#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll p;
struct Matrix {
ll a[3][3];
Matrix() {
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
a[i][j] = 0;
}
Matrix operator*(const Matrix& other) const {
Matrix res;
for (int i = 0; i < 3; ++i)
for (int k = 0; k < 3; ++k)
if (a[i][k])
for (int j = 0; j < 3; ++j)
res.a[i][j] = (res.a[i][j] + a[i][k] * other.a[k][j]) % p;
return res;
}
};
Matrix mat_pow(Matrix base, ll exp) {
Matrix res;
for (int i = 0; i < 3; ++i) res.a[i][i] = 1;
while (exp) {
if (exp & 1) res = res * base;
base = base * base;
exp >>= 1;
}
return res;
}
int main() {
ll n, k;
cin >> n >> k >> p;
if (n == 1 || n == 2) {
cout << 1 % p << endl;
return 0;
}
}