local mmi, mma = math.min, math.max local n, x = io.read("*n", "*n") local a = {} for i = 1, n do a[i] = io.read("*n") - x end local b = {} for i = 1, n do b[i] = io.read("*n") end local asum = 0 for i = 1, n do asum = asum + a[i] end if 0 <= asum then print(0) os.exit() end do local f = true for i = 1, n do if 0 <= a[i] then f = false break end end if f then print(-1) os.exit() end end asum = -asum local t = {} for i = 1, asum do t[i] = -1 end for i = 1, n do local ai = a[i] local bi = b[i] if ai < 0 then ai = -ai for j = asum, 1, -1 do local dst = mmi(asum, j + ai) if t[dst] < 0 or t[j] + bi < t[dst] then t[dst] = t[j] + bi end end do local dst = mmi(asum, ai) if t[dst] < 0 or bi < t[dst] then t[dst] = bi end end end end print(t[asum])