import java.io.*; class Process { private String S; Process(String S) { this.S = S; } int getResult() { // S に含まれる 't', 'r', 'e' それぞれの個数 int[] charCounts = new int[3]; for(int i = 0; i < S.length(); i++) { switch(S.charAt(i)) { case 't': charCounts[0]++; break; case 'r': charCounts[1]++; break; case 'e': charCounts[2]++; break; } } int count = 0; while((charCounts[0] > 0) && (charCounts[1] > 0) && (charCounts[2] > 1)) { count++; charCounts[0]--; charCounts[1]--; charCounts[2] -= 2; } return count; } } public class Main { public static void main(String[] args) throws IOException { var bufferedReader = new BufferedReader(new InputStreamReader(System.in)); var printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); // 入力 String S = bufferedReader.readLine().trim(); // 処理および出力 printWriter.println((new Process(S)).getResult()); bufferedReader.close(); printWriter.close(); } }