import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class No0279 { public static void main(String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { char[] arr = br.readLine().toCharArray(); Map m = new HashMap<>(); Arrays.sort(arr); for (char c : arr) { if (isLetter(c)) { if (m.containsKey(c)) { int cnt = m.get(c); m.put(c, ++cnt); } else { m.put(c, 1); } } } System.out.println(m); int t_cnt = m.get('t'); int r_cnt = m.get('r'); int e_cnt = m.get('e'); int tree_cnt = 0; if (isOverZero(t_cnt, r_cnt, e_cnt)) { // t r 小さいほうと比べてeが何個分とれる? if (t_cnt >= r_cnt) { tree_cnt += (e_cnt / (r_cnt * 2) * r_cnt); } else { tree_cnt += (e_cnt / (t_cnt * 2) * t_cnt); } } System.out.println(tree_cnt); } catch (IOException e) { e.printStackTrace(); } } static boolean isLetter(char c){ return (c == 't' || c == 'r' || c == 'e'); } static boolean isOverZero(int t_cnt, int r_cnt, int e_cnt){ return t_cnt > 0 && r_cnt > 0 && e_cnt > 0; } }