import java.util.Scanner; public class No526 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); System.out.println(fibonacci(N) % M); } public static int fibonacci(int N) { if(N == 1) { return 0; }else if(N == 2) { return 1; }else { return fibonacci(N -1) + fibonacci(N -2); } } }