// Задача "Награды"
// Шестая Интернет-олимпиада сезона 2009-2010, усложненный уровень
// Автор задачи: Рустам Ганеев, ganeev@rain.ifmo.ru
// Автор решения: Антон Ахи, akhi@rain.ifmo.ru

import java.io.*;
import java.util.*;
import java.math.*;

public class grants_aa {

	public static void main(String[] args) throws Throwable {
		new grants_aa().run();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(this.hashCode());

	void run() throws Throwable {
		Locale.setDefault(Locale.US);
		br = new BufferedReader(new FileReader(FNAME + ".in"));
		out = new PrintWriter(FNAME + ".out");
		solve();
		out.close();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	int inBounds(int x, int l, int r, String name) {
		myAssert(l <= x && x <= r, name + " not in bounds: " + x + " not in ["
				+ l + ".." + r + "]");
		return x;
	}

	String FNAME = "grants";

	private void solve() throws IOException {
		int n = inBounds(nextInt(), 1, 100000, "n");
		int k = inBounds(nextInt(), 1, n, "k");
		long m = inBounds(nextInt(), 1, 1000000000, "m");
		myAssert(BigInteger.valueOf(m).isProbablePrime(1000),
				"m is not prime!!! m = " + m);
		out.println(cnk(n - k + 1, k, m));
	}

	long inv(long x, long m) {
		return BigInteger.valueOf(x % m).modInverse(BigInteger.valueOf(m))
				.longValue();
	}

	long cnk(int n, int k, long m) {
		if (n < 0 || k > n) {
			return 0;
		}
		long ans = 1;
		long div = 0;
		long mul = 0;
		for (int i = n; i > n - k; i--) {
			int y = i;
			while (y % m == 0 && y > 0) {
				y /= m;
				mul++;
			}
			ans = (ans * y) % m;
			long x = i - n + k;
			while (x % m == 0 && x > 0) {
				div++;
				x /= m;
			}
			ans = (ans * inv(x, m)) % m;
		}
		if (mul > div) {
			return 0;
		}
		return ans % m;
	}

}
