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(); long[] f = new long[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]); } }