

Input

The input contains two integers N, M (1 ≤ N ≤ 1024, 2 ≤ M ≤ 16), separated by a single space.

Output

Output "YES" or "NO".

Examples

Input


2 3


Output


YES


Input


3 2


Output


NO


Input


33 16


Output


YES


Input


26 5


Output


NO
import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;

public class xenodrome {

	public static void main(String[] args)throws IOException {
	
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String arr[]=br.readLine().split(" ");
		
		int n=Integer.parseInt(arr[0]);
		int m=Integer.parseInt(arr[1]);
		
		ArrayList<Integer> li=new ArrayList<>();
		
		while(n>0)
		{
			li.add(n%m);
			
			n=n/m;
		}
      
		
		HashSet<Integer> set=new HashSet<>();
		
		for(int i=0;i<li.size();i++)
		{
			set.add(li.get(i));
		}
		
		if(li.size()==set.size())
			System.out.println("YES");
		else
			System.out.println("NO");
	}

}
