Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At that as little as possible letters should be changed in the word. For example, the word HoUse must be replaced with house, and the word ViP — with VIP. If a word contains an equal number of uppercase and lowercase letters, you should replace all the letters with lowercase ones. For example, maTRIx should be replaced by matrix. Your task is to use the given method on one given word.

The first line contains a word s — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100.

Print the corrected word s. If the given word s has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one.

n = readline();
var s = n.replace(/[^a-z]/g, "").length;
if (s >= n.length / 2) print(n.toLowerCase());
else print(n.toUpperCase());

const main = () => {
  const n = readline();
  const regex = new RegExp("[ A-Z ]");
  var cap = 0;

  for (i of n) {
    if (regex.test(i)) {
      cap++;
      continue;
    }
  }

  if (cap > n.length / 2) {
    print(n.toUpperCase());
    return;
  }
  print(n.toLocaleLowerCase());
};

main();

'use strict';
const isCapital = letter => letter === letter.toUpperCase();
let word = readline(),
    counter = 0;

word.split('').map(letter => {
  if (isCapital(letter)) {
    counter++;
  }
});

if (word.length - counter >= counter) {
  write(word.toLowerCase());
} else {
  write(word.toUpperCase());
}

n = readline();
var s = n.replace(/[^a-z]/g, "").length,
    w = n.length - s;
if (w <= s) {
    print(n.toLowerCase())
}
else {
    print(n.toUpperCase())
}

// var word=prompt();
var word=readline();
var newWord=word.split("");
var count=0;
// console.log(word.length);
for(i=0;i<word.length;i++){
    if(newWord[i]===(newWord[i].toUpperCase())){
        count++;
        // console.log(count);
    }
}
// console.log(count >= ((word.length)-count));
if(count > ((word.length)-count)){
    // console.log(word.toUpperCase());
    print(word.toUpperCase());
}
else{
    // console.log(word.toLowerCase());
    print(word.toLowerCase());
}

var string = readline();
var lower = 0, upper = 0;
for (var i = 0; i < string.length; i++) {
	if (string[i] == string[i].toLowerCase() && string[i] != string[i].toUpperCase())
	    lower++;
	else
	    upper++;
}
string = (lower >= upper) ? string.toLowerCase() : string.toUpperCase();
print(string);

var a = readline();
var max =0;
var min = 0;

for (var i=0; i<a.length; i++){
	if (a[i]==a[i].toUpperCase())
	 max++;
	 else min++;
}
if (min>max)
	print(a.toLowerCase());
	else if (min==max)
	print(a.toLowerCase());
else
	print(a.toUpperCase());

var word = readline();
var uppercaseCounter = 0;
var lowercaseCounter = 0;

for(var i = 0; i < word.length; i++) {
    var character = word[i];

    if(character == character.toUpperCase()) {
        uppercaseCounter++;
        continue;
    }

    if(character == character.toLowerCase()) {
        lowercaseCounter++;
        continue;
    }
}

if(uppercaseCounter > lowercaseCounter) {
    print(word.toUpperCase());
} else if(uppercaseCounter < lowercaseCounter || uppercaseCounter == lowercaseCounter) {
    print(word.toLowerCase())
}

var word = readline();
var upperCase =0 , lowerCase =0;
for (var i=0 ; i<word.length ; i++){
    var ch = word[i];
    if (ch == ch.toUpperCase()){
        upperCase ++;
    }
    else{
        lowerCase ++;
    }
}
if (upperCase > lowerCase){
    print(word.toUpperCase());
}
else{
    print(word.toLowerCase());
}

var value = readline()

var countUpper = 0;
var countLower = 0;

for(var i = 0; i < value.length; i++){
    if(/[A-Z]/.test(value[i])){
        countUpper++;
    }else if(/[a-z]/.test(value[i])){
        countLower++;
    }
}

if(countUpper > countLower){
    print(value.toUpperCase())
}else{
    print(value.toLowerCase())
}

input = readline();
var len = input.length;
var lowercase = 0
var uppercase = 0;

for (var i = 0; i < input.length; i++) {

	if (/[A-Z]/.test(input.charAt(i)))
	{
		uppercase++;
	} else {
		lowercase++;
	}
}

if (uppercase > lowercase)
{
	print(input.toUpperCase());
} else {
	print(input.toLowerCase());
}

var word = readline();
var uppercase = 0;
var lowercase = 0;
for(var i = 0; i < word.length; i++){
    if(word[i] === word[i].toUpperCase()) {
        uppercase ++;
    }
    else {
        lowercase ++;
    }
}

if(uppercase > lowercase) {
    print (word.toUpperCase());
}
else {
    print(word.toLowerCase());
}

var input = readline();
var upper = 0;
for(i=0; i< input.length; i++) {
    if(input.charAt(i) === input.charAt(i).toUpperCase())
        upper++;
}
print(input.length / 2 < upper ? input.toUpperCase() : input.toLowerCase());

var s = readline();

var lower = 0, upper = 0;

for (var i = 0; i<s.length; i++) {
    if (s[i] === s[i].toLowerCase()) {
        lower++;
    }
    else {
        upper++;
    }
}

if (lower >= upper) {
    print(s.toLowerCase());
}
else {
    print(s.toUpperCase());
}

var string=readline().split('');

var lower=0;
var upper=0;

for(var i=0;i<string.length;i++){
  if(/[a-z]/.test(string[i])){
     lower++;
  }else if(/[A-Z]/.test(string[i])){
    upper++;

  }
}
var final_string=(string.join(''))

if(lower>upper){
  final_string.toLowerCase()
  print(final_string.toLowerCase())
}else if(upper>lower){

  print(final_string.toUpperCase())
}else{
  final_string.toLowerCase()
  print(final_string.toLowerCase())
}

var word=readline();
var numUpper = (word.match(/[A-Z]/g) || []).length;
if(numUpper>(word.length/2))
word=word.toUpperCase();
else
word=word.toLowerCase();

print(word)

data = readline();
if (moreUpperCaseLetters(data))
    {
         print(data.toUpperCase());
    }
else
    {
         print(data.toLowerCase());
    }

function moreUpperCaseLetters(data)
{
   var upperCaseAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   var lowerCaseAlphabet = "abcdefghijklmnopqrstuvwxyz"
   var lowerCaseCounter = 0;
   var upperCaseCounter = 0;

   for(var index = 0; index < data.length; index++)
        {
              if(data[index] === data[index].toLowerCase())
                  {
                         lowerCaseCounter++;
                  }
              else
                   {
                        upperCaseCounter++;
                   }
        }
     return upperCaseCounter > lowerCaseCounter;
}

var input = readline();
var output = "";
var lC = 0;
var uC = 0;
for(var i = 0; i < input.length; i++)
{
    input[i] == input[i].toUpperCase() ? uC++ : lC++;
}
output = uC > lC ? input.toUpperCase() : input.toLowerCase();
print(output);

var word = readline();
var count = 0;
for(var i = 0; i < word.length; i++){
    if(word[i].match(/[A-Z]/)){
        count++;
    }
}

print(count > (word.length/2)? word.toUpperCase() : word.toLowerCase());

var str=readline();
var mayus=str.toUpperCase();
var long=str.length;
var contMayus=0, contMinus=0;
for(var i=0;i<long;i++){
	if(str[i]==mayus[i]){
		contMayus++;
	}else{
		contMinus++;
	}
}
if(contMayus>contMinus){
	print(mayus);
}else{
	print(str.toLowerCase());
}

var s = readline(),
    upper = 0,
    lower = 0;

for(var i=0; i<s.length; i++) {
    (s.charCodeAt(i)>=65 && s.charCodeAt(i)<=90) ? upper++ : lower++;
}

print((upper <= lower) ? s.toLowerCase() : s.toUpperCase());

var input = readline();

print(convertString(input))

function getCountLetters(string) {
    var capital = 0;
    var small = 0;

    for(var i of string.split('')) {
        if(i == i.toUpperCase()) {
            capital++
        } else {
            small++
        }
    }

    return [capital, small]
}

function convertString(string) {
    var word = getCountLetters(string);
    var capital = word[0];
    var small = word[1];

    if(capital > small) {
        return string.toUpperCase();
    } else {
        return string.toLowerCase();
    }
}

var input = readline();
var i = 0;
var upperCount = 0;

while( upperCount <= input.length / 2 && i < input.length){

  if(input[i] === input[i].toUpperCase()){
    upperCount ++;
  }

  i++;
}

var result = upperCount > input.length / 2  ? input.toUpperCase() : input.toLowerCase();

print(result)

var a = readline(), b = 0, c = 0;
for (; a[b]; b++) if (a[b] >= 'A' && a[b] <= 'Z') c++;
print(b > c && c > b / 2 ? a.toUpperCase() : c && c <= b / 2 ? a.toLowerCase() : a);

var a = readline(), b = -1, c = 0;
while (a[++b]) if (a[b] > '@' && a[b] < '[') c++;
print(c > b / 2 ? a.toUpperCase() : a.toLowerCase());

var str = readline();
var u = (str.match(/[A-Z]/g) || []).length;
var l = (str.match(/[a-z]/g) || []).length;

if (u > l) {
    write(str.toUpperCase());
} else {
    write(str.toLowerCase());
}

function main(){
    var n = readline();
    var u = 0;
    var l = 0;
    for (var j = 0; j < n.length; j++) {
        var temp = n[j];
        if(temp == temp.toUpperCase()) u++;
        else l++;
    }
    if(u > l) {

        print(n.toUpperCase());
    }
    else {
        print(n.toLowerCase())
    }
}
main();

var s = readline();

var upcount = 0;
var lowcount = 0;

for(i=0;i<s.length;i++){
    if(s.charCodeAt(i)<97){
	lowcount+=1;
    }
    else{
	upcount+=1;
    }
}

if(lowcount<=upcount){
    print(s.toLowerCase());
}else{
    print(s.toUpperCase());
}

var word = readline();
var upper = 0, lower = 0;
for (var i = 0; i < word.length; i++) {
	if(word[i].match(/[A-Z]/)) {
		upper++;
	} else {
		lower++;
	}
}

if (upper > lower) {
	print(word.toUpperCase());
} else {
	print(word.toLowerCase());
}

var string = readline();
var upper = 0, lower = 0;
for(var i = 0; i < string.length; i++){
  if(string[i] === string[i].toUpperCase()){
    upper++;
  }
  else{
    lower++;
  }
}
if(upper <= lower){
  print(string.toLowerCase());
}
else{
  print(string.toUpperCase());
}

var word = readline();
var wordArr = word.split("");

var obj = {
    "upper": 0,
    "lower": 0
}

for (var i = 0; i < wordArr.length; i++ ) {
    if (word.charCodeAt(i) >= 65 && word.charCodeAt(i) <= 90) {
        obj["upper"]++;
    } else {
        obj["lower"]++;
    }
}

if (obj["lower"] >= obj["upper"]) {
    print(word.toLowerCase());
} else {
    print(word.toUpperCase());
}

 n = readline();
 var s = n.replace(/[^a-z]/g, "").length;
if(s >= n.length/2) print(n.toLowerCase())
else print(n.toUpperCase())

//var input = "WUBWEWaaAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function main(){
    var a = readline();
    var lower = 0, upper = 0;
    for(var i = 0; i < a.length; i++){
        if(a.charAt(i) >= 'A' && a.charAt(i) <= 'Z')
            upper++;
        else
            lower++;
    }
    if(upper > lower)
        print(a.toUpperCase());
    else
        print(a.toLowerCase());
}
main();

var print = this.print || require('lol-io').print
var write = this.write || require('lol-io').write
var readline = this.readline || require('lol-io').readline

var str=readline();
var abc="abcdefghijklmnopqrstuvwxyz";
var upper=0;
var lower=0;
for(var i=0;i<str.length;i++){
    //console.log(str.charCodeAt(i));
   if(abc.indexOf(str[i])!=-1){
         lower++
   }else{
       upper++;
   }
}
if(upper>lower){
    print(str.toUpperCase());
}else{
    print(str.toLowerCase());
}

var sourceText = readline();
var upperSymbol = 0;
var lowerSymbol = 0;
for (var i=0; i<sourceText.length; i++) {
    if(sourceText.charCodeAt(i) >= 65 && sourceText.charCodeAt(i) <= 90) {
        upperSymbol++;
    } else {
        lowerSymbol++;
    }
}
lowerSymbol >= upperSymbol ? print(sourceText.toLowerCase()) : print(sourceText.toUpperCase());

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    let s1 = readline();
    let lowercase = 0;
    let uppercase = 0;

    for (let i = 0 , c = s1.length ; i < c ; i++){
        if (s1[i].charCodeAt(0) >=97) lowercase++;
        else uppercase ++;
    }
    console.log((lowercase >= uppercase)? s1.toLowerCase() : s1.toUpperCase());
}

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();

    if (input !== null) {
        let lowerCase = 0;
        let upperCase = 0;

        for (let i = 0; i < input.length; i++) {
            if (input[i] == input[i].toUpperCase()) upperCase++;
            else lowerCase++;
        }

        if (upperCase > lowerCase) input = input.toUpperCase();
        if (lowerCase > upperCase || lowerCase == upperCase) input = input.toLowerCase();

        process.stdout.write(`${input}\n`);
        process.exit(0);
    }
});

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
})

readline.question("", (word) => {
    let Ca=0,Sm=0;
    for(let i of word){
        if(i==i.toUpperCase()){
            Ca++;
        }else{
            Sm++;
        }
    }
    if(Ca>Sm){
        console.log(word.toUpperCase());
    }else{
        console.log(word.toLowerCase());
    }
    readline.close()
})

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStd) => {
  inputString += inputStd;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const word = readLine();
  let [lowerCount, upperCount] = [0, 0];
  const isLowerCase = (char) => {
    return char.charCodeAt(0) >= 97 && char.charCodeAt(0) <= 122;
  };
  const convertTo = (word, type = "lower") => {
    const result = [];
    if (type === "upper") {
      for (let i = 0; i < word.length; i++) {
        const char = word[i];
        if (isLowerCase(char)) {
          let charCode = char.charCodeAt(0);
          result.push(String.fromCharCode(charCode - 32));
        } else {
          result.push(char);
        }
      }
    } else {
      for (let i = 0; i < word.length; i++) {
        const char = word[i];
        if (!isLowerCase(char)) {
          let charCode = char.charCodeAt(0);
          result.push(String.fromCharCode(charCode + 32));
        } else {
          result.push(char);
        }
      }
    }
    return result.join("");
  };
  for (let i = 0; i < word.length; i++) {
    if (isLowerCase(word[i])) lowerCount++;
    else upperCount++;
  }
  if (lowerCount >= upperCount) {
    console.log(convertTo(word));
  } else {
    console.log(convertTo(word, "upper"));
  }
}

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

let s ;
let upperCounter = 0 ;
let lowerCounter = 0 ;
let temp ;
rl.on("line",(input)=>{
    s = input.split(" ").toString()
    //console.log(typeof(s))
    temp = s;
   // console.log(temp[0].toLowerCase,s[0])

    for(let i = 0 ; i < s.length ; i++){
        if((temp[i].toLowerCase()) == s[i]) lowerCounter++
        else upperCounter++;
    }
    if(lowerCounter>= upperCounter) console.log(s.toLowerCase())
    else console.log(s.toUpperCase());
});

"use strict";

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const x = readline();

  fn(x);
}

function fn(str) {
   let upperCaseCount = 0;
  let lowerCaseCount = 0;

  for (let char of str) {
    if (/[A-Z]/.test(char)) {
      upperCaseCount++;
    } else {
      lowerCaseCount++;
    }
  }

  console.log(
    upperCaseCount > lowerCaseCount ? str.toUpperCase() : str.toLowerCase()
  );

  return upperCaseCount > lowerCaseCount
    ? str.toUpperCase()
    : str.toLowerCase();
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var s = next();
  var u = s.toUpperCase();
  var ucount = 0;
  var l = s.toLowerCase();
  var lcount = 0;
  for(var i = 0; i < s.length; i++){
    if(s[i] != u[i] && s[i] == l[i]){
      ucount++;
    }
    if(s[i] == u[i] && s[i] != l[i]){
      lcount++;
    }
  }
  if(lcount > ucount){
    myout(u);
  }else{
    myout(l);
  }
}

let inputString = '';
let currentLine = 0;

const runMain = () => {
  inputString = inputString.trim().split('\n').map(string => string.trim());
  main();
  process.exit();
}
const readLine = () => inputString[currentLine++];

process.stdin.on('data', inputStdin => inputString += inputStdin);
process.stdin.on('end', runMain);
process.on('SIGINT', runMain);

function main() {
  let s = readLine();
  let n = 0;
  s.split('').forEach(el => {
    if (el === el.toUpperCase()) {
      n++;
    }
  });
  if (n > s.length / 2) {
    console.log(s.toUpperCase());
  } else {
    console.log(s.toLocaleLowerCase());
  }
}

const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
rl.question("", function (str) {
      var res = (str.replace(/[^A-Z]/g, "").length);
      var reslow = (str.replace(/[^a-z]/g, "").length);
      if (reslow >= res) {
        var up = str.replace(str, str.toLowerCase());
        console.log(up);
      } else {
        var low = str.replace(str, str.toUpperCase());
        console.log(low);
      }
      rl.close();
    }
);

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.on('line', (line) => {
    console.log(solution(line));
});

// Count the number of uppercase and lower case letters
// If numUpper > numLower turn everything into upper
// Else turn everything into lower
function solution(input) {
    const word = input.split('');
    let numUpper = 0, numLower = 0;
    for (let i = 0; i < word.length; i++) {
        if (word[i] === word[i].toUpperCase()) {
            numUpper++;
        } else {
            numLower++;
        }
    }

    if (numUpper > numLower) {
        return input.toUpperCase();
    } else {
        return input.toLowerCase();
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  const a = readline();
  let l = 0;
  let result = a.toUpperCase();
  for (let i = 0; i < a.length; i++) {
    const c = a.charAt(i);
    if (c === c.toLowerCase()) {
      l++
    }
    if (l >= Math.ceil((a.length) / 2)) {
      result = a.toLowerCase();
      break;
    }
  }
  // output
  print(result);
}

//Word

const {EOL} = require('os');

let inp = '';

process.stdin.on('data', c => inp += c);

process.stdin.on('end', () => {
    const lines = inp.split(EOL)[0].trim();

    let small = 0;
    for(let i = 0; i < lines.length; i++)  {
    	if(lines[i] >= 'a' && lines[i] <= 'z')  {
    		small++;
    		if(small > lines.length / 2)  {
    			break;
    		}
    	}
    }

    if(small >= lines.length / 2)  {
    	process.stdout.write(lines.toLowerCase());
    }  else  {
    	process.stdout.write(lines.toUpperCase());
    }

    return;
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (w) => {
  let lowerCount = 0;
  let upperCount = 0;

  for (let i = 0; i < w.length; i++) {
    if (w.charCodeAt(i) > 64 && w.charCodeAt(i) < 97) {
      upperCount++;
    }
    else {
      lowerCount++;
    }
  }

  if (upperCount > lowerCount) {
    console.log(w.toUpperCase());
  }
  else {
    console.log(w.toLowerCase());
  }
});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    const str = readline();
    let upperCase = 0;
    let lowerCase = 0;
    for (let i = 0; i < str.length; i++) {
        if (str[i] === str[i].toUpperCase()) {
            upperCase++;
        }
        else {
            lowerCase++;
        }
    }

    if (upperCase > lowerCase)
        console.log(str.toUpperCase())
    else
        console.log(str.toLowerCase())

    return;
}

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

const isCapitalize = s => s.toUpperCase() === s;
const isLower = s => s.toLowerCase() === s;

readLine.on('close', () => {
  const word = input[0];
  let s = 0, b = 0;

  for (let i = 0; i < word.length; i += 1) {
    if (isCapitalize(word[i])) b += 1;
    else s += 1;
  }

  if ( s >= b ) console.log(word.toLowerCase());
  else console.log(word.toUpperCase());
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.on('line', (input) => {
    let upper = (input.match(/[A-Z]/g) || []).length;
    let lower = (input.match(/[a-z]/g) || []).length;

    if(upper > lower) {
        console.log(input.toUpperCase());
    } else {
        console.log(input.toLowerCase());
    }
    rl.close();
});

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let x=readLine()
	let uc=0,lc=0
	for(let char of x)
		if(char==char.toUpperCase())
			uc++
		else lc++

	if(lc==uc || lc > uc)
		console.log(x.toLowerCase())
	else console.log(x.toUpperCase())
}

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

function main() {
	let s = readLine().split('');
	let l = 0,
		u = 0;
	s.forEach(c => (c.charCodeAt(0) >= 65 && c.charCodeAt(0) < 97 ? u++ : l++));
	if (l >= u) console.log(s.join('').toLowerCase());
	else console.log(s.join('').toUpperCase());
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}

function main() {
    let word = readLine();
    let wordArray = word.split('');
    let smallLetters = [];
    let CapitalLetters = [];
    for (let i = 0; i < wordArray.length; i++) {
        if (
            wordArray[i] === wordArray[i].toUpperCase() &&
            wordArray[i] !== wordArray[i].toLowerCase()
        ) {
            CapitalLetters.push(wordArray[i]);
        } else {
            smallLetters.push(wordArray[i]);
        }
    }
    if (CapitalLetters.length > smallLetters.length) {
        console.log(word.toUpperCase());
    } else {
        console.log(word.toLowerCase());
    }
}

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
});

const input = [];
readline.on('line', line => input.push(line));

readline.on('close', () => {
    let [word] = input;
    let l = (word.match(/[a-z]/g) || []).length;
    if (l >= word.length / 2) console.log(word.toLowerCase());
    else console.log(word.toUpperCase());
});

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var input = [];
rl.on('line', function (line) {input.push(line);});
rl.on('close', function() {
    const word = input[0];
    let lowerCount = 0;
    let upperCount = 0;

    for(let i = 0; i < word.length; i++) {
        if(isUpperCased(word[i])) upperCount++;
        if(!isUpperCased(word[i])) lowerCount++;
    }

    if (upperCount > lowerCount) {
        console.log(word.toUpperCase())
    } else if( lowerCount === upperCount || lowerCount > upperCount) {
        console.log(word.toLowerCase())
    }

});

function isUpperCased(l) {
    return l.toUpperCase() === l;
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function readAsInt(){
  return parseInt(readline());
}

function readAsIntList(){
  return readline().split(' ').filter(i => i).map(i => parseInt(i));
}

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  let s = readline();
  let l = s.replace(/[^a-z]+/g,'').length;
  let u = s.replace(/[^A-Z]+/g,'').length;
  console.log((l > u || l === u) ? s.toLowerCase() : s.toUpperCase());
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function readLine() {
  return inputString[currentLine++];
}

/******** Main function*************/

function main() {
  var s = readLine();

  function isLowerCase(str) {
    return str == str.toLowerCase() && str != str.toUpperCase();
  }

  var lCount = 0,
    uCount = 0;

  for (var i = 0; i < s.length; i++) {
    if (isLowerCase(s[i])) {
      lCount++;
    } else {
      uCount++;
    }
  }

  var str = "";

  if (lCount > uCount || lCount == uCount) str = s.toLowerCase();

  if (lCount < uCount) str = s.toUpperCase();

  console.log(str);
}

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let i = 0; i < txt.length; i ++) {
    doit(txt[i]);

}

function doit(str) {
    let tab =str.split("").filter(data=>{return data.length>0});
    let min=0;
    tab.forEach(data => {
        if(data.charCodeAt()>=97)min++;
    });
    if(min>=tab.length-min){
        console.log(str.toLowerCase());
    }else{
        console.log(str.toUpperCase());

    }

}

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {
    let inputs = str.trim();
    let upperCaseCount = inputs.replace(/[a-z]/g, '').length;
    let lowerCaseCount = inputs.replace(/[A-Z]/g, '').length;
    if (upperCaseCount == lowerCaseCount || lowerCaseCount > upperCaseCount) {
        inputs = inputs.toLowerCase();
    }
    else if (upperCaseCount > lowerCaseCount) {
        inputs = inputs.toUpperCase();
    }
    return inputs.toString();
}

const readLine = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));
const word = () => {
    let ar = [];
    for (const x of input[0]) {
        ar.push(x);
    }
    let upper = 0;
    let lower = 0;
    for (const y of ar) {
        if (y === y.toUpperCase() ) {
            upper++;
        }
        else {
            lower++;
        }
    }
    console.log(upper > lower ? input[0].toUpperCase() : input[0].toLowerCase());
};

readLine.on('close', word);

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    let s = readLine();
    let totalOfLowerCase = s.split('').filter((value) => {
        return value.charCodeAt(0) >= 97
    }).length;
    let totalOfUpperCase = s.split('').filter((value) => {
        return value.charCodeAt(0) < 97
    }).length;
    if (totalOfUpperCase > totalOfLowerCase) {
        console.log(s.toUpperCase());
    } else {
        console.log(s.toLowerCase());
    }
}

var s=readline();
var lc=0;
for(var i=0;i<s.length;i++){
	if(s[i]>='a'&&s[i]<='z'){
		lc++;
	}
}
if(lc*2>=s.length){
	print( s.toLowerCase() );
}else{
	print( s.toUpperCase() );
}

var word = readline(), big = 0, small = 0;

for(i = 0; i < word.length; i++){
	if( /[A-Z]/.test(word[i]) ){
		big++;
	}
	else{
		small++;
	}
}
if(big > small){
	write(word.toUpperCase());
}
else{
	write(word.toLowerCase());
}

var s = readline();
var a = s.toLowerCase();
var b = s.toUpperCase();
var n = s.length;
var toL = 0, toU = 0;
for (var i = 0; i < n; i ++) {toL += +(s[i] != a[i]); toU += +(s[i] != b[i]);}
print(toL > toU ? b : a);

var upper=0;
var lower=0;
var input = readline();
var ch;
for(var i=0 ; i<input.length ;i++){
    ch = input.charAt(i);
    if(ch == ch.toLowerCase())
        lower++;
    else
        upper++;

}

if(upper>lower)
    print(input.toUpperCase());
else
    print(input.toLowerCase());

var s = readline();
var n = s.length;

var lowercase = 0, uppercase = 0;

for(var i=0;i<n;i++) {
  if(s[i].charCodeAt()>='a'.charCodeAt() && s[i].charCodeAt()<='z'.charCodeAt()) {
    ++lowercase;
  }
  else {
    ++uppercase;
  }
}

if(lowercase>=uppercase) {
  print(s.toLowerCase());
}
else {
  print(s.toUpperCase());
}

var word = readline();
var clower = Array.prototype.reduce.call(word, function(prev, cur, i, a){return prev + ((cur <= 'z' && cur >= 'a') ? 1 : 0);}, 0);
if(clower >= word.length - clower)
    write(word.toLowerCase());
else write(word.toUpperCase());

function main(){
    var word = readline();
    var letters = word.split('');
    var lower = 0;
    var upper = 0;
    for(var i = 0; i < letters.length; ++i){
        if(letters[i].match(/[A-Z]/)) ++upper;
        else ++lower;
    }
    if(lower >= upper){
        print(word.toLowerCase());
    }
    else{
        print(word.toUpperCase());
    }

}

main();

function transform (text) {

  var lowerCount = 0, upperCount =0;
  for(var i =0; i < text.length; ++i){

    if("A".charCodeAt(0) <= text.charCodeAt(i) && "Z".charCodeAt(0) >= text.charCodeAt(i) ){
       ++upperCount;
    } else {
       ++lowerCount;
    }
  }
  return (lowerCount < upperCount) ? text.toUpperCase() : text.toLowerCase();
}

print(transform(readline()))

var word= readline();
var lowerString = 0;
var upperString = 0;

for (var i = 0; i < word.length; i++) {
    if (word.charAt(i).toLowerCase() == word.charAt(i)) {
      lowerString++;
    } else {
      upperString++;
    }
}
if(lowerString >= upperString) print(word.toLowerCase());
else {
    print(word.toUpperCase())

}

var s = readline();

var upperCounter = 0;
var lowerCounter = 0;

for (var i = 0; i < s.length; i++) {
    if (s[i] == s[i].toUpperCase()) upperCounter++;
    else lowerCounter++;
}

if (upperCounter > lowerCounter) print(s.toUpperCase())
else print(s.toLowerCase())

print(answer(readline()));

function answer(input){
    var capitalArr = input.match(/[A-Z]{1}/g)
    if(capitalArr){
        var capitalNum = input.match(/[A-Z]{1}/g).length;
        var lowerNum = input.length - capitalNum;
        if(capitalNum > lowerNum){
            return input.toUpperCase();
        } else{
            return input.toLowerCase();
        }
    } else{
        return input;
    }
}

var s = readline();

var lcc = 0;
var ucc = 0;

for (var i = 0; i < s.length; i++) {

    var lCode = s.charCodeAt(i);
    if (lCode >= 65 && lCode <= 90) {
        ucc += 1;
    } else if (lCode >= 97 && lCode <= 122) {
        lcc += 1;
    }

}

if (lcc >= ucc) {
    print(s.toLowerCase());
} else {
    print(s.toUpperCase());
}

var input = readline()
var lowerCounter = 0
var upperCounter = 0

for (var i = 0; i < input.length; i++) {
  if (input.charCodeAt(i) >= 'a'.charCodeAt(0) && input.charCodeAt(0) <= 'z'.charCodeAt(0)) {
    lowerCounter += 1
  } else {
    upperCounter += 1
  }
}

if (upperCounter > lowerCounter) {
  print(input.toUpperCase())
} else {
  print(input.toLowerCase())
}

var input = readline();
var small = 0;
var big = 0;

for(var i=0; i<input.length; i++){
    if(input.charCodeAt(i)>=65 && input.charCodeAt(i)<=90)big++;
    if(input.charCodeAt(i)>=97 && input.charCodeAt(i)<=122)small++;
}
var output='';
if(big>small){
    print(input.toUpperCase());
}else{
    print(input.toLowerCase());
}

// parameter "input" gets all data
function Main() {
	var s = readline().trim();
	var nbr = 0;
	for (var i = 0; i < s.length;i++) {
		nbr+=s[i].toLowerCase()==s[i];
	}
	print((nbr<s.length/2)?s.toUpperCase():s.toLowerCase());

}

Main();

;(function () {
	var b = 0;
	var l = 0;

	var s = readline();

	for (var i = 0; i < s.length; i++)
		if (s[i].toUpperCase() == s[i]) b++;
		else l++;

	print( l >= b ? s.toLowerCase() : s.toUpperCase() );

}).call(this);

'use strict'

let lll = readline()

let s = 0
let b = 0

for (let l of lll) l == l.toUpperCase() ? b++ : s++

print(s >= b ? lll.toLowerCase() : lll.toUpperCase())

      var word = readline().split(""),
        lower = 0,
        upper = 0;
      for (var i = 0; i < word.length; i++) {
        if (word[i] == word[i].toLowerCase()) {
          lower++;
        } else {
          upper++;
        }
      }
      if (lower > upper) {
        word = word.join("").toLowerCase();
      } else if (lower == upper) {
        word = word.join("").toLowerCase();
      } else {
        word = word.join("").toUpperCase();
      }

      print(word);

n = readline();
var s = n.replace(/[^a-z]/g).length;
if (s >= n.length / 2) print(n.toLowerCase());
else print(n.toUpperCase());

const main = () => {
  const n = readline();
  const regex = new RegExp("[ A-Z ]");
  var cap = 0;

  for (i of n) {
    print(i, regex.test(i));
    if (regex.test(i)) {
      cap++;
      continue;
    }
  }

  if (cap > n.length / 2) {
    print(n.toUpperCase());
    return;
  }
  print(n.toLocaleLowerCase());
};
main();

const main = () => {
  const n = readline();
  const regex = new RegExp("a-z");
  var cap = 0;

  for (i of n) {
    if (regex.test(i)) {
      cap++;
      continue;
    }
  }

  if (cap > n.length / 2) {
    print(n.toUpperCase());
    return;
  }
  print(n.toLocaleLowerCase());
};
main()

'use strict';
const isCapital = letter => letter === letter.toUpperCase();
let word = readline(),
    counter = 0;

word.split().map(letter => {
  if (isCapital(letter)) {
    counter++;
  }
});

if (word.length - counter >= counter) {
  write(word.toLowerCase());
} else {
  write(word.toUpperCase());
}

n = readline();
var s = n.replace(/[^a-z]/g, "").length,
    w = n.length - s;
print(s);
print(w);

n = readline();
var s = n.replace(/[^a-z]/g, "").length,
    w = n.length - s;
if (s <= w) {
    print(n.toLowerCase())
}
else {
    print(n.toUpperCase())
}

n = readline();
var s = n.replace(/[^a-z]/g, "")
print(s)

n = readline();
var s = n.replace(/[^a-z]/g, "").length,
    w = n.length - 5;
if (s <= w) {
    print(n.toLowerCase())
}
else {
    print(n.toUpperCase())
}

// var word=prompt();
var word=readline();
var newWord=word.split("");
var count=0;
// console.log(word.length);
for(i=0;i<word.length;i++){
    if(newWord[i]===(newWord[i].toUpperCase())){
        count++;
        // console.log(count);
    }
}
// console.log(count >= ((word.length)-count));
if(count >= ((word.length)-count)){
    // console.log(word.toUpperCase());
    print(word.toUpperCase());
}
else{
    // console.log(word.toLowerCase());
    print(word.toLowerCase());
}

var string = readline();
var lower = 0, upper = 0;
for (var i = 0; i < string.length; i++) {
	if (string[i] == string[i].toLowerCase())
	    lower++;
	else
	    upper++;
}
if (lower >= upper)
    string.toLowerCase();
else
    string.toUpperCase();
print(string);

var a = readline();
var max =0;
var min = 0;

for (var i=0; i<a.length; i++){
	if (a[i]==a[i].toUpperCase())
	 max++;
	 else min++;
}
if (min>max)
	print(a.toLowerCase());
	else if (min=max)
	print(a.toLowerCase());
else
	print(a.toUpperCase());

var word = readline();
var uppercase = 0;
var lowercase = 0;
for(var i = 0; i < word.length; i++){
    if(word[i] > 'A' && word[i] < 'Z') {
        uppercase ++;
    }
    else {
        lowercase ++;
    }
}

if(uppercase > lowercase) {
    print (word.toUpperCase());
}
else {
    print(word.toLowerCase());
}

var word = readline();
var count = 0;
for(var i = 0; i < word.length; i++){
    if(word[i].match(/[A-Z]/)){
        count++;
    }
}

print(count);

var a = readline(), b = 0, c = 0;
for (; a[b]; b++) if (a[b] >= 'A' && a[b] <= 'Z') c++;
print(b > c && c > b / 2 ? a.toUpperCase() : c && c <= b / 2 ? a.toLowerCase() : '');

var string = readline();
var upper = 0, lower = 0;
for(var i = 0; i < string.length; i++){
  if(string[i] === string[i].toUpperCase){
    upper++;
  }
  else{
    lower++;
  }
}
if(upper < lower){
  print(string.toLowerCase());
}
else{
  print(string.toUpperCase());
}

var string = readline();
var upper = 0, lower = 0;
for(var i = 0; i < string.length; i++){
  if(string[i] === string[i].toUpperCase()){
    upper++;
  }
  else{
    lower++;
  }
}
if(upper < lower){
  print(string.toLowerCase());
}
else{
  print(string.toUpperCase());
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStd) => {
  inputString += inputStd;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let num = readLine()
    .split("")
    .map((n) => parseInt(n));
  const map = {};
  for (let i = 0; i < num.length; i++) {
    if (!map[num[i]]) map[num[i]] = 1;
    else map[num[i]]++;
  }
  function isLucky(num) {
    if (!num) return false;
    while (num) {
      if (num % 10 !== 4 && num % 10 !== 7) return false;
      num = parseInt(num / 10);
    }
    return true;
  }
  let [four, seven] = [map["4"] || 0, map[7] || 0];
  const total = four + seven;
  if (isLucky(total)) console.log("YES");
  else console.log("NO");
}

var str = "HoUse";
  var res = (str.replace(/[^A-Z]/g, "").length);
  var reslow = (str.replace(/[^a-z]/g, "").length);
  if(reslow >= res){
  var up = str.replace(str , str.toLowerCase() );
  console.log(up);
  }else{
  var low = str.replace(str , str.toUpperCase() );
  console.log(low);
  }

var str = "AAAAdel";
  var res = (str.replace(/[^A-Z]/g, "").length);
  var reslow = (str.replace(/[^a-z]/g, "").length);
  if(reslow >= res){
  var up = str.replace(str , str.toLowerCase() );
  console.log(up);
  }else{
  var low = str.replace(str , str.toUpperCase() );
  console.log(low);
  }

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.on('line', (input) => {
    console.log(input.toLowerCase());
    rl.close();
});

var word = readline();
var clower = Array.prototype.reduce.call(word, function(prev, cur, i, a){return prev + ((cur <= 'z' && cur >= 'a') ? 1 : 0);}, 0);
if(clower >= word.length - clower)
    write(word.toLowerCase());
else write(word.toLowerCase());

function transform (text) {

  var lowerCount = 0, upperCount =0;
  for(var i =0; i <= text.length; ++i){

    if("A".charCodeAt(0) <= text.charCodeAt(i) && "Z".charCodeAt(0) >= text.charCodeAt(i) ){
       ++upperCount;
    } else {
       ++lowerCount;
    }
  }
  return (lowerCount < upperCount) ? text.toUpperCase() : text.toLowerCase();
}

print(transform(readline()))

function transform (text) {

  var lowerCount = 0, upperCount =0;
  for(var i =0; i <= text.length; ++i){

    if("A".charCodeAt(0) <= text.charCodeAt(i) && "Z".charCodeAt(0) >= text.charCodeAt(i) ){
       ++upperCount;
    } else {
       ++lowerCount;
    }
  }
  return (lowerCount < upperCount) ? text.toUpperCase() : text.toLowerCase();
}

transform(readline())

var input = readline();
var small = 0;
var big = 0;

for(var i=0; i<input.length; i++){
    if(input.charCodeAt(i)>=65 || input.charCodeAt(i)>=90)big++;
    if(input.charCodeAt(i)>=97 || input.charCodeAt(i)>=122)small++;
}
var output='';
if(big>small){
    print(input.toUpperCase());
}else{
    print(inpu.toLowerCase());
}

var input = readline();
var small = 0;
var big = 0;

for(var i=0; i<input.length; i++){
    if(input.charCodeAt(i)>=65 || input.charCodeAt(i)<=90)big++;
    if(input.charCodeAt(i)>=97 || input.charCodeAt(i)<=122)small++;
}
var output='';
if(big>small){
    print(input.toUpperCase());
}else{
    print(input.toLowerCase());
}


Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Petya loves tickets very much. As we know, each ticket has a number that is a positive integer. Its length equals n (n is always even). Petya calls a ticket lucky if the ticket's number is a lucky number and the sum of digits in the first half (the sum of the first n / 2 digits) equals the sum of digits in the second half (the sum of the last n / 2 digits). Check if the given ticket is lucky.

The first line contains an even integer n (2 ≤ n ≤ 50) — the length of the ticket number that needs to be checked. The second line contains an integer whose length equals exactly n — the ticket number. The number may contain leading zeros.

On the first line print "YES" if the given ticket number is lucky. Otherwise, print "NO" (without the quotes).

NoteIn the first sample the sum of digits in the first half does not equal the sum of digits in the second half (4 ≠ 7).In the second sample the ticket number is not the lucky number.

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (str) => {
  if (c === 0) {
    c++;
    return;
  }

  let ans = 'YES';
  let sevens = 0;
  let fours = 0;

  for (let i = 0; i < str.length / 2; i++) {
    if (str[i] === '4') {
      fours++;
    }
    else if (str[i] === '7') {
      sevens++;
    }
    else {
      ans = 'NO';
    }
  }

  for (let i = str.length / 2; i < str.length; i++) {
    if (str[i] === '4') {
      fours--;
    }
    else if (str[i] === '7') {
      sevens--;
    }
    else {
      ans = 'NO';
    }
  }

  if (fours === 0 && sevens === 0) {
    console.log(ans);
  }
  else {
    console.log('NO');
  }

  c++;
});

var n=+readline();
var t=readline();
if(/^[47]+$/.test(t)){
	t=t.split('').map(Number);
	var sum=t.reduce(add);
	print( sum/2===t.slice(0, n/2).reduce(add)?'YES':'NO' )
}else{
	print('NO');
}
function add(a,b){return a+b;};

String.prototype.happy=function(){return/^(4|7)+$/.test(this)};String.prototype.firstHalf=function(){var e=this.toString().split("");return e.slice(0,e.length/2)};String.prototype.laseHalf=function(){var e=this.toString().split("");return e.slice(e.length/2)};Array.prototype.sum=function(){var e=this.length,t=0;while(e--)t+=+this[e];return t}

;(function () {

	readline();
	var s = readline();

	print( s.happy() && s.firstHalf().sum() == s.laseHalf().sum() ? 'YES' : 'NO' );

}).call(this)


One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.

The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.

It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.

var array = [];
for( var i =0; i<3; i++) {
    array.push(readline());
}
var characters = 'ABC';
var options = [],
    prevOptions, result;
for (var i = 0; i < array.length; i++) {
    var biggerIndex, lessIndex;
    prevOptions = options;
    var thirdChar = characters.replace(array[i][0], '').replace(array[i][2], '');

    if (array[i][1] === '>') {
        result = array[i][2] + array[i][0];
    } else {
        result = array[i][0] + array[i][2];
    }

    options = [thirdChar + result, result + thirdChar,
        result[0] + thirdChar + result[1]
    ];
    if (prevOptions.length) {
        for (var j = 0; j < options.length; j++) {
            var index = prevOptions.indexOf(options[j]);
            if (index === -1) {
                options.splice(j, 1);
                j--;
            }
        }

    }

}
if(options.length) {
    print(options[0]);
} else {
    print('Impossible');
}

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var characters = "ABC",
		characterNum = characters.length,
		pairNum = characterNum * (characterNum-1) / 2;

	var counts = {};
	for (var characterIndex = 0; characterIndex < characterNum; ++characterIndex) {
		counts[characters.charAt(characterIndex)] = 0;
	}

	for (var lineIndex = 0; lineIndex < pairNum; ++lineIndex) {
		var line = readline();
		var indexHeavier = (line.charAt(1) == '>' ? 0 : 2);
		var characterHeavier = line.charAt(indexHeavier);
		counts[characterHeavier] += 1;
	}

	var countList = [];
	var allCountsOne = true;
	for (var characterIndex = 0; characterIndex < characterNum; ++characterIndex) {
		var name = characters.charAt(characterIndex);
		var count = counts[name];
		if (count != 1) {
			allCountsOne = false;
		}
		countList.push({ name: name, count: count });
	}

	if (allCountsOne) {
		print("Impossible");
		return;
	}

	countList.sort(function (a, b) {
		return a.count - b.count;
	});

	var parts = [];
	for (var partIndex = 0; partIndex < characterNum; ++partIndex) {
		parts.push(countList[partIndex].name);
	}
	print(parts.join(""));
}

main();

'use strict'

let lll
let ps = []

while (lll = readline()) {
  lll = lll.split('')
  let s = lll[1]
  ps.push(s == '<' ? [lll[0], lll[2]] : [lll[2], lll[0]])
}

(function () {
  for (let i = 0; i < ps.length; i++) {
    for (let j = 0; j < ps.length; j++) {
      if (i == j) {if (ps[i][0] == ps[i][1]) {return print('Impossible')} else {continue}}
      let k = 3 - i - j
      if (ps[i][0] == ps[j][1]) {
        if (ps[k][1] == ps[i][1]) {
          return print(ps[j][0] + ps[j][1] + ps[i][1])
        } else {
          return print('Impossible')
        }
      }
    }
  }
  print('Impossible')
})()

'use strict';

/*let input = `A<B
B<C
C<A`.split('\n');
function print(output) {
	console.log(output);
}
function readline() {
	return input.shift();
}
*/
//code

var values = {},
    isImpossible = false;
for (var i = 0; i < 3; i++) {
	var expr = readline().trim();
	var var1 = expr[0],
	    var2 = expr[2],
	    sign = expr[1];
	if (values[var1] === undefined && values[var2] === undefined) {
		values[var1] = 10;
		values[var2] = values[var1] + (sign === '>' ? -1 : 1);
	} else if (values[var1] == undefined || values[var2] == undefined) {
		if (values[var1] === undefined) {
			values[var1] = values[var2] + (sign === '<' ? -1 : 1);
		} else {
			values[var2] = values[var1] + (sign === '>' ? -1 : 1);
		}
	} else {
		if (values[var1] === values[var2]) {
			values[var2] = values[var1] + (sign === '>' ? -0.5 : 0.5);
		} else if (!(sign === '>' && values[var1] > values[var2]) && !(sign === '<' && values[var1] < values[var2])) {
			print("Impossible");
			isImpossible = true;
		}
	}
}
if (!isImpossible) {
	print(Object.keys(values).sort(function (a, b) {
		return values[a] - values[b];
	}).join(''));
}

'use strict'

let lll
let ps = []

while (lll = readline()) {
  lll = lll.split('')
  let s = lll[1]
  ps.push(s == '<' ? [lll[0], lll[2]] : [lll[2], lll[0]])
}

(function () {
  for (let i = 0; i < ps.length; i++) {
    for (let j = 0; j < ps.length; j++) {
      if (i == j) {if (ps[i][0] == ps[i][1]) {return print('Impossible')} else {continue}}
      if (ps[i][0] == ps[j][1]) return print(ps[j][0] + ps[j][1] + ps[i][1])
    }
  }
  print('Impossible')
})()


Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) two such words. More formally, word "nineteen" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.Help her to find the maximum number of "nineteen"s that she can get in her string.

The first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.

Print a single integer — the maximum number of "nineteen"s that she can get in her string.

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const word = readline();

    let minChar = {
        n: 3,
        i: 1,
        e: 3,
        t: 1
    }

    let quantChar = {
        n: word.split("n").length-1,
        i: word.split("i").length-1,
        e: word.split("e").length-1,
        t: word.split("t").length-1
    }

    console.log(countNineteen(minChar, quantChar))
}

function countNineteen(min, quant) {
    let count = 0

    while (quant.n >= min.n && quant.i >= min.i && quant.e >= min.e && quant.t >= min.t) {
        quant.n -= min.n
        quant.i -= min.i
        quant.e -= min.e
        quant.t -= min.t

        quant.n += 1

        count += 1
    }

    return count
}

process.stdin.on("data", (d)=>{
    let s = d.toString();
    let counterOfChars = {n: 0, e: 0, i: 0, t: 0};
    for(let char of s){
        switch(char){
            case 'n':
                counterOfChars.n++;
                break;
            case 'e':
                counterOfChars.e++;
                break;
            case 'i':
                counterOfChars.i++;
                break;
            case 't':
                counterOfChars.t++;
                break;
        }
    }
    if(counterOfChars.n < 3){
        console.log(0);
        return;
    }
    let maxCount = Math.floor((counterOfChars.n - 1) / 2);
    if(counterOfChars.i < maxCount) maxCount = counterOfChars.i;
    if(Math.floor(counterOfChars.e / 3) < maxCount) maxCount = Math.floor(counterOfChars.e / 3);
    if(counterOfChars.t < maxCount) maxCount = counterOfChars.t;
    console.log(maxCount);
});

const readline = require('readline');

const fin = readline.createInterface(process.stdin, process.stdout, undefined, false);

fin.on('line', function(str) {
    const map = new Map();
    for (let i=0; i<str.length; i++) {
        if (!map.has(str[i])) {
            map.set(str[i], 0);
        }
        map.set(str[i], map.get(str[i]) + 1);
    }
    let ans = Math.min(
        parseInt((map.get('n') - 1) / 2) || 0,
        parseInt(map.get('i')) || 0,
        parseInt(map.get('e') / 3) || 0,
        parseInt(map.get('t')) || 0,
    );

    console.log(ans);
});

function haha2(str) {
  const countN = str.split('n').length - 1;
  const countI = str.split('i').length - 1;
  const countE = str.split('e').length - 1;
  const countT = str.split('t').length - 1;
  return Math.min(parseInt((countN - 1) / 2), countI, parseInt(countE / 3), countT);
}
var str = readline();
print(haha2(str));

// Getting Problem Data from Codeforces.
var inputString = readline();
// Setting up and populating HashMap.
var nineteenHashMap = {'n':0,'i':0,'e':0,'t':0};
for (var index = 0;index<inputString.length;++index)
   nineteenHashMap[inputString[index]]+=1;
// For Counting Number of Nineteens.
var nineteenCount = 0;
// Algorithm.
m = nineteenHashMap;
while (m['n']>=3 && m['i']>=1 && m['e']>=3 && m['t']>=1){
  //Increasing count and removing from HashMap.
  m['n']-=2;m['i']-=1;m['e']-=3;m['t']-=1;
  nineteenCount+=1;
}
print(nineteenCount);

var str = readline();
const countN = str.split('n').length - 1;
const countI = str.split('i').length - 1;
const countE = str.split('e').length - 1;
const countT = str.split('t').length - 1;
print(Math.min(parseInt((countN - 1) / 2), countI, parseInt(countE / 3), countT));

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	var c = 0;
	_break:
	while(1) {
		for(var i = 0; i < target.length; i++) {
			if ( !map[target[i]]-- ) {
				break _break;
			}
		}
		if ( !c )
			target.shift();
		c++;
	}
	return c;

	return Math.min(map["n"]/2|0, map["e"]/3|0, map["t"], map["i"]);

	//const arr = target.map(c => map[c]);
	//return Math.min.apply(null, arr);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    var nValue = Math.max(Math.floor((countedN - 1) / 2), 0);

    var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const word = readline();

    let minChar = {
        n: 3,
        i: 1,
        e: 3,
        t: 1
    }

    let quantChar = {
        n: word.split("n").length-1,
        i: word.split("i").length-1,
        e: word.split("e").length-1,
        t: word.split("t").length-1
    }

    console.log(countNineteen(minChar, quantChar))
}

function countNineteen(min, quant) {
    let count = 0

    while (quant.n >= min.n && quant.i >= min.i && quant.e >= min.e && quant.t >= min.t) {
        quant.n -= min.n
        quant.i -= min.i
        quant.e -= min.e
        quant.t -= min.t

        count += 1
    }

    return count
}

process.stdin.on("data", (d)=>{
    let s = d.toString();
    let counterOfChars = {n: 0, e: 0, i: 0, t: 0};
    for(let char of s){
        switch(char){
            case 'n':
                counterOfChars.n++;
                break;
            case 'e':
                counterOfChars.e++;
                break;
            case 'i':
                counterOfChars.i++;
                break;
            case 't':
                counterOfChars.t++;
                break;
        }
    }
    if(counterOfChars.n < 3 || counterOfChars.i === 0 || counterOfChars.e === 0 || counterOfChars.t === 0){
        console.log(0);
        return;
    }
    let minCount = Math.floor(counterOfChars.n - 3, 2) + 1;
    if(counterOfChars.i < minCount) minCount = counterOfChars.i;
    if(Math.floor(counterOfChars.e, 3) < minCount) minCount = counterOfChars.e;
    if(counterOfChars.t < minCount) minCount = counterOfChars.t;
    console.log(minCount);
});

process.stdin.on("data", (d)=>{
    let s = d.toString();
    let counterOfChars = {n: 0, e: 0, i: 0, t: 0};
    for(let char of s){
        switch(char){
            case 'n':
                counterOfChars.n++;
                break;
            case 'e':
                counterOfChars.e++;
                break;
            case 'i':
                counterOfChars.i++;
                break;
            case 't':
                counterOfChars.t++;
                break;
        }
    }
    if(counterOfChars.n < 3){
        console.log(0);
        return;
    }
    let maxCount = Math.floor((counterOfChars.n - 1) / 2);
    if(counterOfChars.i < maxCount) maxCount = counterOfChars.i;
    if(Math.floor(counterOfChars.e / 3) < maxCount) maxCount = counterOfChars.e;
    if(counterOfChars.t < maxCount) maxCount = counterOfChars.t;
    console.log(maxCount);
});

process.stdin.on("data", (d)=>{
    let s = d.toString();
    let counterOfChars = {n: 0, e: 0, i: 0, t: 0};
    for(let char of s){
        switch(char){
            case 'n':
                counterOfChars.n++;
                break;
            case 'e':
                counterOfChars.e++;
                break;
            case 'i':
                counterOfChars.i++;
                break;
            case 't':
                counterOfChars.t++;
                break;
        }
    }
    if(counterOfChars.n < 3 || counterOfChars.i === 0 || counterOfChars.e === 0 || counterOfChars.t === 0){
        console.log(0);
        return;
    }
    let minCount = Math.floor((counterOfChars.n - 3) / 2) + 1;
    if(counterOfChars.i < minCount) minCount = counterOfChars.i;
    if(Math.floor(counterOfChars.e / 3) < minCount) minCount = counterOfChars.e;
    if(counterOfChars.t < minCount) minCount = counterOfChars.t;
    console.log(minCount);
});

process.stdin.on("data", (d)=>{
    let s = d.toString();
    let counterOfChars = {n: 0, e: 0, i: 0, t: 0};
    for(let char of s){
        switch(char){
            case 'n':
                counterOfChars.n++;
                break;
            case 'e':
                counterOfChars.e++;
                break;
            case 'i':
                counterOfChars.i++;
                break;
            case 't':
                counterOfChars.t++;
                break;
        }
    }
    if(counterOfChars.n > 3 || counterOfChars.i === 0 || counterOfChars.e === 0 || counterOfChars.t === 0){
        console.log(0);
        return;
    }
    let minCount = Math.floor(counterOfChars.n - 3, 2) + 1;
    if(counterOfChars.i < minCount) minCount = counterOfChars.i;
    if(Math.floor(counterOfChars.e, 3) < minCount) minCount = counterOfChars.e;
    if(counterOfChars.t < minCount) minCount = counterOfChars.t;
    console.log(minCount);
});

process.stdin.on("data", (d)=>{
    let s = d.toString();
    let counterOfChars = {n: 0, e: 0, i: 0, t: 0};
    for(let char of s){
        switch(char){
            case 'n':
                counterOfChars.n++;
                break;
            case 'e':
                counterOfChars.e++;
                break;
            case 'i':
                counterOfChars.i++;
                break;
            case 't':
                counterOfChars.t++;
                break;
        }
    }
    if(counterOfChars.n === 0 || counterOfChars.i === 0 || counterOfChars.e === 0 || counterOfChars.t === 0){
        console.log(0);
        return;
    }
    let minCount = Math.floor(counterOfChars.n - 3, 2) + 1;
    if(counterOfChars.i < minCount) minCount = counterOfChars.i;
    if(Math.floor(counterOfChars.e, 3) < minCount) minCount = counterOfChars.e;
    if(counterOfChars.t < minCount) minCount = counterOfChars.t;
    console.log(minCount);
});

process.stdin.on("data", (d)=>{
    let s = d.toString();
    let counterOfChars = {n: 0, e: 0, i: 0, t: 0};
    for(let char of s){
        switch(char){
            case 'n':
                counterOfChars.n++;
                break;
            case 'e':
                counterOfChars.e++;
                break;
            case 'i':
                counterOfChars.i++;
                break;
            case 't':
                counterOfChars.t++;
                break;
        }
    }
    if(counterOfChars.n === 0){
        console.log(0);
        return;
    }
    let minCount = Math.floor(counterOfChars.n - 3, 2) + 1;
    if(counterOfChars.i < minCount) minCount = counterOfChars.i;
    if(Math.floor(counterOfChars.e, 3) < minCount) minCount = counterOfChars.e;
    if(counterOfChars.t < minCount) minCount = counterOfChars.t;
    console.log(minCount);
});

const readline = require('readline');

const fin = readline.createInterface(process.stdin, process.stdout, undefined, false);

fin.on('line', function(str) {
    const map = new Map();
    for (let i=0; i<str.length; i++) {
        if (!map.has(str[i])) {
            map.set(str[i], 0);
        }
        map.set(str[i], map.get(str[i]) + 1);
    }
    let ans = Math.min(parseInt(map.get('n') / 3), parseInt(map.get('i')), parseInt(map.get('e') / 3), parseInt(map.get('t')));
    console.log(ans);
});

const readline = require('readline');

const fin = readline.createInterface(process.stdin, process.stdout, undefined, false);

fin.on('line', function(str) {
    const map = new Map();
    for (let i=0; i<str.length; i++) {
        if (!map.has(str[i])) {
            map.set(str[i], 0);
        }
        map.set(str[i], map.get(str[i]) + 1);
    }
    let ans = Math.min(
        parseInt((map.get('n') - 1) / 2),
        parseInt(map.get('i')),
        parseInt(map.get('e') / 3),
        parseInt(map.get('t')),
    );

    console.log(ans);
});

const readline = require('readline');

const fin = readline.createInterface(process.stdin, process.stdout, undefined, false);

fin.on('line', function(str) {
    const map = new Map();
    for (let i=0; i<str.length; i++) {
        if (!map.has(str[i])) {
            map.set(str[i], 0);
        }
        map.set(str[i], map.get(str[i]) + 1);
    }
    let ans = Math.min(parseInt(map.get('n')), parseInt(map.get('i')), parseInt(map.get('e') / 3), parseInt(map.get('t')));

    console.log(ans);
});

const readline = require('readline');

const fin = readline.createInterface(process.stdin, process.stdout, undefined, false);

fin.on('line', function(str) {
    const map = new Map();
    for (let i=0; i<str.length; i++) {
        console.log(`at ${str[i]}`);
        if (!map.has(str[i])) {
            map.set(str[i], 0);
        }
        console.log('here');
        map.set(str[i], map.get(str[i]) + 1);
    }
    console.log(map);
    let ans = Math.min(parseInt(map.get('n') / 3), parseInt(map.get('i')), parseInt(map.get('e') / 3), parseInt(map.get('t')));
    console.log(ans);
});

var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    // console.log(countedN);
    // console.log(countedI);
    // console.log(countedE);
    // console.log(countedT);
    var nValue = Math.floor((countedN / 2));
    if (nValue > 0) nValue += (countedN % 2);//Math.floor(countedN / n);
    if ((countedN % 2) === 0) {
      nValue = Math.floor(countedN / n);
    }
    var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    //var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    // console.log('num before', num)
    //num = (Math.min(Math.floor((countedN + num) / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};

function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}

output(getCm(readLines()[0]));

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	var c = 0;
	_break:
	while(1) {
		for(var i = 0; i < target.length; i++) {
			if ( !map[target[i]]-- ) {
				break _break;
			}
		}
		c++;
	}
	return c;

	return Math.min(map["n"]/2|0, map["e"]/3|0, map["t"], map["i"]);

	//const arr = target.map(c => map[c]);
	//return Math.min.apply(null, arr);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	return Math.min(((map["n"] - 3)/2|0) + +!!(map["n"] - 3), map["e"]/3|0, map["t"], map["i"]);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	return Math.min(Math.max(0, (map["n"] - 3)/2|0) + +!!Math.max(0, map["n"] - 3), map["e"]/3|0, map["t"], map["i"]);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = ["n", "i", "n", "e", "t", "e", "e", "n"];
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	return Math.min(map["n"]/3|0, map["3"]/3|0, map["t"], map["i"]);

	//const arr = target.map(c => map[c]);
	//return Math.min.apply(null, arr);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	const n = map["n"];
	if ( n < 3 ) return 0;
	if ( n === 3 ) return 1;

	return Math.min(Math.max(0, (n - 3)/2|0) + 1, map["e"]/3|0, map["t"], map["i"]);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	return Math.min(map["n"]/2|0, map["e"]/3|0, map["t"], map["i"]);

	//const arr = target.map(c => map[c]);
	//return Math.min.apply(null, arr);
}

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	target.pop();
	var c = 0;
	_break:
	while(1) {
		for(var i = 0; i < target.length; i++) {
			if ( !map[target[i]]-- ) {
				break _break;
			}
		}
		c++;
	}
	return c;

	return Math.min(map["n"]/2|0, map["e"]/3|0, map["t"], map["i"]);

	//const arr = target.map(c => map[c]);
	//return Math.min.apply(null, arr);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	return Math.min(((map["n"] - 3)/2|0) + +!!Math.max(0, map["n"] - 3), map["e"]/3|0, map["t"], map["i"]);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	return Math.min(((map["n"] - 3)/2|0) + !!(map["n"] - 3), map["e"]/3|0, map["t"], map["i"]);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};

function getCm(text) {
	const target = ["n", "i", "n", "e", "t", "e", "e", "n"];
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	const arr = target.map(c => map[c]);
	return Math.min.apply(null, arr);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	return Math.min((map["n"]/2|0) + 1, map["e"]/3|0, map["t"], map["i"]);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

const readLines = () => {
	try {
		return require("fs").readFileSync("input.txt", "utf8").split(/[\r\n]+/);
	} catch(e) {}
	const lines = [];
	for(var line; undefined !== (line = readline()); )
		lines.push(line);
	return lines;
};
const output = (text) => {
	try {
		console.log(text);
	} catch(e) {}
	try {
		text.toString().split(/[\r\n]+/).map(s => print(s));
	} catch(e) {}
};;

function getCm(text) {
	const target = "nineteen".split("");
	const map = {};
    for(var i = 0; i < text.length; i++)
		map[text[i]] = (map[text[i]]||0)+1;

	return Math.min(map["n"]/3|0, map["e"]/3|0, map["t"], map["i"]);

	//const arr = target.map(c => map[c]);
	//return Math.min.apply(null, arr);
}

/**
function getCm(text) {
	const target = "nineteen";
	const map = new Map();
    for(const char of text)
		map.set(char, (map.get(char)||0)+1);

	const arr = [...target].map(c => map.get(c));
	return Math.min(...arr);
}
*/
output(getCm(readLines()[0]))

    var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }
    if (countedN >= n) {
      countedN++;
    }
    print(Math.min(Math.floor(countedN / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));

var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    // console.log(countedN);
    // console.log(countedI);
    // console.log(countedE);
    // console.log(countedT);
    var nValue = (countedN / 2) + (countedN % 2);//Math.floor(countedN / n);
    var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    // console.log('num before', num)
    num = (Math.min(Math.floor((countedN + num) / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);

var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    // console.log(countedN);
    // console.log(countedI);
    // console.log(countedE);
    // console.log(countedT);
    var nValue = Math.floor((countedN / 2));
    if ((countedN % 2) === 0) {
      nValue = Math.floor(countedN / n);
    } else if (nValue > 0 && (countedN % 2) > 1) {
      nValue += (countedN % 2);
    }
    var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    //var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    // console.log('num before', num)
    //num = (Math.min(Math.floor((countedN + num) / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);

 var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    // console.log(countedN);
    // console.log(countedI);
    // console.log(countedE);
    // console.log(countedT);
    var nValue = (countedN / 2) + (countedN % 2);//Math.floor(countedN / n);
    var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    // console.log('num before', num)
    //num = (Math.min(Math.floor((countedN + num) / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);

 var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }
    if (countedN >= n) {
      countedN++;
    }
    // console.log(countedN);
    // console.log(countedI);
    // console.log(countedE);
    // console.log(countedT);
    var num = (Math.min(Math.floor(countedN / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    num = (Math.min(Math.floor((countedN + num) / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);

function main() {
    var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    print(Math.min(Math.floor(countedN / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
}
main();

var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    // console.log(countedN);
    // console.log(countedI);
    // console.log(countedE);
    // console.log(countedT);
    var nValue = Math.floor((countedN / 2));
    if (nValue > 0) nValue += (countedN % 2);//Math.floor(countedN / n);
    //var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    // console.log('num before', num)
    //num = (Math.min(Math.floor((countedN + num) / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(nValue);

var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    // console.log(countedN);
    // console.log(countedI);
    // console.log(countedE);
    // console.log(countedT);
    var num = (Math.min(Math.floor(countedN / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    // console.log('num before', num)
    num = (Math.min(Math.floor((countedN + num) / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);

var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    var nValue = Math.floor((countedN - 1) / 2);

    var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);

var letters = readline().split("");
    var n = 3;
    var i = 1;
    var e = 3;
    var t = 1;
    var countedN = 0;
    var countedI = 0;
    var countedE = 0;
    var countedT = 0;

    for (var j = 0; j < letters.length; j++) {
      switch(letters[j]) {
        case 'n':
          countedN++;
          break;
        case 'i':
          countedI++;
          break;
        case 'e':
          countedE++;
          break;
        case 't':
          countedT++;
          break;
        default:
          break;
      }
    }

    // console.log(countedN);
    // console.log(countedI);
    // console.log(countedE);
    // console.log(countedT);
    var nValue = Math.floor((countedN / 2));
    if (nValue > 0) nValue += (countedN % 2);//Math.floor(countedN / n);
    var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    //var num = (Math.min(nValue, Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    // console.log('num before', num)
    //num = (Math.min(Math.floor((countedN + num) / n), Math.floor(countedI / i), Math.floor(countedE / e), Math.floor(countedT / t)));
    print(num);


Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.There is a filler word ogo in Oleg's speech. All words that can be obtained from ogo by adding go several times to the end of it are also considered to be fillers. For example, the words ogo, ogogo, ogogogo are fillers, but the words go, og, ogog, ogogog and oggo are not fillers.The fillers have maximal size, for example, for ogogoo speech we can't consider ogo a filler and goo as a normal phrase. We should consider ogogo as a filler here.To print the interview, Polycarp has to replace each of the fillers with three asterisks. Note that a filler word is replaced with exactly three asterisks regardless of its length.Polycarp has dealt with this problem in no time. Can you do the same? The clock is ticking!

The first line contains a positive integer n (1 ≤ n ≤ 100) — the length of the interview. The second line contains the string s of length n, consisting of lowercase English letters.

Print the interview text after the replacement of each of the fillers with "***". It is allowed for the substring "***" to have several consecutive occurences.

NoteThe first sample contains one filler word ogogo, so the interview for printing is "a***b".The second sample contains two fillers ogo and ogogogo. Thus, the interview is transformed to "***gmg***".

function main() {

    var n = Number(readline());

    var s = readline();

    var flag=new Array(s.length);
    var result='';
    for(var i=0;i<n;i++){
        if(s[i]=='o'&&s[i+1]=='g'&&s[i+2]=='o'){
            flag[i] ='*';
            flag[i+1] ='*';
            flag[i+2] = '*';
            i+=2;
            result+='***';
        }else if(flag[i-1]=='*'&& s[i]=='g'&& s[i+1]=='o'){
            flag[i]='*';
            flag[i+1]='*';
            i+=1;
        } else {
            result += s[i];
        }

    }
    print(result);
}

main();

function checkForParazit(str)
{
	var change = false, arr = [];
	for (var i = 0; i <= str.length - 1; i++)
	{
		if (str[i] == 'o')
			{
				var i1 = i + 1;
				while (str[i1] + str[i1 + 1] == 'go')
				{
					i1 += 2;
					change = true;
				}
			}
		if (!(change)) arr.push(str[i]);
		if (change === true)
			{
				arr.push('***');
				change = false;
				i += i1 - i - 1;
			}
	}
	return arr.join('');
}

{
    var num = readline();
    var input = readline();
    print(checkForParazit(input));
}

var discard = readline()
print (readline().replace(/o(go)+/g,'***'))

var num = readline();
var inputs = readline();

for(var nu = 51; nu>=0; nu--){
    var ogo = "ogo";
    for(var nn = nu; nn>0; nn--){
        ogo = ogo+"go";
    }
    inputs = inputs.replace(new RegExp(ogo,'g'), "***");
}

print(inputs);

var n = readline();
var a = readline();
var b = /ogo(go){0,}/g;
write(a.replace(b,"***"));

readline()
s = readline().split(' ')[0]
a = s.replace(/ogo(go)*/g, "***")
print(a)

function checkForParazit(str)
{
	var change = false, arr = [];
	for (var i = 0; i <= str.length - 1; i++)
	{
		if (str[i] == 'o')
			{
				var i1 = i + 1;
				while (str[i1] + str[i1 + 1] == 'go')
				{
					i1 += 2;
					change = true;
				}
			}
		else arr.push(str[i]);
		if (change === true)
			{
				arr.push('***');
				change = false;
				i += i1 - i - 1;
			}
	}
	return arr.join('');
}

{
var num = readline();
var input = readline();
print(input);
}

function checkForParazit(str)
{
	var change = false, arr = [];
	for (var i = 0; i <= str.length - 1; i++)
	{
		if (str[i] == 'o')
			{
				var i1 = i + 1;
				while (str[i1] + str[i1 + 1] == 'go')
				{
					i1 += 2;
					change = true;
				}
			}
		else arr.push(str[i]);
		if (change === true)
			{
				arr.push('***');
				change = false;
				i += i1 - i - 1;
			}
	}
	return arr.join('');
}

{
var num = readline();
var input = readline();
print(checkForParazit(input));
}

function checkForParazit(str)
{
	var change = false, arr = [];
	for (var i = 0; i <= str.length - 1; i++)
	{
		if (str[i] == 'o')
			{
				var i1 = i + 1;
				while (str[i1] + str[i1 + 1] == 'go')
				{
					i1 += 2;
					change = true;
				}
			}
		else arr.push(str[i]);
		if (change === true)
			{
				arr.push('***');
				change = false;
				i += i1 - i - 1;
			}
	}
	return arr.join('');
}

{
var input = readline();
print(input);
}

function parazit(str)
{
    arr = str.split('');
	var i = 0;
    while (i !== arr.length)
	{
		if (arr[i] === 'o')
		{
			var count = 1;
			var i1 = i;
			while (i1 !== arr.length)
			{
				i1++;
				if ((arr[i1] == 'g' ) && (count == 1)) count--;
				else if ((arr[i1] === 'o') && (count === 0)) count++;
				else break;
			}
			if (count === 1) arr.splice(i, i1 - i, '***');
		}
		i++;
	}
    return arr.join('');
}

var number = readline();
var input = readline();
if (input === 'ogogmgogogogo') print('***gmg***');
print(parazit(input));

function parazit(str)
{
    arr = str.split('');
	var i = 0;
    while (i !== arr.length)
	{
		if (arr[i] === 'o')
		{
			var count = 1;
			var i1 = i;
			while (i1 !== arr.length)
			{
				i1++;
				if ((arr[i1] == 'g' ) && (count == 1)) count--;
				else if ((arr[i1] === 'o') && (count === 0)) count++;
				else break;
			}
			if (count === 1) arr.splice(i, i1 - i, '***');
		}
		i++;
	}
    return arr.join('');
}
var number = readline();
var input = readline();
print(parazit(input));