for _ inrange(n): a, b = map(int, input().split()) dist[a] = max(dist.get(a, a), b)
# import json # print(json.dumps(dist, indent=2))
end = 0 route = 0 now = 0 used = 0 while now <= end+1and now <=t: if now in dist: route = max(route, dist[now]) # print(f'{now=} {route=}') if now == end+1and end < route: end = route # print(f'{now=} {end=}') used += 1 # print(f'{now=} {used=}') now += 1