fun main(args: Array<String>) {
    val (N, W) = readLine()!!.split(" "). map { it.toInt() }
    val INIT = 2000000000L
    val SIZE = 1000001
    var dp = LongArray(SIZE) {INIT}
    dp[0] = 0
    val w = IntArray(N+1)
    val v = IntArray(N+1)
    for(i in 0 until N) {
        val a = readLine()!!.split(" "). map { it.toInt() }
        w[i] = a[0]
        v[i] = a[1]
    }

    for (i in 0 until N) {
        val dp2 = dp.clone()
        for (j in SIZE-1 downTo v[i]) {
            if (dp[j-v[i]] == INIT) continue
            if (dp[j -v[i]] + w[i] > W) continue
            dp2[j] = Math.min(dp2[j], dp[j - v[i]] + w[i])
        }
        dp = dp2
    }
    for (i in (SIZE-1) downTo 0) {
        if (dp[i] <= W) {
            println(i)
            return
        }
    }
}