import math import sys import heapq from typing import List, Tuple int1 = lambda x: int(x) - 1 input = lambda: sys.stdin.readline().rstrip('\n') ii = lambda: int(input()) vi = lambda: list(map(int, input().split())) vi1 = lambda: list(map(int1, input().split())) def dbg(*args, **kwargs): print(*(repr(arg) for arg in args), *(f'{k}: {repr(v)}' for k, v in kwargs.items()), sep='; ', file=sys.stderr, flush=True) def solve(x): z = 10 ** len(x) return z // math.gcd(z, int(x)) def main(): n, y, z = vi() clx = [] for _ in range(n): clx.append(tuple(vi())) clx.sort(key=lambda x: x[1], reverse=True) q = [] while clx and clx[-1][1] <= y: c, _, x = clx.pop() heapq.heappush(q, (-x, c)) ans = 0 while y < z and q: # print(y, z, q) mx, c = heapq.heappop(q) x = -mx nl = z if clx: nl = min(nl, clx[-1][1]) tu = -(-(nl - y) // x) zz = min(tu, c) ans += zz c -= zz y += zz * x if c != 0: heapq.heappush(q, (-x, c)) while clx and clx[-1][1] <= y: c, _, x = clx.pop() heapq.heappush(q, (-x, c)) if y >= z: return ans else: return -1 def _start(): if (ret := main()) is not None: print(*ret) if isinstance(ret, List) or isinstance(ret, Tuple) else print(ret) if __name__ == '__main__': _start()