using C=System.Console;class X{static void Main(){C.Write((C.Read()%4+7)%9);}}