Hacker Zhorik wants to decipher two secret messages he intercepted yesterday. Yeah message is a sequence of encrypted blocks, each of them consists of several bytes of information.

Zhorik knows that each of the messages is an archive containing one or more files. Zhorik knows how each of these archives was transferred through the network: if an archive consists of *k* files of sizes *l*<sub class="lower-index">1</sub>, *l*<sub class="lower-index">2</sub>, ..., *l*<sub class="lower-index">*k*</sub> bytes, then the *i*-th file is split to one or more blocks *b*<sub class="lower-index">*i*, 1</sub>, *b*<sub class="lower-index">*i*, 2</sub>, ..., *b*<sub class="lower-index">*i*, *m*<sub class="lower-index">*i*</sub></sub> (here the total length of the blocks *b*<sub class="lower-index">*i*, 1</sub> + *b*<sub class="lower-index">*i*, 2</sub> + ... + *b*<sub class="lower-index">*i*, *m*<sub class="lower-index">*i*</sub></sub> is equal to the length of the file *l*<sub class="lower-index">*i*</sub>), and after that all blocks are transferred through the network, maintaining the order of files in the archive.

Zhorik thinks that the two messages contain the same archive, because their total lengths are equal. However, each file can be split in blocks in different ways in the two messages.

You are given the lengths of blocks in each of the two messages. Help Zhorik to determine what is the maximum number of files could be in the archive, if the Zhorik's assumption is correct.
The first line contains two integers *n*, *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">5</sup>) — the number of blocks in the first and in the second messages.

The second line contains *n* integers *x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, ..., *x*<sub class="lower-index">*n*</sub> (1 ≤ *x*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>) — the length of the blocks that form the first message.

The third line contains *m* integers *y*<sub class="lower-index">1</sub>, *y*<sub class="lower-index">2</sub>, ..., *y*<sub class="lower-index">*m*</sub> (1 ≤ *y*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>) — the length of the blocks that form the second message.

It is guaranteed that *x*<sub class="lower-index">1</sub> + ... + *x*<sub class="lower-index">*n*</sub> = *y*<sub class="lower-index">1</sub> + ... + *y*<sub class="lower-index">*m*</sub>. Also, it is guaranteed that *x*<sub class="lower-index">1</sub> + ... + *x*<sub class="lower-index">*n*</sub> ≤ 10<sup class="upper-index">6</sup>.
In the first example the maximum number of files in the archive is 3. For example, it is possible that in the archive are three files of sizes 2 + 5 = 7, 15 = 3 + 1 + 11 = 8 + 2 + 4 + 1 and 4 + 4 = 8.

In the second example it is possible that the archive contains two files of sizes 1 and 110 = 10 + 100 = 100 + 10. Note that the order of files is kept while transferring archives through the network, so we can't say that there are three files of sizes 1, 10 and 100.

In the third example the only possibility is that the archive contains a single file of size 4.
7 6
2 5 3 1 11 4 4
7 8 2 4 1 8
3
3 3
1 10 100
1 100 10
2
1 4
4
1 1 1 1
1
1 1
1000000
1000000
1
3 5
2 2 9
2 1 4 2 4
2
5 3
1 1 4 1 2
1 4 4
2
30 50
3 3 1 3 1 2 4 3 4 1 3 2 3 3 2 3 2 1 3 4 2 1 1 3 2 2 1 3 1 60
4 4 1 2 2 2 3 1 3 2 1 2 4 4 2 1 2 3 1 3 4 4 3 3 4 4 4 1 2 1 3 3 1 1 3 3 4 3 2 3 2 4 1 4 2 3 2 2 3 1
12
50 50
5733 740 547 3647 5382 5109 6842 7102 5879 1502 3574 1628 7905 4357 8569 9564 8268 3542 2487 8532 425 7713 2585 925 6458 2697 2844 69 324 9030 495 4428 6724 3524 3304 4874 1303 2098 1136 1048 2464 7316 274 9586 534 2450 2368 8060 7795 70692
1918 4122 6806 4914 6517 6278 9842 9480 6609 4221 9373 1728 9508 9778 8578 5589 2673 6618 6031 9016 4017 6671 6008 2268 5154 9614 6834 9512 9618 6424 1736 1464 6520 9812 1722 9197 2412 2699 73 968 2906 2715 6573 8675 548 7061 5455 88 5565 2544
1
1 2
2
1 1
1
1 2
1000000
999999 1
1
2 2
1 1
1 1
2
2 2
500000 500000
1 999999
1
2 2
2 3
4 1
1
2 2
2 3
3 2
1
2 2
2 3
2 3
2
2 3
2 2
1 1 2
2
1 1
1
1
1
2 3
3 2
2 1 2
2
2 3
2 3
2 1 2
2
50 30
2 3 1 2 2 4 3 4 3 2 1 4 2 3 1 3 1 2 2 3 1 1 1 2 3 1 4 3 1 2 1 2 2 1 2 4 4 3 3 2 2 1 1 1 2 2 2 4 3 3
3 3 3 4 1 4 1 4 4 1 3 4 3 1 2 4 2 1 4 2 3 1 1 2 2 1 2 4 1 41
12
50 50
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
50
31 31
5745 258 5486 13779 20931 407 1478 49032 30787 4957 36603 1034 5011 22319 50560 34419 22036 18235 62551 89259 36093 126169 106027 1673 52983 50127 640 30714 54574 20129 45984
5745 258 5486 13779 20931 407 1478 49032 30787 4957 36603 1034 5011 22319 50560 34419 22036 18235 62551 89259 36093 126169 106027 1673 52983 50127 640 30714 54574 20129 45984
31
3 6
8 4 1
1 8 1 1 1 1
2
n, m = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
y = list(map(int, input().split(' ')))

sumx, sumy = x[0], y[0]
ix, iy = 0, 0

ans = 0

while 1:
    if sumx == sumy and ix < n - 1 and iy < m - 1:
        ix += 1
        iy += 1
        sumxnew = x[ix]
        sumynew = y[iy]
        ans += 1
    elif sumx < sumy and ix < n - 1:
        ix += 1
        sumxnew = sumx + x[ix]
        sumynew = sumy
    elif sumx > sumy and iy < m - 1:
        iy += 1
        sumxnew = sumx
        sumynew = sumy + y[iy]
    else:
        break
    sumx, sumy = sumxnew, sumynew

if sumx == sumy:
    ans += 1
print(ans)
