using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, k, m) = (c[0], c[1], c[2]); WriteLine(Divide(n, k, m)); } static long Divide(long n, long k, long m) { var dic = PDiv(m); var ans = long.MaxValue; foreach (var kv in dic) { ans = Math.Min(ans, Divs(n, kv.Key) - Divs(n - k, kv.Key) - Divs(k, kv.Key)); } return ans; } static long Divs(long n, long p) { if (n < 0) return 0; var prev = 1L; var ans = 0L; while (true) { var pc = prev * p; if (pc / p != prev) break; ans += n / pc; prev = pc; } return ans; } static Dictionary PDiv(long n) { var dic = new Dictionary(); var tmp = n; while (tmp % 2 == 0) { tmp /= 2; if (dic.ContainsKey(2)) ++dic[2]; else dic.Add(2, 1); } for (var p = 3L; p * p <= n; p += 2) { while (tmp % p == 0) { tmp /= p; if (dic.ContainsKey(p)) ++dic[p]; else dic.Add(p, 1); } if (tmp == 1) break; } if (tmp > 1) dic.Add(tmp, 1); return dic; } }