#include using namespace std; int main() { long n, m; cin >> n >> m; long prev = 0, current = 1; for (long i = 2; i <= n; i++) { long w = (current + prev) % m; prev = current; current = w; } cout << current << endl; }