950_B. Intercepted Message_28711
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 l1, l2, ..., lk bytes, then the i-th file is split to one or more blocks bi, 1, bi, 2, ..., bi, mi (here the total length of the blocks bi, 1 + bi, 2 + ... + bi, mi is equal to the length of the file li), 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.

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 105) — the number of blocks in the first and in the second messages.

The second line contains n integers x1, x2, ..., xn (1 ≤ xi ≤ 106) — the length of the blocks that form the first message.

The third line contains m integers y1, y2, ..., ym (1 ≤ yi ≤ 106) — the length of the blocks that form the second message.

It is guaranteed that x1 + ... + xn = y1 + ... + ym. Also, it is guaranteed that x1 + ... + xn ≤ 106.

Output

Print the maximum number of files the intercepted array could consist of.

Examples

Input

7 6
2 5 3 1 11 4 4
7 8 2 4 1 8


Output

3


Input

3 3
1 10 100
1 100 10


Output

2


Input

1 4
4
1 1 1 1


Output

1

Note

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.
import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;
public class Blocks{
    public static void main(String[] args) {
        MyScanner sc=new MyScanner();
        int a=sc.ni();
        int b=sc.ni();
        int ar[]=new int[a];
        int br[]=new int[b];
        for(int i=0;i<a;i++) ar[i]=sc.ni();
        for(int i=0;i<b;i++) br[i]=sc.ni();
        long s1=0,s2=0;
        int pa=0,pb=0,ans=0;
        while(pa<a && pb<b){
          if(s1==0 && s2==0){
            s1+=ar[pa];
            pa++;
          }
          else if(s1>s2){
            s2+=br[pb];
            pb++;
          }
          else if(s1<s2){
            s1+=ar[pa];
            pa++;
          }
          else if(s1==s2 && s1!=0){
            ans++;
            s1=0;
            s2=0;
          }
        }//end of while
        ans++;//for last pair 
        System.out.println(ans);
    }


    private static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }

      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }

      int ni() {
          return Integer.parseInt(next());
      }
      float nf() {
        return Float.parseFloat(next());
      }
      long nl() {
          return Long.parseLong(next());
      }

      double nd() {
          return Double.parseDouble(next());
      }

      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}
1 4
4
1 1 1 1
 7 6
2 5 3 1 11 4 4
7 8 2 4 1 8
 3 3
1 10 100
1 100 10
 1 1
1000000
1000000
 2 2
1 1
1 1
 2 2
2 3
3 2
 2 3
2 2
1 1 2
 2 3
3 2
2 1 2
 2 2
2 3
4 1
 1 1
1
1
 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
 2 2
500000 500000
1 999999
 2 2
2 3
2 3
 1 2
1000000
999999 1
 5 3
1 1 4 1 2
1 4 4
 3 5
2 2 9
2 1 4 2 4
 1 2
2
1 1
 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
 3 6
8 4 1
1 8 1 1 1 1
 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
 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
 2 3
2 3
2 1 2
 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
 2 3
2 2
2 1 1
 2 3
1 3
2 1 1
 5 3
1 1 4 1 3
2 4 4
 2 2
3 3
3 3
 3 5
2 3 9
2 1 4 2 5
 3 5
3 1 9
2 1 4 2 4
 2 2
2 1
2 1
 2 2
2 5
2 5
 3 5
2 3 9
2 2 4 2 4
 2 2
3 2
2 3
 2 3
4 2
1 1 4
 2 2
2 4
3 3
 3 3
2 10 100
2 100 10
 2 2
2 2
2 2
 2 3
3 1
1 1 2
 1 1
2
2

1
 3
 2
 1
 2
 1
 2
 2
 1
 1
 12
 1
 2
 1
 2
 2
 1
 31
 2
 12
 50
 2
 1
 2
 1
 3
 2
 2
 2
 2
 2
 2
 1
 1
 1
 2
 2
 1
 1
