import heapq n = int(input()) heap = [] # Generate all a and b pairs where a < b for a in range(1, 10): for b in range(a + 1, 10): initial = str(a) + str(b) heapq.heappush(heap, (2, initial, a, b, 1)) count = 0 result = "" while heap: length, current, a, b, k = heapq.heappop(heap) count += 1 if count == n: result = current break # Generate next number by appending b next_str = current + str(b) next_length = length + 1 heapq.heappush(heap, (next_length, next_str, a, b, k + 1)) print(result)