first = input() split_first = first.split() A = int(split_first[0]) B = int(split_first[1]) new_str_list = list(str(B**A)) new_str = ''.join(reversed(new_str_list)) print(new_str)