import std.stdio,
       std.string,
       std.conv;

void main() {
    while(1) {
        auto input = readln.split;
        auto n = input[0].to!int;
        auto m = input[1].to!int;
        if ((n | m) == 0)
            break;

        auto h = new int[](n);
        foreach(i; 0 .. n)
            h[i] = readln.chomp.to!int;
        auto w = new int[](m);
        foreach(i; 0 .. m)
            w[i] = readln.chomp.to!int;

        int ans;
        foreach(i; 0 .. n) {    int y = 0;
        foreach(j; i .. n) {
            y += h[j];
            foreach(k; 0 .. m) {    int x = 0;
            foreach(l; k .. m) {
                x += w[l];
                if (x == y) {
                    ans += 1;
                    break;
                }
                else if (x > y)
                    break;
            }}
        }}
        
        ans.writeln;
    }
}