let [n, b] = require("fs").readFileSync(0, "utf8").toString().split(' ').map(Number);
let res = [];
do {
    let val = n%b;
    if(val<10){
        res.push(String.fromCharCode('0'.charCodeAt()+val));
    }
    else{
        res.push(String.fromCharCode('A'.charCodeAt()+val-10));
    }
    n = Math.floor(n/b);
} while(n!==0)

console.log(res.reverse().join(''));