import heapq def main(): N = int(input()) heap = [] # Generate all possible (a, b) pairs with a < b and push their initial values into the heap for a in range(1, 10): for b in range(a + 1, 10): initial_num = str(10 * a + b) num_tuple = (len(initial_num),) + tuple(map(int, initial_num)) heapq.heappush(heap, (num_tuple, a, b, 0)) current_count = 0 result = "" while heap: num_tuple, a, b, c = heapq.heappop(heap) current_count += 1 if current_count == N: # Convert the tuple back to the string representation result = ''.join(map(str, num_tuple[1:])) break # Generate the next number by appending b to the current number new_num_str = ''.join(map(str, num_tuple[1:])) + str(b) new_num_tuple = (len(new_num_str),) + tuple(map(int, new_num_str)) heapq.heappush(heap, (new_num_tuple, a, b, c + 1)) print(result) if __name__ == "__main__": main()