#include using namespace std; int main() { int N, M; cin >> N >> M; int F1 = 0; int F2 = 1; /* if( N == 0 ) { cout << F0 << endl; return 0; } if( N == 1 ) { cout << F1 << endl; return 0; } */ int tmp; for( int i = 1; i < N ; i++ ) { tmp = F1; F1 = F2; F2 = tmp + F1; F1 = F1%M; F2 = F2%M; } cout << F1 << endl; return 0; }