def main():

  n, w = [int(e) for e in input().split()]

  maxv = 10 ** 3 * n + 1

  t = [-1 for i in range(maxv)]

  t[0] = w

  for _ in range(n):

    nw, nv = [int(e) for e in input().split()]

    for i in range(maxv - 1, -1, -1):

      if t[i] == -1:

        continue

      if t[i + nv] < t[i] - nw:

        t[i + nv] = t[i] - nw

  for i in range(maxv - 1, 0, -1):

    if t[i] == -1:

      continue

    print(i)

    break

main()
def main():

  n, w = [int(e) for e in input().split()]

  maxv = 10 ** 3 * n + 1

  t = [-1 for i in range(maxv)]

  t[0] = w

  cmaxv = 0

  for _ in range(n):

    nw, nv = [int(e) for e in input().split()]

    for i in range(cmaxv, -1, -1):

      if t[i] == -1:

        continue

      if t[i + nv] < t[i] - nw:

        t[i + nv] = t[i] - nw

        if cmaxv < i + nv:

          cmaxv = i + nv

  print(cmaxv)

main()
def main():
    n, w = [int(e) for e in input().split()]
    maxv = 10**3 * n + 1
    t = [-1 for i in range(maxv)]
    t[0] = w
    for _ in range(n):
        nw, nv = [int(e) for e in input().split()]
        for i in range(maxv - 1, -1, -1):
            if t[i] == -1:
                continue
            if t[i + nv] < t[i] - nw:
                t[i + nv] = t[i] - nw
    for i in range(maxv - 1, 0, -1):
        if t[i] == -1:
            continue
        print(i)
        break


main()

def main():
    n, w = [int(e) for e in input().split()]
    maxv = 10**3 * n + 1
    t = [-1 for i in range(maxv)]
    t[0] = w
    cmaxv = 0
    for _ in range(n):
        nw, nv = [int(e) for e in input().split()]
        for i in range(cmaxv, -1, -1):
            if t[i] == -1:
                continue
            if t[i + nv] < t[i] - nw:
                t[i + nv] = t[i] - nw
                if cmaxv < i + nv:
                    cmaxv = i + nv
    print(cmaxv)


main()

+    cmaxv = 0 -        for i in range(maxv - 1, -1, -1): +        for i in range(cmaxv, -1, -1): -    for i in range(maxv - 1, 0, -1): -        if t[i] == -1: -            continue -        print(i) -        break +                if cmaxv < i + nv: +                    cmaxv = i + nv +    print(cmaxv)