N = int(input()) while N % 6 and N > 6 == 0: N //= 6 if N != 6: print('No') else: print('Yes')