#include<stdio.h>
int main(){
	int s[9000],n,m,t,f,i;
	while(scanf("%d%d",&n,&m),n)
		for(i=t=f=1;i<=n+m;i++){
			scanf("%d",&s[i]);
			if(i>n){t+=s[t+=s[i]];
				if(t>=n&f==1){
					printf("%d\n",i-n);
					f=0;
			}
		}}
}