CodeEff/ECCO huggingface dataset:
# Original solution
import sys
from collections import deque
#import numpy as np
import math
#sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return list(map(str,sys.stdin.readline().rstrip().split()))
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return list(map(int,sys.stdin.readline().rstrip().split()))

def solve():
    exclude = set()
    prime = set()
    for i in range(2,int(math.sqrt(x))+1):
        if i in exclude:
            continue
        prime.add(i)
        j = i
        while j<=x+2*i:
            exclude.add(j)
            j += i
    current = x
    while True:
        for rep in prime:
            if current%rep==0:
                break
        else:
            print(current)
            return
        current += 1
    return

if __name__=='__main__':
    x = I()
    solve()

# Optimized solution
import sys
from collections import deque
#import numpy as np
import math
#sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return list(map(str,sys.stdin.readline().rstrip().split()))
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return list(map(int,sys.stdin.readline().rstrip().split()))

def solve():
    exclude = set()
    prime = set()
    for i in range(2,int(math.sqrt(x))+1):
        if i in exclude:
            continue
        prime.add(i)
        j = i
        while j<=math.sqrt(x):
            exclude.add(j)
            j += i
    current = x
    while True:
        for rep in prime:
            if current%rep==0:
                break
        else:
            print(current)
            return
        current += 1
    return

if __name__=='__main__':
    x = I()
    solve()
# Original solution
x = int(eval(input()))
while True:
    n = 0
    for i in range(2, x):
        if x % i == 0:
            n += 1
    if n != 0:
        x += 1
    else:
        break
print(x)

# Optimized solution
x = int(eval(input()))
while True:
    judge = False
    for i in range(2, x):
        if x % i == 0:
            judge = True
            break
    if judge:
        x += 1
    else:
        break
print(x)
# Original solution

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


def main():
    X = int(eval(input()))
    primes = get_sieve_of_eratosthenes(X*2)
    for p in primes:
        if X <= p:
            print(p)
            break


if __name__ == "__main__":
    main()


# Optimized solution

def is_prime(n):
    i = 2
    while(i**2 <= n):
        if n % i == 0:
            return False
        i += 1
    return True


def main():
    X = int(eval(input()))
    for x in range(X, 2*X):
        if is_prime(x):
            print(x)
            break


if __name__ == "__main__":
    main()
# Original solution
from collections import deque

X = int(eval(input()))
nums = deque([i for i in range(3, 10**5+10, 2)])

prime = 2
while prime < X:
    prime = nums.popleft()
    nums = deque([i for i in nums if i % prime != 0])
print(prime)

# Optimized solution
X = int(eval(input()))

def check(num):
    max_div = int(num**0.5)
    for div in range(2, max_div+1):
        if num % div == 0:
            return False
    else:
        return True

num = X
while True:
    if check(num):
        print(num)
        break
    
    num += 1
# Original solution
from bisect import bisect_left


def get_primes(n):
    prime = []
    limit = n ** 0.5
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


X = int(eval(input()))
primes = get_primes(10 ** 5 + 3)
print((primes[bisect_left(primes, X)]))


# Optimized solution
X = int(eval(input()))
while any(X % i == 0 for i in range(2, int(X ** 0.5) + 1)):
    X += 1
print(X)
# Original solution
def get_primes(x):
    if x < 2:
        return list()
    primes = [2]
    n = 3
    while n <= x:
        is_prime = True
        for p in primes:
            if n % p == 0:
                is_prime = False
                break
            if p**2 > n:
                break
        if is_prime:
            primes.append(n)
        n += 2
    return primes


def main():
    X = int(eval(input()))
    if X <= 1:
        print((2))
        exit(0)
    primes = get_primes(X)
    while True:
        is_prime = True
        for p in primes:
            if X % p == 0 and X > p:
                is_prime = False
                break
        if is_prime:
            break
        X += 1
    print(X)


if __name__ == '__main__':
    main()


# Optimized solution
def is_prime(x):
    if x <= 1:
        return False
    elif x == 2:
        return True
    else:
        n = 2
        while n**2 <= x:
            if x % n == 0:
                return False
            n += 1
        return True


def main():
    X = int(eval(input()))
    while True:
        if is_prime(X):
            print(X)
            break
        X += 1


if __name__ == '__main__':
    main()
# Original solution
X = int(eval(input()))
Y = 0
while Y == 0:
  Y = 1
  for i in range(2,X-1):
    Y = Y * (X % i)
  X += 1
print((X-1))

# Optimized solution
X = int(eval(input()))
Y = 0
while Y == 0:
  Y = 1
  for i in range(2,int(X*0.5+1)):
    Y = Y * (X % i)
  X += 1
print((X-1))
# Original solution
#%%
import math

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
l = callIsPrime(10**6)

x = int(eval(input()))
for i in range(len(l)):
    if l[i] >= x:
        print((l[i]))
        break

# %%


# Optimized solution

#%%
import math

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=(10**5) * 2):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
l = callIsPrime((10**5) * 2)
#print(l)

x = int(eval(input()))
for i in range(len(l)):
    if l[i] >= x:
        print((l[i]))
        break

# %%
# Original solution
def is_prime(a):
    if a == 2:
        return True
    for i in range(2, int(a**0.5)+2):
        if a%i == 0:
            return False
    return True

X = int(eval(input()))

for i in range(X, 100004):
    if is_prime(i):
        print(i)
        break

# Optimized solution
def is_prime(a):
    for i in range(2, int(a**0.5)+1):
        if a%i == 0:
            return False
    return True

X = int(eval(input()))

for i in range(X, 100004):
    if is_prime(i):
        print(i)
        break
# Original solution
x=int(eval(input()))
count=0

n=1
while True:
	n+=1
	ans=True
	for i in range(2,int(x**0.5)):
		if n%i==0:
			ans=False
	if ans and n>=x:
		print(n)
		break


# Optimized solution
x=int(eval(input()))
count=0

n=1
while True:
	n+=1
	ans=True
	for i in range(2,int(x**0.5)):
		if n%i==0:
			ans=False
			break
	if ans and n>=x:
		print(n)
		break
# Original solution
m = int(eval(input()))
if m <= 2 :
  print('2')
else:
  n = 10**6
  primes = set(range(2, n+1))
  for i in range(2, int(n**0.5+1)):
      primes.difference_update(list(range(i*2, n+1, i)))
  primes=list(primes)

  for i in range(len(primes)-1):
    if primes[i] < m and m <= primes[i+1]:
      print((primes[i+1]))

# Optimized solution
m = int(eval(input()))
if m <= 2 :
  print('2')
else:
  n = 2*10**5
  primes = set(range(2, n+1))
  for i in range(2, int(n**0.5+1)):
      primes.difference_update(list(range(i*2, n+1, i)))
  primes=list(primes)

  for i in range(len(primes)-1):
    if primes[i] < m and m <= primes[i+1]:
      print((primes[i+1]))
# Original solution
def c_next_prime():
    from bisect import bisect_left
    X = int(eval(input()))

    def prime_table(n):
        """n以下の素数のリスト(エラトステネスの篩)"""
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return [i for i in range(n + 1) if is_prime[i]]

    primes = prime_table(2 * X)
    return primes[bisect_left(primes, X)]

print((c_next_prime()))

# Optimized solution
def c_next_prime():
    from bisect import bisect_left
    X = int(eval(input()))

    def prime_table(n):
        """n以下の素数のリスト(エラトステネスの篩)"""
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return [i for i in range(n + 1) if is_prime[i]]

    primes = prime_table(min(2 * X, 10**5 + 3))
    return primes[bisect_left(primes, X)]

print((c_next_prime()))
# Original solution
import math
X = int(eval(input()))
def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)
        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list
l = get_primenumber(10**6)
for i in range(X,10**6):
  if i in l:
    print(i)
    break

# Optimized solution
import math
X = int(eval(input()))
def f(X):
  if X <= 1:
    return False
  for i in range(2, int(math.sqrt(X))+1):
    if X%i==0:
      return False
  return True
while not f(X):
  X += 1
print(X)
# Original solution
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n = int(read())
n_ = 5*10**5

primes = set(range(2, n_+1))
for i in range(2, int(n_**0.5+1)):
    primes.difference_update(list(range(i*2, n_+1, i)))
primes=list(primes)

idx = bisect.bisect_left(primes, n)



print((primes[idx]))


# Optimized solution
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n = int(read())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


for i in range(n, n*n, 1):
    if is_prime(i):
        print(i)
        break
# Original solution
import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


def main():
    X = int(readline())

    P = prime_numbers(10 ** 6)
    ans = P[bisect_left(P, X)]

    print(ans)
    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True


def main():
    X = int(readline())

    while not is_prime(X):
        X += 1

    print(X)
    return


if __name__ == '__main__':
    main()
# Original solution
x = int(eval(input()))
num = 0

for i in range(x,x*2):
    for j in range(2,x//2):
        if i%j == 0:
            num += 1
            continue
    if num == 0:
        print(i)
        exit(0)
    num = 0

# Optimized solution
import math
x = int(eval(input()))
for i in range(x, x * 2):
    flag = True
    for j in range(2, math.floor(math.sqrt(x))+1):
        if i % j == 0:
            flag = False
            break
    if flag:
        print(i)
        exit(0)
# Original solution
import math

x = int(eval(input()))

prms = []
n = 2
while True:
    is_prm = True
    for prm in prms:
        if n % prm == 0:
            is_prm = False
            break
    if is_prm:
        prms.append(n)
        if n >= x:
            break
    n += 1

print(n)


# Optimized solution
import math

x = int(eval(input()))

prm_dict = {i: True for i in range(2, 100004)}
for n in range(2, 100004):
    if prm_dict[n]:
        if n >= x:
            break
        for nk in range(n * 2, 100004, n):
            prm_dict[nk] = False
print(n)
# Original solution
x = int(eval(input()))
nums = [i for i in range(2, 100004)]
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]


# Optimized solution
import sys

x = int(eval(input()))
nums = [i for i in range(1, 100004, 2)]
del nums[0]
if x == 2:
    print((2))
    sys.exit()
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]
# Original solution
import sys

x = int(eval(input()))
nums = [i for i in range(1, 100004, 2)]
del nums[0]
if x == 2:
    print((2))
    sys.exit()
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]


# Optimized solution
def check_primal(num):
    '''素数だったら0を、違ったら1を返す'''
    for mod in range(2, int(num**0.5+1)):
        if num % mod == 0:
            return 1
    return 0


x = int(eval(input()))

for i in range(x, 100004):
    if check_primal(i) == 0:
        print(i)
        break
# Original solution
X = int(eval(input()))

sosu = [2]

for i in range(3, 10**5+100, 2):
    if(all(i % num != 0 for num in sosu)):
        sosu.append(i)   
        if(i >= X):
            print((i if X > 2 else 2))
            break

# Optimized solution
import math

X = int(eval(input()))

def isprime(num):
    if(num==2):
        return True
    elif(num%2 == 0):
        return False
    
    for i in range(3, int(math.sqrt(num)+1), 2):
        if(num%i == 0):
            return False
        
    return True

def prime(n):
    ans = 2
    for i in range(n, 10**5+4):
        if(isprime(i)):
            ans = i        
            break
    return ans
 
print((prime(X)))
# Original solution
nn=int(eval(input()))
n=10**5+100
ar=[0]*(n)
ar[1]=0
ans=0
pre=1
for i in range(2,n):
    if ar[i]==0:

        for j in range(2*i,n,i):
            ar[j]=1
ans=1
if ar[nn]==0:
    print(nn)
else:
        
    for i in range(nn,n):
        if ar[i]==0:
            print(i)
            break
        

        

# Optimized solution
nn=int(eval(input()))
n=10**5+100
ar=[0]*(n)
ar[1]=0
ans=0
pre=1
for i in range(2,int((n**0.5))+1):
    if ar[i]==0:

        for j in range(2*i,n,i):
            ar[j]=1
ans=1
if ar[nn]==0:
    print(nn)
else:
        
    for i in range(nn,n):
        if ar[i]==0:
            print(i)
            break
# Original solution
n, w = list(map(int, input().split()))
V, W = [], []
for i in range(n):
    wi, vi = list(map(int, input().split()))
    W.append(wi)
    V.append(vi)
    
max_sumv = sum(V) 
# dp[i][sum_v] := i-1 番目までの品物から価値がsum_v以上を達成するように選んだときの、重さの総和の最小値   
dp = [[10 ** 9] * (max_sumv + 1) for _ in range(n+1)]

dp[0][0] = 0
for i in range(n):
    for sum_v in range(max_sumv + 1):
        #i番目の商品を選ぶ場合
        if sum_v - V[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - V[i]] + W[i])
        #i番目の商品を選ばない場合
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])
ans = 0
for i in range(max_sumv + 1):
    if dp[n][i] <= w:
        ans = i
print(ans)

# Optimized solution
n, w = list(map(int, input().split()))
W, V = [], []
sum_v = 0
for i in range(n):
  wi, vi = list(map(int ,input().split()))
  W.append(wi)
  V.append(vi)
  sum_v += vi

memo = [[10**9] * (sum_v + 1) for _ in range(n+1)]
memo[0][0] = 0

for i in range(n):
  for v_i in range(sum_v + 1):
    memo[i+1][v_i] = min(memo[i+1][v_i], memo[i][v_i])
    if v_i - V[i] >= 0:
      memo[i+1][v_i] = min(memo[i+1][v_i], memo[i][v_i-V[i]] + W[i])

ans = 0
for i in range(sum_v + 1):
  if memo[-1][i] <= w:
    ans = i
print(ans)
# Original solution
n,wmax=list(map(int,input().split()))
v=[0]*n
w=[0]*n
for i in range(n):
    w[i],v[i]=list(map(int,input().split()))
sv=sum(v)+1
dp=[[float('inf')]*sv for _ in range(n)]
dp[0][v[0]-1]=w[0]
for i in range(n):
    dp[i][0]=0
for i in range(n):
    for j in range(sv):
        dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
        if dp[i][j]>wmax:
            dp[i][j]=float('inf')
ans=float('inf')
for p in range(sv-1,-1,-1):
    if dp[n-1][p]!=ans:
        ans=p
        break
print(ans)

# Optimized solution
n,wmax=list(map(int,input().split()))
v=[0]*n
w=[0]*n
for i in range(n):
    w[i],v[i]=list(map(int,input().split()))
sv=sum(v)+1
dp=[[float('inf')]*sv for _ in range(n)]
dp[0][v[0]-1]=w[0]
for i in range(n):
    dp[i][0]=0
for i in range(n):
    for j in range(sv):
        dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
ans=float('inf')
for p in range(sv-1,-1,-1):
    if dp[n-1][p]!=ans and dp[n-1][p]<=wmax:
        ans=p
        break
print(ans)
# Original solution
N,W =list(map(int,input().split()))
weight,value=[],[]
for i in range(N):
    w,v = list(map(int,input().split()))
    weight.append(w)
    value.append(v)
inf = float('inf')
dp = [[inf for _ in range(10**3*N+10)] for _ in range(N+10)]
maxv = sum(value)
#初期化
dp[0][0] =0
for i in range(N):
    for sum_v in range(maxv+1):
        if sum_v-value[i] >=0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v-value[i]] + weight[i])
        dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])
res =0
for sum_v in range(maxv+1):
    if dp[N][sum_v] <=W:
        res = sum_v
print(res)

# Optimized solution
N,maxW = list(map(int,input().split()))
w,v = [],[]
for i in range(N):
    weight,value = list(map(int,input().split()))
    w.append(weight)
    v.append(value)
maxV=sum(v)
inf = float('inf')
dp = [[inf for _ in range(maxV+1)] for _ in range(N+1)]
dp[0][0] =0
for i in range(N):
    for sum_v in range(maxV+1):
        if (sum_v -v[i]>=0):
            dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v-v[i]]+w[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v])
res = 0
for i in range(maxV+1):
    if dp[N][i] <= maxW:
        res = i
print(res)
# Original solution
n,w = list(map(int,input().split()))
item = [list(map(int,input().split())) for i in range(n)]

dp = [[float('inf')]*(10**5+1) for i in range(n+1)]
dp[0][0] = 0

for i in range(1,n+1):
    for j in range(10**5+1):
        if j >= item[i-1][1]:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-item[i-1][1]]+item[i-1][0])
        else:
            dp[i][j] = dp[i-1][j]
for j in range(10**5+1):
    if dp[n][j] <= w:
        ans = j

print(ans)

# Optimized solution
INF = 10**18
N, W = list(map(int, input().split()))

dp = [[INF for i in range(10**5 + 1)] for j in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    w, v = list(map(int, input().split()))
    for j in range(10**5 + 1):
        if j - v >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w)
        else:
            dp[i][j] = dp[i - 1][j]

res = 0

for j in range(10**5 + 1):
    if dp[N][j] <= W:
        res = j

print(res)
# Original solution
import sys
input=sys.stdin.readline

import collections
def main():
    N,W = list(map(int, input().split()))
    I = collections.deque()
    for _ in range(N):
        I.append(tuple(map(int, input().split())))

    MV = N*(10**3) + 1
    dp = [[0]*MV for _ in range(N+1)]
    inf = 2*10**9
    for j in range(MV):
        dp[0][j] = inf
    dp[0][0] = 0
    
    for i in range(N):
        w,v = I.popleft()
        for j in range(MV):
            if j < v:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = min(dp[i][j], dp[i][j-v] + w)
    ans = 0
    for j in range(MV):
        if dp[N][j] <= W:
            ans = j
    print(ans)

if __name__ == '__main__':
    main()


# Optimized solution
import sys
input=sys.stdin.readline

import collections
def main():
    N,W = list(map(int, input().split()))
    I = collections.deque()
    for _ in range(N):
        I.append(tuple(map(int, input().split())))

    MV = 1 + N*(10**3)
    dp = [[0]*MV for _ in range(N+1)]
    inf = 2*10**9
    for j in range(MV):
        dp[0][j] = inf
    dp[0][0] = 0
    
    for i in range(N):
        w,v = I.popleft()
        for j in range(MV):
            if j < v:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = min(dp[i][j], dp[i][j-v] + w)
    ans = 0
    for v,w in enumerate(dp[N]):
        if w <= W:
            ans = v
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
# temp
n,w = list(map(int,input().split()))
wv = [tuple(map(int,input().split())) for i in range(n)]

dp = [0] + [float("inf")]*(10**5)
for i in range(n):
    for j in range(10**5,wv[i][1]-1,-1):
        dp[j] = min(dp[j],dp[j-wv[i][1]]+wv[i][0])

res = 0
for v,e in enumerate(dp):
    if e <= w:
        res = v
print(res)

# Optimized solution
# dpE - Knapsack 2
import sys
input = sys.stdin.readline

def main():
    n, W = tuple(map(int, input().rstrip().split()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    _, v = list(zip(*A))
    lim = sum(v)
    dp = [0] + [float("inf")] * lim
    for i in range(n):
        for j in range(lim, A[i][1] - 1, -1):
            dp[j] = min(dp[j], dp[j - A[i][1]] + A[i][0])
    ans = max(v for v, w in enumerate(dp) if w <= W)
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
# dpE
import sys
input = sys.stdin.readline

def main():
    N, W = tuple(map(int, input().rstrip().split()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N))
    lim = 10 ** 5
    dp = [0] + [float("inf")] * lim
    for i in range(N):
        for j in range(lim, A[i][1] - 1, -1):
            dp[j] = min(dp[j], dp[j - A[i][1]] + A[i][0])
    ans = [i for i, j in enumerate(dp) if j <= W]
    print((max(ans)))


if __name__ == "__main__":
    main()

# Optimized solution
# dpE - Knapsack 2
import sys
input = sys.stdin.readline

def heavy_knapsack(W: int, weight: "Array[int]", value: "Array[int]") -> int:
    lim = sum(value)
    dp = [0] + [float("inf")] * lim  # dp[i] := minimum weight of value i
    for w, v in zip(weight, value):
        for cur_v in range(lim, v - 1, -1):
            dp[cur_v] = min(dp[cur_v], dp[cur_v - v] + w)
    ret = max(v for v, w in enumerate(dp) if w <= W)
    return ret


def main():
    N, W = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    w, v = list(zip(*A))
    ans = heavy_knapsack(W, w, v)
    print(ans)


if __name__ == "__main__":
    main()