#include #include #include #include #include #include #define rep(i,n) for(int i = 0;i < n;i++) #define REP(i,n,k) for(int i = n;i < k;i++) #define P(p) cout << (p) << endl;//print typedef long long ll; using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n,m; cin >> n >> m; int now =0; int past =1; rep(i,n-1){ ll tmp=now; now = (now + past)%m; past = tmp; } P(now); }