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