import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int N, M;
int[] H, W;
bool input() {
    scanf("%d %d\n", &N, &M);
    if (N == 0 && M == 0) return false;
    H = new int[N];
    W = new int[M];
    foreach (i; 0 .. N) {
        scanf("%d\n", &H[i]);
    }
    foreach (i; 0 .. M) {
        scanf("%d\n", &W[i]);
    }
    return true;
}

void solve() {
    auto sH = new int[N + 1];
    foreach (i; 0 .. N) {
        sH[i + 1] = sH[i] + H[i];
    }
    auto sW = new int[M + 1];
    foreach (i; 0 .. M) {
        sW[i + 1] = sW[i] + W[i];
    }

    int[] hh;
    foreach (i; 0 .. N) {
        foreach (j; i + 1 .. N + 1) {
            hh ~= sH[j] - sH[i];
        }
    }
    hh.sort;
    int ans = 0;
    foreach (i; 0 .. M) {
        foreach (j; i + 1 .. M + 1) {
            int w = sW[j] - sW[i];
            ans += hh.assumeSorted.equalRange(w).count;
        }
    }
    writeln(ans);
}

void main() {
    while (input) solve;
}