N, K = map(int, input().split())
a, b = zip(*(map(int, input().split()) for _ in range(N)))

ans = 10**10
for ai in a:
    for bi in b:
        if ai + bi >= K:
            ans = min(ans, ai + bi)

print(ans)
