

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.*;
public class Mango {
	
	public static void main(String[] args) throws Exception {
	Scanner sc = new Scanner(System.in);
	long x = sc.nextLong();
	long y = sc.nextLong();
	boolean f= true;
	HashSet<Long> h = new HashSet<Long>();
	while(x>0) {
		long z = x%y;
		if(h.contains(z)) {
			f = false;
			break;
		}
		h.add(z);
		x = x/y;
	}
	if(f) {
		System.out.println("YES");
	}
	else {
		System.out.println("NO");
	}
	}
}
