import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int M = scan.nextInt(); scan.close(); int []F = new int[N]; F[0] = 0; F[1] = 1; for(int i = 2; i < N; i++) { F[i] = (F[i - 1] + F[i - 2]) % M; } System.out.println(F[N - 1]); } }