using System; using System.Linq; class Program { static void Main(string[] args) { int treeCount = 0; var line = Console.ReadLine().ToCharArray().OrderBy(x => x == 't').ThenBy(x => x == 'r').ThenBy(x => x == 'e').ToArray(); Array.Reverse(line); int tCnt = line.Count(x => x == 't'); int rCnt = line.Count(x => x == 'r'); int eCnt = line.Count(x => x == 'e'); if ( tCnt == 0 || rCnt == 0 || eCnt < 2) { Console.WriteLine(treeCount); return; } int treeCnt = 0; while (tCnt >= 1 && rCnt >= 1 && eCnt >= 2) { treeCnt++; tCnt--; rCnt--; eCnt -= 2; } Console.WriteLine(treeCnt); } }