using System; using System.Linq; class No526 { static void Main() { var num = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); var before = 0; var current = 1; var after = (before+current)%num[1]; for (int i = 2; i < num[0]; ++i) { before = current; current = after; after = (before + current) % num[1]; } Console.WriteLine(after); } }