#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	while (n*n + m * m != 0) {
		vector<int> si(n);
		for (int i = 0; i < n; i++) {
			cin >> si[i];
		}
		int ma = 1;
		int kai = 0;
		while (ma < n) {
			kai++;
			int x;
			cin >> x;
			ma += x;
			if (ma < n) {
				ma += si[ma - 1];
			}
		}
		cout << kai << endl;
		for (int i = kai; i < m; i++) {
			int x; cin >> x;
		}
		cin >> n >> m;
	}
}

