public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
long num = sc.nextLong();
int k = sc.nextInt();
System.out.println(transfer(num, k));
}
}
public static String transfer(long num, int k) {
if (num == 0) return "0";
StringBuilder sb = new StringBuilder();
while (num != 0) {
sb.append(num % k);
num /= k;
}
return sb.reverse().toString();
}
} import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long num = sc.nextLong();
long j = sc.nextInt();
long z, y;
ArrayList<Long> res = new ArrayList<>();
if(num == 0){
System.out.println(0);
}else{
while(num != 0){
z = num/j;
y = num%j;
res.add(y);
num = z;
}
Collections.reverse(res);
}
for (long n: res) {
System.out.print(n);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long x = scanner.nextLong();
long k = scanner.nextLong();
System.out.println(radix(x, k));
}
private static String radix(long x, long k) {
StringBuilder sb = new StringBuilder();
if (x == 0) {
sb.append(0);
}
while (x != 0) {
sb.append(x % k);
x /= k;
}
return sb.reverse().toString();
}
}