loop {
    n, m  = gets.split.map &:to_i
    break if n == 0
    board = (1..n).map{ gets.to_i }
    dice = (1..m).map{ gets.to_i }
    x = 0
    k = 0
    loop {
        x += dice[k]
        k += 1
        break if x >= n - 1
        x += board[x]
        break if x >= n - 1
    }
    puts k
}