using System; using System.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Text; public class Program { public void Proc() { Reader.IsDebug = false; int div = int.Parse(Reader.ReadLine()); int mul = (int)((2017L*2017)%div); int tmp = 1; for(int i=1; i<=2017; i++) { tmp = tmp * mul; tmp = tmp % div; } tmp += 2017; tmp = tmp % div; Console.WriteLine(tmp); } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 1 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }