A=readline().split(' ').map(Number)
B=readline().split(' ').map(Number)
print(Math.max(0,B[0]*2+B[1]-A[0])+Math.max(0,B[1]+3*B[2]-A[1]))

var N = readline().split(' ');
var M = readline().split(' ');
var y = parseInt(N[0]) , b = parseInt(N[1]);
var x1 = 0 , x2 = 0 , num1 = 0 , num2 = 0;
var bally = parseInt(M[0]) , ballg = parseInt(M[1]) , ballb = parseInt(M[2]);

    x1 = 2 * bally + ballg;
    x2 = ballg + 3 * ballb;

    if(y < x1){
    	num1 = x1 - y;
    }
    if(b < x2){
    	num2 = x2 - b;
    }

    print(num1+num2);

var lineA = readline();
var lineB = readline();

var a = +lineA.split(' ')[0];
var b = +lineA.split(' ')[1];

var x = +lineB.split(' ')[0];
var y = +lineB.split(' ')[1];
var z = +lineB.split(' ')[2];

var da = 2 * x + y;
var db = 3 * z + y;

var resa = (da - a) >= 0 ? da - a : 0;
var resb = (db - b) >= 0 ? db - b : 0;

var res = resa + resb;

print(res);

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [yH, bH] = d.split(' ').map(Number);
    return;
  }

  const [y, g, b] = d.split(' ').map(Number);

  const yellow = y * 2 + g;
  const blue = b * 3 + g;
  const ans = Math.max(0, yellow - yH) + Math.max(0, blue - bH);

  console.log(ans);

  c++;
});

var line = readline().split(' ');
var a=parseInt(line[0]),b=parseInt(line[1]);
var line = readline().split(' ');
var a1=parseInt(line[0]),a2=parseInt(line[1]),a3=parseInt(line[2]);
var s1,s2,sum=0;
s1=a1*2+a2;
s2=a3*3+a2;

if(s1>a)
    sum+=(s1-a);
if(s2>b)
    sum+=(s2-b);
print(sum);

var have_crystals = String(readline()).split(" ");
var need_balls = String(readline()).split(" ");
var yellow_need = 2 * parseInt(need_balls[0]) + parseInt(need_balls[1]);
var blue_need = parseInt(need_balls[1]) + 3 * parseInt(need_balls[2]);
var result = 0;
if (parseInt(have_crystals[0]) < yellow_need) {
    result += yellow_need - parseInt(have_crystals[0]);
}
if (parseInt(have_crystals[1]) < blue_need) {
    result += blue_need - parseInt(have_crystals[1]);
}
print(result);

var arr = readline().split(' ').map(Number);
var A = arr[0];
var B = arr[1];
arr = readline().split(' ').map(Number);
var x = arr[0];
var y = arr[1];
var z = arr[2];

var yellow = 2*x + y;
var blue = y + 3*z;

var q = Math.max(yellow - A, 0)
var p = Math.max(blue - B, 0)

print(p + q);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
var needYellow = (2 * nado[0]) + nado[1];
var needBlue = nado[1] + (3 * nado[2]);
// print('Nado yellow: ' + needYellow + ', blue: '+ needBlue);
var offYellow = needYellow - curYellow > 0 ? needYellow - curYellow : 0;
var offBlue = needBlue - curBlue > 0 ? needBlue - curBlue : 0;

off = offYellow + offBlue;
print(off);

var lineA = readline();
var lineB = readline();

var a = +lineA.split(' ')[0];
var b = +lineA.split(' ')[1];

var x = +lineB.split(' ')[0];
var y = +lineB.split(' ')[1];
var z = +lineB.split(' ')[2];

var da = 2 * x + y;
var db = 3 * z + y;

var res = da - a + db - b;

print(res);

var lineA = readline();
var lineB = readline();

var a = +lineA.split(' ')[0];
var b = +lineA.split(' ')[1];

var x = +lineB.split(' ')[0];
var y = +lineB.split(' ')[1];
var z = +lineB.split(' ')[2];

var da = 2 * x + y;
var db = 3 * z + y;

var res = da - a + db - b;

print(res >= 0 ? res : 0);

var arr1 = readline().split(" ");
var arr2 = readline().split(" ");
var yellow = 2 * parseInt(arr2[0]) + parseInt(arr2[1]);
var blue = parseInt(arr2[1]) + 3 * parseInt(arr2[2]);
var result = (yellow - parseInt(arr1[0])) + (blue - parseInt(arr1[1]));
if (result < 0) {
    print(0);
} else {
    print(result);
}

var arr1 = readline().split(" ");
var arr2 = readline().split(" ");
var yellow = 2 * parseInt(arr2[0]) + parseInt(arr2[1]);
var blue = parseInt(arr2[1]) + 3 * parseInt(arr2[2]);
var result = (yellow - parseInt(arr1[0])) + (blue - parseInt(arr1[1]));
print(result);

var arr = readline().split(' ').map(Number);
var A = arr[0];
var B = arr[1];
arr = readline().split(' ').map(Number);
var x = arr[0];
var y = arr[1];
var z = arr[2];

// var requiredNumberOfCrystals = 2*x + 2*y + 3*z;

print(Math.max(2*x + 2*y + 3*z - A - B, 0));

var arr = readline().split(' ').map(Number);
var A = arr[0];
var B = arr[1];
arr = readline().split(' ').map(Number);
var x = arr[0];
var y = arr[1];
var z = arr[2];

// var requiredNumberOfCrystals = 2*x + 2*y + 3*z;

print(2*x + 2*y + 3*z - A - B);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
// make yellow
var doneYellow = 0;
if (nado[0] > 0) {
  var reqYellow = nado[0] * 2;
  if (reqYellow > curYellow) {
    var over = reqYellow - curYellow;
    off += over;
    var affordable = reqYellow - over;
    curYellow -= affordable;
    doneYellow += nado[0];
  } else {
    curYellow -= reqYellow;
    doneYellow += nado[0];
  }
}

// make green
var doneGreen = 0;
if (nado[1] > 0) {
  var _reqYellow = nado[1] * 1;
  var reqBlue = nado[1] * 1;
  var _affordable = 0;
  var aY = 0;
  var aB = 0;
  if (_reqYellow > curYellow) {
    var _over = _reqYellow - curYellow;
    off += _over;
    aY = curYellow;
  } else {
    aY = _reqYellow;
  }
  if (reqBlue > curBlue) {
    var _over2 = reqBlue - curBlue;
    off += _over2;
    aB = curBlue;
  } else {
    aB = reqBlue;
  }
  if (aY > aB) {
    _affordable = aB;
    var _over3 = aY - aB;
    off += _over3;
  } else if (aB > aY) {
    _affordable = aY;
    var _over4 = aB - aY;
    off += _over4;
  }
  curYellow -= _affordable;
  curBlue -= _affordable;
}
// make blue
var doneBlue = 0;
if (nado[2] > 0) {
  var _reqBlue = nado[2] * 3;
  if (_reqBlue > curBlue) {
    var over = _reqBlue - curBlue;
    off += over;
    var affordable = _reqBlue - over;
    curBlue -= affordable;
    doneBlue += nado[0];
  } else {
    curBlue -= _reqBlue;
    doneBlue += nado[0];
  }
}

print(off);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
// make yellow
var doneYellow = 0;
if (nado[0] > 0) {
  var reqYellow = nado[0] * 2;
  if (reqYellow > curYellow) {
    var over = reqYellow - curYellow;
    off += over;
    var affordable = reqYellow - over;
    curYellow -= affordable;
    doneYellow += nado[0];
  } else {
    curYellow -= reqYellow;
    doneYellow += nado[0];
  }
}

// make green
var doneGreen = 0;
if (nado[1] > 0) {
  var _reqYellow = nado[1] * 1;
  var reqBlue = nado[1] * 1;
  var _affordable = 0;
  var aY = 0;
  var aB = 0;
  if (_reqYellow > curYellow) {
    var _over = _reqYellow - curYellow;
    //off += _over;
    aY = curYellow;
  } else {
    aY = _reqYellow;
  }
  if (reqBlue > curBlue) {
    var _over2 = reqBlue - curBlue;
    //off += _over2;
    aB = curBlue;
  } else {
    aB = reqBlue;
  }
  if (aY > aB) {
    _affordable = aB;
    var _over3 = aY - aB;
    off += _over3;
  } else if (aB > aY) {
    _affordable = aY;
    var _over4 = aB - aY;
    off += _over4;
  } else {
    _affordable = aY;
  }

  curYellow -= _affordable;
  curBlue -= _affordable;
}

// make blue
var doneBlue = 0;
if (nado[2] > 0) {
  var _reqBlue = nado[2] * 3;
  if (_reqBlue > curBlue) {
    var over = _reqBlue - curBlue;
    off += over;
    var affordable = _reqBlue - over;
    curBlue -= affordable;
    doneBlue += nado[2];
  } else {
    curBlue -= _reqBlue;
    doneBlue += nado[2];
  }
}

print(off);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
// make yellow
var doneYellow = 0;
if (nado[0] > 0) {
  var reqYellow = nado[0] * 2;
  if (reqYellow > curYellow) {
    var over = reqYellow - curYellow;
    off += over;
    var affordable = reqYellow - over;
    curYellow -= affordable;
    doneYellow += nado[0];
  } else {
    curYellow -= reqYellow;
    doneYellow += nado[0];
  }
}

// make green
var doneGreen = 0;
if (nado[1] > 0) {
  var _reqYellow = nado[1] * 1;
  var reqBlue = nado[1] * 1;
  var _affordable = 0;
  var aY = 0;
  var aB = 0;
  if (_reqYellow > curYellow) {
    var _over = _reqYellow - curYellow;
    off += _over;
    aY = curYellow;
  } else {
    aY = _reqYellow;
  }
  if (reqBlue > curBlue) {
    var _over2 = reqBlue - curBlue;
    off += _over2;
    aB = curBlue;
  } else {
    aB = reqBlue;
  }
  if (aY > aB) {
    _affordable = aB;
    var _over3 = aY - aB;
    off += _over3;
  } else if (aB > aY) {
    _affordable = aY;
    var _over4 = aB - aY;
    off += _over4;
  } else {
    _affordable = aY;
  }

  curYellow -= _affordable;
  curBlue -= _affordable;
}
// make blue
var doneBlue = 0;
if (nado[2] > 0) {
  var _reqBlue = nado[2] * 3;
  if (_reqBlue > curBlue) {
    var over = _reqBlue - curBlue;
    off += over;
    var affordable = _reqBlue - over;
    curBlue -= affordable;
    doneBlue += nado[2];
  } else {
    curBlue -= _reqBlue;
    doneBlue += nado[2];
  }
}

print(off);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
// make yellow
var doneYellow = 0;
if (nado[0] > 0) {
  var reqYellow = nado[0] * 2;
  if (reqYellow > curYellow) {
    var over = reqYellow - curYellow;
    off += over;
    var affordable = reqYellow - over;
    curYellow -= affordable;
    doneYellow += nado[0];
  } else {
    curYellow -= reqYellow;
    doneYellow += nado[0];
  }
}
// make green
var doneGreen = 0;
if (nado[1] > 0) {
  var _reqYellow = nado[0] * 1;
  var reqBlue = nado[0] * 1;
  var _affordable = 0;
  var aY = 0;
  var aB = 0;
  if (_reqYellow > curYellow) {
    var _over = _reqYellow - curYellow;
    off += _over;
    aY = curYellow;
  } else {
    aY = curYellow;
  }
  if (reqBlue > curBlue) {
    var _over2 = reqBlue - curBlue;
    off += _over2;
    aB = curBlue;
  } else {
    aB = curBlue;
  }
  if (aY > aB) {
    _affordable = aB;
    var _over3 = aY - aB;
    off += _over3;
  } else if (aB > aY) {
    _affordable = aY;
    var _over4 = aB - aY;
    off += _over4;
  }
}
// make blue
var doneBlue = 0;
if (nado[2] > 0) {
  var _reqBlue = nado[0] * 3;
  if (_reqBlue > curBlue) {
    var over = _reqBlue - curBlue;
    off += over;
    var affordable = _reqBlue - over;
    curBlue -= affordable;
    doneBlue += nado[0];
  } else {
    curBlue -= _reqBlue;
    doneBlue += nado[0];
  }
}

print(off);


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();

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())

}

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 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());
}

;(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';

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();
}

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

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());
    }
}

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 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 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 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 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());
}

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 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 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())

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();

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 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()
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();

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);

// 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();

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

'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);

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());

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());

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());
}


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)

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;};

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++;
});


'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')
})()

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 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(''));
}

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');
}

'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')
})()


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);

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);
});

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));

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);

'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);
});

'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);