#include #include #include #include using namespace std; typedef long long ll; ll i,n,a,b,c,ans; vector vec; int main(){ cin >> n >> ans; a = 0; b = 1; c = 0; for(i = 0;i < n;i++){ a = b; b = c; c = a + b; if(i == 0){ a = 0; b = 1; c = 0; } } for(i = 0;i < c;i++){ if(c % ans == i){ cout << i << endl; break; } } return 0; }