import heapq n = int(input()) # Generate all valid (a, b) pairs where a < b pairs = [] for a in range(1, 10): for b in range(a + 1, 10): pairs.append((a, b)) # Initialize the heap with the initial length of 2 for each pair heap = [] for a, b in pairs: heapq.heappush(heap, (2, a, b)) # Process the first (n-1) elements for _ in range(n - 1): length, a, b = heapq.heappop(heap) heapq.heappush(heap, (length + 1, a, b)) # The nth element is now the smallest in the heap length, a, b = heapq.heappop(heap) # Generate the resulting number as a string result = str(a) + str(b) + (length - 2) * str(b) print(result)