#include <stdio.h>

int main(){
    int B, val, i=0;
    long int N;
    char res[31];

    scanf("%ld %d", &N, &B);

    while(N!=0){
        val = N%B;
        N/=B;
        if(val>9){
            res[i]='A'+val-10;
        }
        else{
            res[i]='0'+val;
        }
        i++;
    }

    while(i--){
        printf("%c",res[i]);
    }

    return 0;
}