#include<stdio.h>
int w,h,i,j,k,s,a,d[1510],b[1510],t,r,c;
int main(){
  while(scanf("%d %d",&h,&w),w||h){
    for(i=d[0]=0;i<h;i++){
      scanf("%d",&a);
      d[i+1]=d[i]+a;//printf("%d %d\n",i+1,d[i+1]);
    }
    d[i+1]=1000000000;
    for(i=c=b[0]=0;i<w;i++)scanf("%d",&b[i]);//,printf("b%d\n",b[i]);
    b[i]=1000000000;
    for(i=1;i<=h;i++){
      for(j=0;j<i;j++){
	t=r=s=0;//printf("%d\n",d[i]-d[j]);
	while(t<=w){//printf("%d %d %d\n",t,r,s);
	  if(s==d[i]-d[j])c++;
	  if(s<=d[i]-d[j])s+=b[r++];
	  if(s> d[i]-d[j])s-=b[t++];
	}//printf("c%d\n",c);
      }
    }
    printf("%d\n",c);
  }
  return 0;
}
	  