using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; string inpt = Reader.ReadLine(); StringBuilder inputNum = new StringBuilder(); while (inpt.Length > 0) { if (inpt.StartsWith("hamu")) { inputNum.Append("1"); inpt = inpt.Substring(4); } else { inputNum.Append("0"); inpt = inpt.Substring(3); } } string num = inputNum.ToString(); long val = Convert.ToInt64(num, 2); val *= 2; num = Convert.ToString(val, 2); StringBuilder ans = new StringBuilder(); num.ToList().ForEach(a => ans.Append(a == '1' ? "hamu" : "ham")); Console.WriteLine(ans.ToString()); } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" hamuhamhamu "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }