S = input() S = list(S) t = S.count("t") r = S.count("r") e = S.count("e") tree = 0 while t != 0: t = t-1 if r >= 1 and e >= 2: tree += 1 r = r-1 e = e-2 print(tree)