from heapq import * def main(): n, y, z = list(map(int, input().split())) Q = [list(map(int, input().split())) for _ in range(n)] + [[-1, z, -1]] Q.sort(key = lambda x: -x[1]) hq = [] ans = 0 while 1: while Q[-1][1] <= y: c, l, x = Q.pop() if c == -1: return ans heappush(hq, (-x, c)) if hq: x, c = heappop(hq) x = -x nc = (Q[-1][1] - y + x - 1) // x mc = min(c, nc) c -= mc y += mc * x ans += mc if c: heappush(hq, (-x, c)) else: break return -1 print(main())