package yukicoder; import java.math.BigInteger; import java.util.Scanner; public class No526 { private int n; private BigInteger m; private BigInteger[] fibonacci; public static void main(String[] args) { No526 main = new No526(); main.run(); } private void run() { Scanner sc = new Scanner(System.in); n = sc.nextInt(); m = new BigInteger(sc.next()); fibonacci = new BigInteger[n + 2]; fibonacci[1] = new BigInteger("0"); fibonacci[2] = new BigInteger("1"); for(int i = 3; i < n + 1; i++) { fibonacci[i] = fibonacci[i - 1].add(fibonacci[i - 2]); } System.out.println(fibonacci[n].mod(m)); } }