eolymp
bolt
Try our new interface for solving problems
Problems

Indivisibility of binomial coefficients

Indivisibility of binomial coefficients

\includegraphics{https://static.e-olymp.com/content/ac/ac1d6b9e5c2e474fc77e1b3547f16abf288cb49c.jpg} Let us denote , where \textbf{0} ≤ \textbf{i} ≤ \textbf{n} and \textbf{n}, \textbf{i} are integer numbers. Given a natural number \textbf{n} and a prime number \textbf{p}. You are required to find numbers of integers \textbf{i} from \{\textbf{0}, \textbf{1}, ..., \textbf{n}\} such that \textbf{C^i_n} is not divisible by \textbf{p}. \InputFile The only line of the input file consists of a natural number \textbf{n} ≤ \textbf{10^18} and a prime number \textbf{p} < \textbf{10^18}. \OutputFile In the output file you should write the answer of the task.
Time limit 0.5 seconds
Memory limit 64 MiB
Input example #1
4 2
Output example #1
2
Author А.Лунев
Source Зимние сборы в Харькове 2010 День 1