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).
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Solution 
{
    static class InputReader 
    {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;

        public InputReader(InputStream st) {
            this.stream = st;
        }

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    static long modInverse(long a,long m) 
    { 
        long m0 = m; 
        long y = 0, x = 1; 
  
        if (m == 1) 
            return 0; 
  
        while (a > 1) 
        { 
            long q = a / m; 
            long t = m; 
            m = a % m; 
            a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        } 
  
        if (x < 0) 
            x += m0; 
  
        return x; 
    }
    public static long power(long a,long b,long mod)
    {
        if(b==0)
            return 1;
        else if(b==1)
            return a;
        else
        {
            if(b%2==1)
            {
                long p=power(a,b/2,mod);
                return((p*p*a)%mod);
            }
            else
            {
                long p1=power(a,b/2,mod);
                return((p1*p1)%mod);
            }
        }
    }
    static class node
    {
        int v;
        ArrayList<node> ar;
        node(int a1)
        {
            v=a1;
            ar=new ArrayList<node>();
        }
    }
    public static long mod=998244353;
    static class pair implements Comparable<pair>
    {
        int x,y,ix;
        pair(int a1,int a2,int a3)
        {
            x=a1;
            y=a2;
            ix=a3;
        }
        public int compareTo(pair p1)
        {
            return(((this.y-this.x)-(p1.y-p1.x)));
        }
    }
    public static void main(String[] args) throws IOException 
    {
        //w.println("h ");
        InputReader in=new InputReader(System.in);
        PrintWriter w=new PrintWriter(System.out);
        long n=in.nextLong();
        long b=in.nextLong();
        //w.println("Hi");
        //prime=new boolean[]
        ArrayList<Long> al=new ArrayList<Long>();
        HashMap<Long,Long> map=new HashMap<Long,Long>();
        long temp=b;
        for(long i=2;i*i<=b;i++)
        {
            if(temp%i==0)
            {
                al.add(i);
                long j=0;
                while(temp%i==0 && temp>=i)
                {
                    j++;
                    temp/=i;
                }
                map.put(i,j);
               //w.println(i+" "+j);
            }
        }
        //while()
        al.add(temp);
        map.put(temp,1L);
        long ans=Long.MAX_VALUE;
        for(int i=0;i<al.size();i++)
        {
            long p=al.get(i);
            if(p==1)
            {
                continue;
            }
            long tp=n;
            long cnt=0;
            while(tp>=p)
            {
                cnt+=tp/p;
                tp/=p;
            }
            //w.println(p+" "+cnt);
            ans=(long)Math.min(ans,cnt/map.get(p));
        }
        w.println(ans);
        w.close();
    }
}
