using System; class Program { static void Main(string[] args) { //入力 ulong N = ulong.Parse(Console.ReadLine()); //各係数に対する配列を用意する ulong[] an = new ulong[N]; ulong[] bn = new ulong[N]; ulong[] cn = new ulong[N]; an[0] = 1; an[1] = 0; an[2] = 0; bn[0] = 0; bn[1] = 1; bn[2] = 0; cn[0] = 0; cn[1] = 0; cn[2] = 1; for (ulong i = 3; i < N; i++) { an[i] = an[i - 3] + an[i - 2]; bn[i] = bn[i - 3] + bn[i - 2]; cn[i] = cn[i - 3] + cn[i - 2]; } //出力 switch (N) { case 1: Console.WriteLine("1"); break; case 2: Console.WriteLine("2"); break; case 3: Console.WriteLine("2"); break; default: Console.WriteLine((an[N - 1] + 2 * bn[N - 1] + 2 * cn[N - 1]) % (Math.Pow(10, 9) + 1)); break; } } }