using System; using System.Linq; public class Program { static void Main(string[] args) { var L = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList(); int N = L[0], M = L[1]; long a = 1, b = 0, t; for (int i = 0; i < N - 2; ++i) { t = a; a = (a + b) % M; b = t; } Console.WriteLine(a); } }