package jp.co.kokou.sample.no279; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { try (InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr)) { String line = br.readLine(); long tCount = charCount('t', line); long rCount = charCount('r', line); long eCount = charCount('e', line) / 2; long max = Math.min(Math.min(tCount, rCount), eCount); System.out.format("%d%n", max); } catch (IOException ex) { } } private static long charCount(char c, String seq) { return seq.chars().filter(i -> i == (int) c).count(); } }