#include int main(){ long long int N, M, tmp, i; long long int num[3]; scanf("%lld %lld", &N, &M); num[0] = 0; num[1] = 1; for(i = 2; i < N; i++){ num[2] = (num[1] + num[0])%M; //printf("%lld\n", num[2]); if(i != N - 1){ tmp = num[1]; num[1] = num[2]; num[0] = tmp; } } printf("%lld\n", num[2]); return 0; }