import heapq n = int(input()) heap = [] # Generate all possible (a, b) pairs and their initial numbers for a in range(1, 10): for b in range(a + 1, 10): num_str = f"{a}{b}" heapq.heappush(heap, (len(num_str), num_str, a, b)) current = None for _ in range(n): current = heapq.heappop(heap) length, num_str, a, b = current next_num_str = num_str + str(b) heapq.heappush(heap, (len(next_num_str), next_num_str, a, b)) print(current[1])