package org.bwgl.Fibonacci;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
long n = sc.nextLong();
long m = sc.nextLong();
long p = sc.nextLong();
long num1 = test1(n);//递归求和
long num2 = test2(m);//求前m项
long x = (num1%num2)%p;
System.out.println(x);
}
}
public static long test1(long n) {//前n项和
if(n==1)
return 1;
else if(n==2)
return 2;
else if(n>2)
return test1(n-1)+test2(n);
return 0;
}
public static long test2(long n) {//求前m项
if(n==1||n==2) {
return 1;
}else {
return test2(n-1)+test2(n-2);
}
}
}