import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); public static void main(String[] args){ int n = in.nextInt(), m = in.nextInt(); System.out.println(f(n) % m); } public static int f(int n){ if(n == 1) return 0; if(n == 2) return 1; else return f(n - 1) + f(n - 2); } }