import java.util.*; public class Main { public static void main (String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int preprev = 0; int prev = 1; for (int i = 3; i <= n; i++) { int value = preprev + prev; value %= m; preprev = prev; prev = value; } System.out.println(prev); } }