#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; #define debug(x) cerr << #x << " = " << (x) << endl; #define mod 1000000007 //1e9+7(prime number) #define INF 1000000000 //1e9 #define LLINF 2000000000000000000LL //2e18 #define SIZE 100010 ll fib[SIZE]; int main(){ int n,m; fib[1] = 0; fib[2] = 1; cin >> n >> m; for(int i=3;i<=n;i++){ fib[i] = (fib[i-1] + fib[i-2])%m; } cout << fib[n]%m << endl; return 0; }