using System; using System.Collections.Generic; using System.Linq; namespace yukicode { public class Program { static List Fibonatch = new List(); public static void MakeFibonatchSequence(int n) { if (Fibonatch.Count == 0) Fibonatch.Add( 0 ); if (Fibonatch.Count == 1) Fibonatch.Add( 1 ); if (n < 2) return; for (var i = 2; i <= n; ++i) { if (Fibonatch.Count == i) { Fibonatch.Add( Fibonatch[ i - 1 ] + Fibonatch[ i - 2 ] ); } } } public static UInt64 Solver(System.IO.TextReader reader) { var n = reader.ReadLine().Split().ToList().ConvertAll( int.Parse ); MakeFibonatchSequence( n[ 0 ] - 1 ); return Fibonatch[ n[ 0 ] - 1 ] % (UInt64)n[ 1 ]; } private static void Main() { Console.WriteLine( Solver( Console.In ) ); } } }