The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis. 

Aki is fond of numbers, especially those with trailing zeros. For example, the number 9200 has two trailing zeros. Aki thinks the more trailing zero digits a number has, the prettier it is.

However, Aki believes, that the number of trailing zeros of a number is not static, but depends on the base (radix) it is represented in. Thus, he considers a few scenarios with some numbers and bases. And now, since the numbers he used become quite bizarre, he asks you to help him to calculate the beauty of these numbers.

Given two integers n and b (in decimal notation), your task is to calculate the number of trailing zero digits in the b-ary (in the base/radix of b) representation of n ! ([factorial](https://en.wikipedia.org/wiki/Factorial) of n). 

Input

The only line of the input contains two integers n and b (1 ≤ n ≤ 10^{18}, 2 ≤ b ≤ 10^{12}).

Output

Print an only integer — the number of trailing zero digits in the b-ary representation of n!

Examples

Input

6 9


Output

1


Input

38 11


Output

3


Input

5 2


Output

3


Input

5 10


Output

1

Note

In the first example, 6!_{(10)} = 720_{(10)} = 880_{(9)}.

In the third and fourth example, 5!_{(10)} = 120_{(10)} = 1111000_{(2)}.

The representation of the number x in the b-ary base is d_1, d_2, …, d_k if x = d_1 b^{k - 1} + d_2 b^{k - 2} + … + d_k b^0, where d_i are integers and 0 ≤ d_i ≤ b - 1. For example, the number 720 from the first example is represented as 880_{(9)} since 720 = 8 ⋅ 9^2 + 8 ⋅ 9 + 0 ⋅ 1.

You can read more about bases [here](https://en.wikipedia.org/wiki/Radix).
//package feb19;
import java.util.*;
import java.io.*;



public class TrailingZeroes {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		// 6 9 1
		Scanner scn=new Scanner(System.in);
		
		long n=scn.nextLong();
		long n1=n;
		long b=scn.nextLong();
		/*6!=720 is divisible by 9^1 so answer is 1*/
		
		/*Finding prime factors of b*/
		long min=Long.MAX_VALUE;
		int count=0;
		long b1=b;
		/*Long i is must not int i else TLE :)*/
		for(long i=2; i*i<=b;i++)
		{
			//System.out.println("I:"+i);
			n=n1;
		//	b=b1;
		//	System.out.println(i+","+b);
			if(b%i==0)
			{
				/*Now we need to find what power of i will make me closest to b*/
				int power=0;
				while(b%i==0)
				{
					b=b/i;
					power++;
				}
			//	System.out.println(b);
				/*What power of i will be in total 1*2*3*4*.... n */
				long powern=0;
				while(n!=0)
				{
					powern=powern+n/i;
					n=n/i;
				}
				long ans=powern/power;
				min=Math.min(min, ans);
				
				count=1;
				
			}
		}
		
		
		/*agar kisi bhi prime factor se completely divide nahi hua to*/
		if(b!=1)
		{
			long powern=0;
			
			while(n1!=0)
			{
		//		System.out.println(powern);
				powern=powern+n1/b;
				n1=n1/b;
			}
			if(powern<min)
			{
				min=powern;
			}
		}
		System.out.println(min);
		

	}
	/*public static class FS
	   {
	      StringTokenizer st;
	      BufferedReader br;
	      
	      FS(InputStream in) throws Exception
	      {
	         br = new BufferedReader(new InputStreamReader(in));
	         st = new StringTokenizer("");
	      }
	      
	      String next() throws Exception
	      {
	         if (st.hasMoreTokens())
	         {
	            return st.nextToken();
	         }
	         st = new StringTokenizer(br.readLine());
	         return next();
	      }
	      
	      int nextInt() throws Exception
	      {
	         return Integer.parseInt(next());
	      }
	      
	      long nextLong() throws Exception
	      {
	         return Long.parseLong(next());
	      }
	   }*/

}
