#если основание до 10 n = int(input()) x = '' while n != 0: x = str(n % 3) + x n //= 3 print(x) #если больше 10 n = int(input()) x = '' while n != 0: if n % 13 > 10: x = 'ABC'[n % 13 - 10] + x else: x = str(n % 13) + x n //= 13 print(x)