import java.util.*; import java.math.*; public class Main{ public static void main(String... args){ Scanner scan = new Scanner(System.in); String s = scan.next(); System.out.println(Calc(s)); } public static int Calc(String s){ int t = 0; int r = 0; int e = 0; for(int i = 0; i < s.length(); i++){ if(s.charAt(i) == 't'){ t++; }else if(s.charAt(i) == 'r'){ r++; }else if(s.charAt(i) == 'e'){ e++; } } if(t == 0 || r == 0 || e == 0)return 0; return (int)Math.min((int)Math.min(t,r),e/2); } }