

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
//https://codeforces.com/contest/1505/problem/D
//D. Xenolith? Hippodrome?
import java.util.*;
import java.io.*;
public class CF_1505_D{

	static boolean check(int n, int m){
		boolean pres[] = new boolean[m];

		while(n>0){
			int temp = n%m;

			if(pres[temp])
				return false;
			else
				pres[temp] = true;

			n = n/m;
		}
		return true;
	}

	public static void main(String[] args) throws Exception{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		StringTokenizer st;

		st = new StringTokenizer(br.readLine().trim());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());

		boolean flag = check(n, m);

		if(flag)
			pw.print("YES");
		else
			pw.print("NO");

		pw.flush();
		pw.close();
	}
}