#include <stdio.h>

int main(){
    int N,M,i,j,k,l,a,h[i],w[i],s,t,x;
    x=0;
    scanf("%d %d",&N,&M);
    while (N!==0 && M!==0) {
    for (i=0;i<N;i++) {
        scanf("%d",&h[i]);
    }
    for (i=0;i<M;i++){
        scanf("%d",&w[i]);
    }
    for (i=0;i<N;i++) {
        for (j=i;j<N;j++) {
            for(k=0;k<M;k++) {
                for (l=k;l<M;l++) {
                    s=0; t=0;
                    for (a=i;a<=j;a++) {s=s+h[a];}
                    for (a=k;a<=l;a++) {t=t+w[a];}
                    if (s==t) {x++;}
                }
            }
        }
    }
    printf("%d\n",x);
    scanf("%d %d",&N,&M);}
    return 0;
    
}