#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ZERO 48
#define A 65
#define SIZE 100
int main()
{
/* Declare variables */
int DECIMAL;
int BASE;
char ans[SIZE];
int remainder;
int idx;
int i;
/* Initiallize variables */
memset(ans, '\0', SIZE);
idx = 0;
/* Get input */
scanf("%d", &DECIMAL);
scanf("%d", &BASE);
while (DECIMAL > 0)
{
remainder = (DECIMAL % BASE);
if (remainder < 10)
{
remainder += ZERO;
}
else{
remainder += A - 10;
}
ans[idx] = (char)remainder;
idx++;
DECIMAL = DECIMAL / BASE;
}
for (i = 0; i < idx; i++)
{
printf("%c",ans[idx - i - 1]);
}
printf("\n");
}