#include int main(void) { int n, m, i; long long f1 = 0LL, f2 = 1LL, fb; scanf("%d %d", &n, &m); for (i = 3; i <= n; i++) { fb = (f1 + f2) % m; f1 = f2; f2 = fb; } printf("%lld\n", fb); return 0; }