n, as, bs = ARGF.read.split("\n").map { |e| e.split }
xs = as.zip(bs).map { |e|
  a,b = e.map { |e| e.to_i }
  [a, b, a - b]
}.sort { |e| e.last }
ms = xs.select { |e|
  e.last < 0
}
ps = xs.select { |e|
  e.last > 0
}
if ms.length == 0
  puts 0
  exit
end

c = ms.length
val = 0
ms.each { |e|
  if val <= e.last.abs
    loop {
      if ps.length == 0
        puts -1
        exit
      else
        val += ps.pop.last
        c += 1
        if val > e.last.abs
          val -= e.last.abs
          break
        end
      end
    }
  end
}
puts c
