import heapq def main(): N = int(input().strip()) heap = [] # Generate all possible (a, b) pairs where a < b for a in range(1, 10): for b in range(a + 1, 10): s = f"{a}{b}" # Push the tuple (length, string, a, b, c) heapq.heappush(heap, (len(s), s, a, b, 0)) count = 0 result = "" while heap: current = heapq.heappop(heap) length, s, a, b, c = current count += 1 if count == N: result = s break # Generate the next number by appending b new_s = s + str(b) new_length = length + 1 heapq.heappush(heap, (new_length, new_s, a, b, c + 1)) print(result) if __name__ == "__main__": main()