import java.util.*;
import java.io.*;
import java.lang.*;

public class codes_1
	{

		public static void main(String[] args)
		{
			InputReader in = new InputReader(System.in);
			PrintWriter pw = new PrintWriter(System.out);

			//Code starts..

			int n = in.nextInt();
			int m = in.nextInt();

			int[] a = in.nextIntArray(n);
			int[] b = in.nextIntArray(m);

			int i=1, j=1;
			long sum1 = a[0];
			long sum2 = b[0];
			int ans = 0;
			boolean flag = false;
			while(i<n || j<m)
			{
				flag = false;
				if(sum1<sum2)
					sum1 += a[i++];
				if(sum1>sum2)
					sum2 += b[j++];
				if(sum1==sum2){
					//pw.println(i+" "+j+" ");
					ans++;
					if(i<n)
					{
						flag = true;
						sum1=a[i++];
					}
						if(j<m)
						{
							flag = true;
							sum2=b[j++];
						}

				}

			}
			if(i==n && j==n && sum1==sum2 && flag)
				ans++;

			pw.println(ans);
			//Code ends....

			pw.flush();
			pw.close();
		}

		static class InputReader
		{

			private final InputStream stream;
			private final byte[] buf = new byte[8192];
			private int curChar, snumChars;
			private SpaceCharFilter filter;

			public InputReader(InputStream stream)
			{
				this.stream = stream;
			}

			public int snext()
			{
				if (snumChars == -1)
					throw new InputMismatchException();
				if (curChar >= snumChars)
				{
					curChar = 0;
					try
					{
						snumChars = stream.read(buf);
					}
					catch (IOException e)
					{
						throw new InputMismatchException();
					}
					if (snumChars <= 0)
						return -1;
				}
				return buf[curChar++];
			}

			public int nextInt()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				int sgn = 1;
				if (c == '-')
			    {
					sgn = -1;
					c = snext();
				}
				int res = 0;
				do
				{
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public long nextLong()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				int sgn = 1;
				if (c == '-')
				{
					sgn = -1;
					c = snext();
				}
				long res = 0;
				do
				{
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public int[] nextIntArray(int n)
			{
				int a[] = new int[n];
				for (int i = 0; i < n; i++)
				{
					a[i] = nextInt();
				}
				return a;
			}

			public String readString()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				StringBuilder res = new StringBuilder();
				do
				{
					res.appendCodePoint(c);
					c = snext();
				} while (!isSpaceChar(c));
				return res.toString();
			}

			public String nextLine()
			{
				int c = snext();
				while (isSpaceChar(c))
					c = snext();
				StringBuilder res = new StringBuilder();
				do
				{
					res.appendCodePoint(c);
					c = snext();
				} while (!isEndOfLine(c));
				return res.toString();
			}

			public boolean isSpaceChar(int c)
			{
				if (filter != null)
					return filter.isSpaceChar(c);
				return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
			}

			private boolean isEndOfLine(int c)
			{
				return c == '\n' || c == '\r' || c == -1;
			}

			public interface SpaceCharFilter
		    {
				public boolean isSpaceChar(int ch);
			}
		}
		public static long c = 0;

		public static long mod = 1000000007;
		public static int d;
		public static int p;
		public static int q;

		public static  int gcd(int p2, int p22)
		{
		    if (p2 == 0)
		        return (int) p22;
		    return gcd(p22%p2, p2);
		}

		public static int findGCD(int arr[], int n)
		{
		    int result = arr[0];
		    for (int i=1; i<n; i++)
		        result = gcd(arr[i], result);

		    return result;
		}

	    public static long lcm(int[] numbers) {
	        long lcm = 1;
	        int divisor = 2;
	        while (true) {
	            int cnt = 0;
	            boolean divisible = false;
	            for (int i = 0; i < numbers.length; i++) {
	                if (numbers[i] == 0) {
	                    return 0;
	                } else if (numbers[i] < 0) {
	                    numbers[i] = numbers[i] * (-1);
	                }
	                if (numbers[i] == 1) {
	                    cnt++;
	                }
	                if (numbers[i] % divisor == 0) {
	                    divisible = true;
	                    numbers[i] = numbers[i] / divisor;
	                }
	            }
	            if (divisible) {
	                lcm = lcm * divisor;
	            } else {
	                divisor++;
	            }
	            if (cnt == numbers.length) {
	                return lcm;
	            }
	        }
	    }
		public static long fact(long n) {

			long factorial = 1;
			 for(int i = 1; i <= n; i++)
		        {
		            factorial *= i;
		        }
			 return factorial;
		}

		public static int lowerLimit(int[] a, int n) {
			int ans = 0;

			int ll = 0;
			int rl = a.length-1;
		//	System.out.println(a[rl]+" "+n);
			if(a[0]>n)
				return 0;
			if(a[0]==n)
				return 1;
			else if(a[rl]<=n)
				return rl+1;

			while(ll<=rl)
			{

				int mid = (ll+rl)/2;
				if(a[mid]==n)
				{
					ans = mid + 1;
					break;
				}

				else if(a[mid]>n)
				{
					rl = mid-1;

				}
				else
				{
					ans = mid+1;
					ll = mid+1;
				}
			}

			return ans;
		}

		public static long choose(long total, long choose){
		    if(total < choose)
		        return 0;
		    if(choose == 0 || choose == total)
		        return 1;
		    return (choose(total-1,choose-1)+choose(total-1,choose))%mod;
		}

		public static int[] suffle(int[] a,Random gen)
		{
			int n = a.length;
			for(int i=0;i<n;i++)
			{
				int ind = gen.nextInt(n-i)+i;
				int temp = a[ind];
				a[ind] = a[i];
				a[i] = temp;
			}
			return a;
		}

		public static int floorSearch(int arr[], int low, int high, int x)
		{
		    if (low > high)
		        return -1;

		    if (x > arr[high])
		        return high;
		    int mid = (low+high)/2;

		    if (mid > 0 && arr[mid-1] < x && x < arr[mid])
		        return mid-1;

		    if (x < arr[mid])
		        return floorSearch(arr, low, mid-1, x);

		    return floorSearch(arr, mid+1, high, x);
		}

	/*	public static void swap(int a, int b){
			int temp = a;
			a = b;
			b = temp;
		}
		*/
		public static ArrayList<Integer> primeFactorization(int n)
		{
			ArrayList<Integer> a =new ArrayList<Integer>();
			for(int i=2;i*i<=n;i++)
			{
				while(n%i==0)
				{
					a.add(i);
					n/=i;
				}
			}
			if(n!=1)
				a.add(n);
			return a;
		}

		public static void sieve(boolean[] isPrime,int n)
		{
			for(int i=1;i<n;i++)
				isPrime[i] = true;

			isPrime[0] = false;
			isPrime[1] = false;

			for(int i=2;i*i<n;i++)
			{
				if(isPrime[i] == true)
				{
					for(int j=(2*i);j<n;j+=i)
						isPrime[j] = false;
				}
			}
		}

		public static int GCD(int a,int b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static long GCD(long a,long b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static void extendedEuclid(int A,int B)
		{
			if(B==0)
			{
				d = A;
				p = 1 ;
				q = 0;
			}
			else
			{
				extendedEuclid(B, A%B);
				int temp = p;
				p = q;
				q = temp - (A/B)*q;
			}
		}

		public static int lowerbound(ArrayList<Long> list, long n) {
			int i=Collections.binarySearch(list, n);
			if(i<0)
				i = -(i+2);
			return i;

		}
		public static int uperbound(ArrayList<Long> list, long n) {
			int i=Collections.binarySearch(list, n);
			if(i<0)
				i = -(i+1);
			return i;

		}

		public static long LCM(long a,long b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int LCM(int a,int b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int binaryExponentiation(int x,int n)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static int[] countDer(int n)
	    {
	        int der[] = new int[n + 1];

	        der[0] = 1;
	        der[1] = 0;
	        der[2] = 1;

	        for (int i = 3; i <= n; ++i)
	            der[i] = (i - 1) * (der[i - 1] + der[i - 2]);

	        // Return result for n
	        return der;
	    }

		 static long binomialCoeff(int n, int k)
		    {
		    long C[][] = new long[n+1][k+1];
		    int i, j;

		        // Calculate  value of Binomial Coefficient in bottom up manner
		    for (i = 0; i <= n; i++)
		    {
		        for (j = 0; j <= Math.min(i, k); j++)
		        {
		            // Base Cases
		            if (j == 0 || j == i)
		                C[i][j] = 1;

		            // Calculate value using previosly stored values
		            else
		                C[i][j] = C[i-1][j-1] + C[i-1][j];
		          }
		     }

		    return C[n][k];
		    }

		public static long binaryExponentiation(long x,long n)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=(x%mod * x%mod)%mod;
		        n=n/2;
		    }
		    return result;
		}

		public static int modularExponentiation(int x,int n,int M)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modularExponentiation(long x,long n,long M)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static int modInverse(int A,int M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static long modInverse(long A,long M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static boolean isPrime(int n)
		{

		    if (n <= 1)  return false;
		    if (n <= 3)  return true;

		    if (n%2 == 0 || n%3 == 0)
		    	return false;

		    for (int i=5; i*i<=n; i=i+6)
		    {
		        if (n%i == 0 || n%(i+2) == 0)
		           return false;
		    }

		    return true;
		}

		static class pair implements Comparable<pair>

		{
			Integer x, y;
			pair(int x,int y)
			{
				this.x=x;
				this.y=y;
			}

			public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);

				return result;
			}

			public String toString()
			{
				return x+" "+y;
			}

			public boolean equals(Object o)
			{
				if (o instanceof pair)
			    {
					pair p = (pair)o;
					return p.x == x && p.y == y ;
				}
				return false;
			}

			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode();
			}
		}

		static class triplet implements Comparable<triplet>
		{
			Integer x,y,z;
			triplet(int x,int y,int z)
			{
				this.x = x;
				this.y = y;
				this.z = z;
			}

			public  int compareTo(triplet o)
			{
				int result = x.compareTo(o.x);
				if(result==0)
					result =  y.compareTo(o.y);
				if(result==0)
					result = z.compareTo(o.z);

				return result;
			}

			public boolean equlas(Object o)
			{
				if(o instanceof triplet)
				{
					triplet p = (triplet)o;
					return x==p.x && y==p.y && z==p.z;
				}
				return false;
			}

			public String toString()
			{
				return x+" "+y+" "+z;
			}
			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode() + new Long(z).hashCode();
			}
		}

		static class node implements Comparable<node>

		{
			Integer x, y, z;
			node(int x,int y, int z)
			{
				this.x=x;
				this.y=y;
				this.z=z;
			}

			public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);
				if(result==0)
					result = z.compareTo(z);
				return result;
			}

			@Override
			public int compareTo(node o) {
				// TODO Auto-generated method stub
				return 0;
			}
		}
	}


import java.util.*;
import java.io.*;
public class Solution {

    public static void main(String[] args) throws IOException{
       Scanner sc = new Scanner(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m,n;
        int nbm=0,nbn=0,nb=0;
        int jj=0;
        StringTokenizer st = new StringTokenizer(br.readLine());
        n = Integer.parseInt(st.nextToken());
        m = Integer.parseInt(st.nextToken());
        int[] a = new int[n];
        int[] b = new int[m];
         st = new StringTokenizer(br.readLine());
        for(int i=0;i<n;i++) a[i] = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(br.readLine());
        for(int i=0;i<m;i++) b[i] = Integer.parseInt(st.nextToken());
        for(int i=0;i<n;i++) {
            nbn += a[i];
            for(int j=jj;j<m;j++){
                if(nbm>=nbn) break;
                nbm += b[j];
                jj = j+1;
            }
            if(nbn==nbm){
                nbn = 0;
                nbm = 0;
                nb++;
            }
        }
        System.out.println(nb);
    }
}


import java.util.*;
import java.io.*;
public class Solution {

    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);

        int m,n;
        int nbm=0,nbn=0,nb=0;
        int jj=0;

        n = sc.nextInt();
        m = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for(int i=0;i<n;i++) a[i] = sc.nextInt();
        for(int i=0;i<m;i++) b[i] = sc.nextInt();
        for(int i=0;i<n;i++) {
            nbn += a[i];
            for(int j=jj;j<m;j++){
                if(nbm>=nbn) break;
                nbm += b[j];
                jj = j+1;
            }
            if(nbn==nbm){
                nbn = 0;
                nbm = 0;
                nb++;
            }
        }
        System.out.println(nb);
    }
}


import java.io.*;
import java.util.stream.Stream;

/**
 * @author madi.sagimbekov
 */
public class C950B {

    private static BufferedReader in;
    private static BufferedWriter out;

    public static void main(String[] args) throws IOException {
        open();

        int[] nm = readInts();
        int n = nm[0];
        int m = nm[1];

        int[] f = readInts();
        int[] s = readInts();

        int sum1 = 0;
        int sum2 = 0;
        int i = 0;
        int j = 0;
        int cnt = 1;

        while (i < n && j < m) {
            if (sum1 == sum2) {
                if (sum1 > 0) {
                    cnt++;
                }
                sum1 = f[i];
                sum2 = s[j];
                i++;
                j++;
            } else if (sum1 > sum2) {
                sum2 += s[j];
                j++;
            } else {
                sum1 += f[i];
                i++;
            }
        }

        out.write(cnt + "\n");

        close();
    }

    private static int[] readInts() throws IOException {
        return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }

    private static int readInt() throws IOException {
        return Integer.parseInt(in.readLine());
    }

    private static long[] readLongs() throws IOException {
        return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
    }

    private static long readLong() throws IOException {
        return Long.parseLong(in.readLine());
    }

    private static double[] readDoubles() throws IOException {
        return Stream.of(in.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
    }

    private static double readDouble() throws IOException {
        return Double.parseDouble(in.readLine());
    }

    private static String readString() throws IOException {
        return in.readLine();
    }

    private static void open() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new BufferedWriter(new OutputStreamWriter((System.out)));
    }

    private static void close() throws IOException {
        out.flush();
        out.close();
        in.close();
    }

}


import java.io.*;
import java.util.stream.Stream;

/**
 * @author madi.sagimbekov
 */
public class C950B {

    private static BufferedReader in;
    private static BufferedWriter out;

    public static void main(String[] args) throws IOException {
        open();

        int[] nm = readInts();
        int n = nm[0];
        int m = nm[1];

        int[] f = readInts();
        int[] s = readInts();

        int sum1 = 0;
        int sum2 = 0;
        int i = 0;
        int j = 0;
        int cnt = 1;

        while (i < n && j < n) {
            if (sum1 == sum2) {
                if (sum1 > 0) {
                    cnt++;
                }
                sum1 = f[i];
                sum2 = s[j];
                i++;
                j++;
            } else if (sum1 > sum2) {
                sum2 += s[j];
                j++;
            } else {
                sum1 += f[i];
                i++;
            }
        }

        out.write(cnt + "\n");

        close();
    }

    private static int[] readInts() throws IOException {
        return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }

    private static int readInt() throws IOException {
        return Integer.parseInt(in.readLine());
    }

    private static long[] readLongs() throws IOException {
        return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
    }

    private static long readLong() throws IOException {
        return Long.parseLong(in.readLine());
    }

    private static double[] readDoubles() throws IOException {
        return Stream.of(in.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
    }

    private static double readDouble() throws IOException {
        return Double.parseDouble(in.readLine());
    }

    private static String readString() throws IOException {
        return in.readLine();
    }

    private static void open() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new BufferedWriter(new OutputStreamWriter((System.out)));
    }

    private static void close() throws IOException {
        out.flush();
        out.close();
        in.close();
    }

}


import java.util.Scanner;

import java.util.Scanner;
public class MessShifr {

        public static void main(String[] args) {
            Scanner s = new Scanner(System.in);
            int n,m;
            System.out.println("Введите кол-во блоков в первом сообщении>>");
            n = s.nextInt();
            System.out.println("Введите кол-во блоков во втором сообщении>>");
            m = s.nextInt();
            int[] a1 = new int[n];
            int[] a2 = new int[m];
            for (int i = 0; i < n ; i++)
                a1[i] = s.nextInt();
            for (int i = 0; i < m ; i++)
                a2[i] = s.nextInt();
            int sum1=0,sum2=0;
            int count = 0;
            int i=0,j=0;
            for (i = 0; i<n ; i++)
                while(j<m){
                if (sum1+a1[i]>sum2+a2[j]) {sum2+=a2[j];j++;}
                    if (sum1+a1[i]<sum2+a2[j]) {sum1+=a1[i]; break;}
                    if(sum1+a1[i]==sum2+a2[j]) {count++;sum1+=a1[i];sum2+=a2[j];j++;break;}
                }

            System.out.println(count);

        }

}


import java.util.Scanner;

import java.util.Scanner;
public class MessShifr {

        public static void main(String[] args) {
            Scanner s = new Scanner(System.in);
            int n,m;
            n = s.nextInt();
            m = s.nextInt();
            int[] a1 = new int[n];
            int[] a2 = new int[m];
            for (int i = 0; i < n ; i++)
                a1[i] = s.nextInt();
            for (int i = 0; i < m ; i++)
                a2[i] = s.nextInt();
            int sum1=0,sum2=0;
            int count = 0;
            int i=0,j=0;
            for (i = 0; i<n ; i++)
                while(j<m){
                if (sum1+a1[i]>sum2+a2[j]) {sum2+=a2[j];j++;}
                    if (sum1+a1[i]<sum2+a2[j]) {sum1+=a1[i]; break;}
                    if(sum1+a1[i]==sum2+a2[j]) {count++;sum1=0;sum2=0;j++;break;}
                }

            System.out.println(count);

        }

}


import java.util.Scanner;

import java.util.Scanner;
public class MessShifr {

        public static void main(String[] args) {
            Scanner s = new Scanner(System.in);
            int n,m;
            System.out.println("Введите кол-во блоков в первом сообщении>>");
            n = s.nextInt();
            System.out.println("Введите кол-во блоков во втором сообщении>>");
            m = s.nextInt();
            int[] a1 = new int[n];
            int[] a2 = new int[m];
            for (int i = 0; i < n ; i++)
                a1[i] = s.nextInt();
            for (int i = 0; i < m ; i++)
                a2[i] = s.nextInt();
            int sum1=0,sum2=0;
            int count = 0;
            int i=0,j=0;
            for (i = 0; i<n ; i++)
                while(j<m){
                if (sum1+a1[i]>sum2+a2[j]) {sum2+=a2[j];j++;}
                    if (sum1+a1[i]<sum2+a2[j]) {sum1+=a1[i]; break;}
                    if(sum1+a1[i]==sum2+a2[j]) {count++;sum1=0;sum2=0;j++;break;}
                }

            System.out.println(count);

        }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class QuartersRound3 {

	public static void solve(FastScanner fs) {
		int n=fs.nextInt(), m=fs.nextInt();
		int[] a=fs.readArray(n), b=fs.readArray(m);
		HashSet<Long> csA=new HashSet<>();
		long total=0;
		for (int i:a) {
			total+=i;
			csA.add(total);
		}
		long total2=0, count=0;
		for (int i:b) {
			total2+=i;
			if (csA.contains(total2)) {
				count++;
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastScanner scanner = new FastScanner(System.in);
		solve(scanner);
	}

	private static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++)
				a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++)
				a[i]=nextLong();
			return a;
		}
	}
}


import java.io.*;
import java.util.*;

public class ProgEc {

	public static void main(String[] args) throws Exception {
		//FileInputStream inputStream = new FileInputStream("input.txt");
		//FileOutputStream outputStream = new FileOutputStream("output.txt");

		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;

		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);

		Solver solver = new Solver();
		solver.solve(1, in, out);

		out.close();
	}

	static class Solver {

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			int[] a = new int[n];
			int[] b = new int[m];
			for (int i = 0; i < n; i++)
				a[i] = in.nextInt();

			int ans = 0;
			int sum1 = 0;
			int sum2 = 0;
			int j = -1;
			for (int i = 0; i < m; i++) {
				b[i] = in.nextInt();
				sum2 += b[i];
				while (sum2 > sum1){
					j++;
					sum1 += a[j];
				}
				if (sum1 == sum2) {
					sum1 = 0;
					sum2 = 0;
					ans++;
				}
			}
			out.println(ans);
		}

		/*class MyString implements Comparable<MyString> {
			String str;

			MyString(String other) {
				str = other;
			}

			public int compareTo(MyString other) {
				return str.length() - other.str.length();
			}
		}*/

	}

	static class InputReader {

		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public float nextFloat() {
			return Float.parseFloat(next());
		}

	}
}


import java.util.*;
import java.io.*;
import java.math.*;

public class Tester {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int m=s.nextInt();
		int a[]=new int[n];
		int b[]=new int[m];
		int cnt=0;
		for(int i=0;i<n;i++)
			a[i]=s.nextInt();
		for(int j=0;j<m;j++)
			b[j]=s.nextInt();
		int i,j;
		i=1;j=1;
		int s1=a[0],s2=b[0];
		while(i<n && j<m)
		{
			if(s1==s2)
			{
				cnt++;
				s1=0;s2=0;
			}
			else if(s1<s2)
			{
				s1+=a[i];
				i++;
			}
			else
			{
				s2+=b[j];
				j++;
			}

		}
		System.out.println(cnt);

	}

}


import java.util.*;
import java.io.*;
import java.math.*;

public class Tester {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int m=s.nextInt();
		int a[]=new int[n];
		int b[]=new int[m];
		int cnt=0;
		for(int i=0;i<n;i++)
			a[i]=s.nextInt();
		for(int j=0;j<m;j++)
			b[j]=s.nextInt();
		int i,j;
		i=0;j=0;
		int s1=a[0],s2=b[0];
		while(i<n && j<m)
		{

		    if(s1<s2)
			{
		    	i++;
		    	if(i<n)
		    		s1+=a[i];

			}
			else if(s1>s2)
			{
				j++;
				if(j<m)
					s2+=b[j];

			}
			else
			{
				cnt++;
				i++;
				j++;
				if(i<n)
					s1=a[i];
				if(j<m)
					s2=b[j];
			}

		}
		System.out.println(cnt);

	}

}


import java.util.*;
import java.io.*;
public class tester
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int m=s.nextInt();
        int n=s.nextInt();
        int a[]=new int[m];
        int b[]=new int[n];
        for(int i=0;i<m;i++)
            a[i]=s.nextInt();
        for(int i=0;i<n;i++)
            b[i]=s.nextInt();
        int ans=0;
        int j=0,k=0;int s1=a[0],s2=b[0];
        while(j<m && k<n)
        {
            if(s1==s2)
            {
                ans++;
                j++;
                s1=a[j];
                k++;
                s2=b[k];
            }
            else if(s1>s2)
            {
                k++;
                s2+=b[k];
            }
            else
            {
                j++;
                s1+=a[k];
            }
        }
        System.out.println(ans);
    }
}


import java.util.*;
import java.io.*;
import java.math.*;

public class Tester {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int m=s.nextInt();
		int a[]=new int[n];
		int b[]=new int[m];
		int cnt=0;
		for(int i=0;i<n;i++)
			a[i]=s.nextInt();
		for(int j=0;j<m;j++)
			b[j]=s.nextInt();
		int i,j;
		i=1;j=1;
		int s1=a[0],s2=b[0];
		while(i<n && j<m)
		{
			if(s1==s2)
			{
				cnt++;
				i++;
				j++;
				s1=a[i];
				s2=b[j];
			}
			else if(s1<s2)
			{
				s1+=a[i];
				i++;
			}
			else
			{
				s2+=b[j];
				j++;
			}

		}
		System.out.println(cnt);

	}

}


import java.io.*;
public class B
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String in1[]=br.readLine().split(" ");
int n=Integer.parseInt(in1[0]);
int m=Integer.parseInt(in1[1]);
String in2[]=br.readLine().split(" ");
String in3[]=br.readLine().split(" ");
int ar1[]=new int[n];
int ar2[]=new int[m];
long pr1[]=new long[n];
long pr2[]=new long[m];
int i,j,k,min=Math.min(n,m);
ar1[0]=Integer.parseInt(in2[0]);
pr1[0]=ar1[0];
ar2[0]=Integer.parseInt(in3[0]);
pr2[0]=ar2[0];
for(i=1;i<min;i++)
{
ar1[i]=Integer.parseInt(in2[i]);
pr1[i]=pr1[i-1]+ar1[i];
ar2[i]=Integer.parseInt(in3[i]);
pr2[i]=pr2[i-1]+ar2[i];
}
if(n==1 || m==1)
{
System.out.println(1);
return;
}
int cnt=0;
j=0;
k=0;
while(j<n && k<m)
{
while(j<n && k<m && pr1[j]!=pr2[k] )
{
if(pr1[j]<pr2[k])
j++;
else
k++;
}
j++;
k++;
cnt++;
}
System.out.println(cnt);
}
}


import java.io.*;
public class B
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String in1[]=br.readLine().split(" ");
int n=Integer.parseInt(in1[0]);
int m=Integer.parseInt(in1[1]);
String in2[]=br.readLine().split(" ");
String in3[]=br.readLine().split(" ");
int ar1[]=new int[n];
int ar2[]=new int[m];
long pr1[]=new long[n];
long pr2[]=new long[m];
int i,j,k;
ar1[0]=Integer.parseInt(in2[0]);
pr1[0]=ar1[0];
ar2[0]=Integer.parseInt(in3[0]);
pr2[0]=ar2[0];
for(i=1;i<n;i++)
{
ar1[i]=Integer.parseInt(in2[i]);
pr1[i]=pr1[i-1]+ar1[i];
}
for(i=1;i<m;i++){
ar2[i]=Integer.parseInt(in3[i]);
pr2[i]=pr2[i-1]+ar2[i];
}
if(n==1 || m==1)
{
System.out.println(1);
return;
}
int cnt=0;
j=0;
k=0;
while(j<n && k<m)
{
while(j<n && k<m && pr1[j]!=pr2[k] )
{
if(pr1[j]<pr2[k])
j++;
else
k++;
}
j++;
k++;
cnt++;
}
System.out.println(cnt);
}
}


import java.util.Scanner;

public class Dev2B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[m];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            y[i] = sc.nextInt();
        }
        int total = 0;
        int i = 0, j = 0;
        int sumI = x[0], sumJ = y[0];
        int lastCounted = 0;
        while (i < n && j < m) {
            if (sumI < sumJ) {
                i++;
                while (i < n && sumI < sumJ) {
                    sumI += x[i];
                    i++;
                }
//                System.out.println(sumI + " " + sumJ);
                if (sumI == sumJ) {
                    if (i < n) sumI = x[i];
                    j++;
                    if (j < m) sumJ = y[j];
                }
                if (i > lastCounted) {
                    total++;
                    lastCounted = i;
                }

            } else {
                j++;
                while (j < m && sumJ < sumI) {
                    sumJ += y[j];
                    j++;
                }
//                System.out.println(sumI + " " + sumJ);
                if (sumI == sumJ) {
                    if (j < m ) sumJ = y[j];
                    i++;
                    if (i < n) sumI = x[i];
                }
                if (j > lastCounted) {
                    total++;
                    lastCounted = j;
                }
            }
        }
        System.out.println(total);
    }
}


import java.util.Scanner;

public class Dev2B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[m];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            y[i] = sc.nextInt();
        }
        int total = 0;
        int i = 0, j = 0;
        int sumI = 0, sumJ = 0;
        while (i < n && j < m) {
            if (sumI <= sumJ) sumI+=x[i++];
            else sumJ+=y[j++];
            if (sumI == sumJ) total++;
        }
        System.out.println(total + 1);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class B {
    static final int MAXN = 100005;
    static int [] a = new int [MAXN];
    static int [] b = new int [MAXN];
    static int n, m;
    public static void main(String[] args) throws IOException {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        in.nextToken(); n = (int)in.nval;
        in.nextToken(); m = (int)in.nval;

        for(int i = 0; i< n; i++){
            in.nextToken(); a[i] = (int)in.nval;
        }
        for(int i = 0; i < m; i++){
            in.nextToken(); b[i] = (int)in.nval;
        }
        out.println(solve());
        out.flush();
    }

    private static int solve(){
        int num = 0;
        long a1 = a[0], b1 = b[0];
        int i = 1, j = 1;
        while(i < n && j < m){
            System.out.println("一直运行？？？" + " i = " + i + " j = " + j  + " a1 == b1 ? " + (a1 == b1) + " num = " + num);
            if(a1 == b1){
                num++;
                a1 += a[i++];
                b1 += b[j++];
            }
            while(a1 < b1 && i < n){
                a1 += a[i++];
            }

            while(b1 < a1 && j < m){
                b1 += b[j++];
            }
        }

        return num + 1;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class B {
    static final int MAXN = 100005;
    static int [] a = new int [MAXN];
    static int [] b = new int [MAXN];
    static int n, m;
    public static void main(String[] args) throws IOException {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        in.nextToken(); n = (int)in.nval;
        in.nextToken(); m = (int)in.nval;

        for(int i = 0; i< n; i++){
            in.nextToken(); a[i] = (int)in.nval;
        }
        for(int i = 0; i < m; i++){
            in.nextToken(); b[i] = (int)in.nval;
        }
        out.println(solve());
        out.flush();
    }

    private static int solve(){
        int num = 0;
        long a1 = 0, b1 = 0;
        int i = 0, j = 0;
        while(i < n && j < m){
            if(a1 == b1){
                num++;
                a1 += a[i++];
                b1 += b[j++];
            }
            while(a1 < b1 && i < n){
                a1 += a[i++];
            }

            while(b1 < a1 && j < m){
                b1 += b[j++];
            }
        }
//        System.out.println("i = " + i + " j = " + j);
        return num;
    }
}


import java.io.*;
import java.util.*;

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            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 nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static ArrayList<Integer> tab=new ArrayList<>();
    static ArrayList<Integer> tab2=new ArrayList<>();
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        int n=s.nextInt();
        int m=s.nextInt();
        for (int i=0;i<n;i++) {
        	tab.add(s.nextInt());
        }
        for (int i=0;i<m;i++) {
        	tab2.add(s.nextInt());
        }

        int i=1;
        int j=1;
        int sum1=tab.get(0),sum2=tab2.get(0);
        int nb=0;
        int k=0;
        while (i < n && j<m &&  k<10) {
        	k++;
        	if (sum1>sum2) {
        		sum2+=tab2.get(j);
        		j++;
        		if (sum1==sum2) {
        			nb++;
        			i++;
        			sum1=tab.get(i);
            		sum2=tab2.get(j);
            		if (i<n) i++;
            		if (j<m) j++;
        		}
        	}
        	else if (sum1<sum2){
        		sum1+=tab.get(i);
        		i++;
        		if (sum1==sum2) {
        			nb++;
        			sum1=tab.get(i);
            		sum2=tab2.get(j);
            		if (i<n) i++;
            		if (j<m) j++;
        		}
        	}
        	else {
        		nb++;
    			sum1=tab.get(i);
        		sum2=tab2.get(j);
        	}
        }

        System.out.println(nb+1);

    }
}


import java.io.*;
import java.util.*;

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            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 nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static ArrayList<Integer> tab=new ArrayList<>();
    static ArrayList<Integer> tab2=new ArrayList<>();
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        int n=s.nextInt();
        int m=s.nextInt();
        for (int i=0;i<n;i++) {
        	tab.add(s.nextInt());
        }
        for (int i=0;i<m;i++) {
        	tab2.add(s.nextInt());
        }

        int i=1;
        int j=1;
        int sum1=tab.get(0),sum2=tab2.get(0);
        int nb=0;
        int k=0;
        while (i < n && j<m &&  k<10) {
        	k++;
        	if (sum1>sum2) {
        		sum2+=tab2.get(j);
        		j++;
        		if (sum1==sum2) {
        			nb++;
        			i++;
        			sum1=tab.get(i);
            		sum2=tab2.get(j);
            		if (i<n) i++;
            		if (j<m) j++;
        		}
        	}
        	else if (sum1<sum2){
        		sum1+=tab.get(i);
        		i++;
        		if (sum1==sum2) {
        			nb++;
        			sum1=tab.get(i);
            		sum2=tab2.get(j);
            		if (i<n) i++;
            		if (j<m) j++;
        		}
        	}
        	else {
        		nb++;
    			sum1=tab.get(i);
        		sum2=tab2.get(j);
        		j++;
        		i++;
        	}
        	//System.out.println("nb="+nb);
        	//System.out.println(sum1+" "+sum2);
        }

        System.out.println(nb+1);

    }
}


import java.io.*;
import java.util.*;

public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            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 nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static ArrayList<Integer> tab=new ArrayList<>();
    static ArrayList<Integer> tab2=new ArrayList<>();
    public static void main(String[] args)
    {
        FastReader s=new FastReader();
        int n=s.nextInt();
        int m=s.nextInt();
        for (int i=0;i<n;i++) {
        	tab.add(s.nextInt());
        }
        for (int i=0;i<m;i++) {
        	tab2.add(s.nextInt());
        }

        int i=1;
        int j=1;
        int sum1=tab.get(0),sum2=tab2.get(0);
        int nb=0;
        while (i < n && j<m) {
        	//System.out.println("avant :"+ sum1+" "+sum2);
        	if (sum1>sum2) {
        		sum2+=tab2.get(j);
        		j++;
        		if (sum1==sum2) {
        			nb++;
        			sum1=tab.get(i);
            		sum2=tab2.get(j);
            		if (i<n) i++;
            		if (j<m) j++;
        		}
        	}
        	else if (sum1<sum2){
        		sum1+=tab.get(i);
        		i++;
        		if (sum1==sum2) {
        			nb++;
        			sum1=tab.get(i);
            		sum2=tab2.get(j);
            		if (i<n) i++;
            		if (j<m) j++;
        		}
        	}
        	else {
        		nb++;
    			sum1=tab.get(i);
        		sum2=tab2.get(j);
        		j++;
        		i++;
        	}
        	//System.out.println("nb="+nb);
        	//System.out.println(sum1+" "+sum2+" i:"+i+" j:"+j);
        }

        System.out.println(nb+1);

    }
}


//package ishan;
//import java.util.Arrays;
import java.util.Scanner;

public class classy
{
	static int[][] matrix;
	static int nonce=0;
	static int[] arr;
	static int[] brr;
	static StringBuffer buff;

	public static void printMatrix(int[][] nice)
	{
		for(int i=0;i<nice.length;i++)
		{	for(int j=0;j<nice[0].length;j++)
				System.out.print(nice[i][j]+" ");
			System.out.println();
		}
	}

	public static int func()
	{
		int index1=0;
		int index2=0;
		int counter=0;
		while(index1<arr.length && index2<brr.length)
		{	if(arr[index1]<brr[index2])
			{	if(index1+1<arr.length)
					arr[index1+1]+=arr[index1++];
			}
			else if(brr[index2]<arr[index1])
			{	if(index2+1<brr.length)
					brr[index2+1]+=brr[index2++];
			}
			else										//equal case
			{	counter++;
				index1++;
				index2++;
			}
		}
		return counter;
	}

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int m=sc.nextInt();
		int n=sc.nextInt();
		arr=new int[m];
		brr=new int[n];

		for(int i=0;i<m;i++)
			arr[i]=sc.nextInt();
		for(int i=0;i<n;i++)
			brr[i]=sc.nextInt();
		int ans=func();

		System.out.println(ans);

	}
}


import java.io.*;
import java.security.acl.LastOwnerException;
import java.util.*;

import static java.lang.Math.*;

public class bigo1 {

    public static TreeSet<String> hs;
    public static ArrayList<Integer> graph[];
    public static int []c ;
    public static InputReader in;
    public static PrintWriter out;
    // public static long memory[][][] = new long[105][2][2];
    public static String b;
    public static int n , k ,x;
    public static void main(String[] args) throws IOException {

        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        in = new InputReader(System.in);
        out = new PrintWriter(System.out);

        int n = in.nextInt();
        int m = in.nextInt();
        int []a = new int[n];
        int []b = new int[m];
        for (int i = 0 ;i<n;i++)
        {
            a[i] = in.nextInt();
        }
        for (int  j = 0 ;j<m;j++)
        {
            b[j] = in.nextInt();
        }
        int p1 = 1;
        int p2 = 1 ;

        int sum = a[0] - b[0];
        int ans = 1;
        while (p1<n && p2<m)
        {
            if(sum == 0)
            {
                sum = a[p1++] - b[p2++];
                ans++;
            }
            else if(sum<0)
            {
                sum+=a[p1++];
            }else
            {
                sum -=b[p2++];
            }
        }
        out.print(ans);

        out.close();

    }

    public static long gcd(long x, long y) {
        if (x == 0)
            return y;
        else
            return gcd( y % x,x);
    }
    public static long mod = 1000000007, inf = 100000000000000000l;
    public static long fac[],inv[];
    public static void cal()
    {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0]=1;
        inv[0]=1;
        for(int i=1; i<=1000000; i++)
        {
            fac[i]=(fac[i-1]*i)%mod;
            inv[i]=(inv[i-1]*modPow(i,mod-2,mod))%mod;

        }
    }
    public static long ncr(int n, int r)
    {
        return (((fac[n]*inv[r])%mod)*inv[n-r])%mod;
    }
    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result =1;
        while(exp > 0)
        {
            if(exp % 2== 1)
            {
                result = (result * base) % mod;
                exp --;
            }
            else
            {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ProblemBInterceptedMessage solver = new ProblemBInterceptedMessage();
        solver.solve(1, in, out);
        out.close();
    }

    static class ProblemBInterceptedMessage {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int m = in.scanInt();

            long ans = 0;
            int arr1[] = new int[n];
            int arr2[] = new int[m];
            for (int i = 0; i < n; i++) arr1[i] = in.scanInt();
            for (int i = 0; i < m; i++) arr2[i] = in.scanInt();

            int p1 = 1;
            int p2 = 1;
            long t1 = 0;
            long t2 = 0;

            t1 = arr1[0];
            t2 = arr2[0];

            while (p1 < n && p2 < m) {

                if (t1 == t2) {
                    ans++;

                    t1 = arr1[p1];
                    t2 = arr2[p2];
                    p1++;
                    p2++;
                } else if (t1 > t2) {
                    t2 += arr2[p2];
                    p2++;

                } else {
                    t1 += arr1[p1];
                    p1++;
                }
            }

            while (p1 < n) {
                t1 += arr1[p1];
                if (t1 == t2) {
                    ans++;
                    break;
                }
                p1++;
            }

            while (p2 < m) {
                t2 += arr2[p2];
                if (t1 == t2) {
                    ans++;
                    break;
                }
                p2++;
            }

            out.println(ans);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int Total_Char;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= Total_Char) {
                index = 0;
                try {
                    Total_Char = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (Total_Char <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ProblemBInterceptedMessage solver = new ProblemBInterceptedMessage();
        solver.solve(1, in, out);
        out.close();
    }

    static class ProblemBInterceptedMessage {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {

            int n = in.scanInt();
            int m = in.scanInt();
            long ans = 0;
            int arr1[] = new int[n];
            int arr2[] = new int[m];
            for (int i = 0; i < n; i++) arr1[i] = in.scanInt();
            for (int i = 0; i < m; i++) arr2[i] = in.scanInt();

            int p1 = 1;
            int p2 = 1;
            long t1 = 0;
            long t2 = 0;

            t1 = arr1[0];
            t2 = arr2[0];
            while (p1 < n && p2 < m) {
                if (t1 == t2) {
                    ans++;
                    t1 = arr1[p1];
                    t2 = arr2[p2];
                    p1++;
                    p2++;
                } else if (t1 > t2) {
                    t2 += arr2[p2];
                    p2++;

                } else {
                    t1 += arr1[p1];
                    p1++;
                }
            }

            while (p1 < n) {
                t1 += arr1[p1];
                if (t1 == t2) {
                    ans++;
                    break;
                }
                p1++;
            }
            while (p2 < m) {
                t2 += arr2[p2];
                if (t1 == t2) {
                    ans++;
                    break;
                }
                p2++;
            }

            if (p1 == n && p2 == m) {
                if (t1 == t2) ans++;
            }
            out.println(ans);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int Total_Char;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= Total_Char) {
                index = 0;
                try {
                    Total_Char = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (Total_Char <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class NewMain {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner ip = new Scanner(System.in);
        int n = ip.nextInt();
        int m = ip.nextInt();
        ArrayList<Integer> first = new ArrayList<>();
        ArrayList<Integer> second = new ArrayList<>();
        for(int i = 0; i < n; i++)
        {
            first.add(ip.nextInt());
        }
        for(int i = 0; i < m; i++)
        {
            second.add(ip.nextInt());
        }
        int sumx = 0;
        int sumy = 0;
        int files = 0;
        int i, j;
        for(i = 0, j = 0; i < n || j < m; i++, j++)
        {
            sumx = first.get(i);
            sumy = second.get(j);
            while(true)
            {
                if(sumx != sumy)
                {
                    if(sumx < sumy)
                    {
                        sumx += first.get(++i);
                    }
                    else
                    {
                        sumy += second.get(++j);
                    }
                }
                else
                {
                    break;
                }
            }
            if(sumx == sumy)
            {
                files++;
            }
        }
        System.out.println(files);

    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.HashMap;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class NewMain {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner ip = new Scanner(System.in);
        int n = ip.nextInt();
        int m = ip.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for(int i = 0; i < n ;i++)
        {
            a[i] = ip.nextInt();
        }
        for(int i = 0; i < m ;i++)
        {
            b[i] = ip.nextInt();
        }
        HashMap<Long, Integer> checka = new HashMap<>();
        long sum;
        for(int i = 0; i < n; i++)
        {
            sum = 0;
            if(n == 1)
            {
                sum += a[i];
                checka.put(sum, 0);
            }
            else
            {
                for(int j = i + 1; j < n; j++)
                {
                    sum += a[i] + a[j];
                    checka.put(sum, 0);
                }
            }
        }
        HashMap<Long, Integer> checkb = new HashMap<>();

        for(int i = 0; i < m; i++)
        {
            sum = 0;
            if(m == 1)
            {
                sum += b[i];
                checkb.put(sum, 0);
            }
            else
            {
                for(int j = i + 1; j < m; j++)
                {
                    sum += b[i] + b[j];
                    checkb.put(sum, 0);
                }
            }

        }
        int count = 0;
        for(long temp : checka.keySet())
        {
            if(checkb.containsKey(temp))
            {
                count++;

            }
        }
        System.out.println(count);
    }

}


//package mar18;

import java.io.ByteArrayInputStream;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Rnd469 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	//boolean codechef=true;
	boolean codechef=true;
	void solve()
	{
		int n=ni(),m=ni();
		int[] x=na(n);
		int[] y=na(m);
		int i=0,j=0;
		int cnt=0;
		while(i<n && j<m)
		{
		   //System.out.println(i+" "+j);

			int currx=x[i],curry=y[j];
			//System.out.println(currx+" "+curry);
			boolean ch1=false,ch2=false;

			while(currx!=curry)
			{
				while(currx>curry)
				{
					j++;
					if(j>=m)break;
					curry+=y[j];
					ch1=true;
				}

				while(curry>currx)
				{
					i++;
					if(i>=n)break;
					currx+=x[i];
					ch2=true;
				}
			}
			i++;j++;
			//System.out.println("i:"+i+" "+j);

			cnt++;
		}
		out.println(cnt);
	}

	static int pow(int a, int b, int p)
	{
		long ans = 1, base = a;
		while (b!=0)
		{
			if ((b & 1)!=0)
			{
				ans *= base;
				ans%= p;
			}
			base *= base;
			base%= p;
			b >>= 1;
		}
		return (int)ans;
	}

	static int inv(int x, int p)
	{
		return pow(x, p - 2, p);
	}

	void run() throws Exception
	{
		if(codechef)oj=true;
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception {new Rnd469().run();}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


//package mar18;

import java.io.ByteArrayInputStream;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Rnd469 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	//boolean codechef=true;
	boolean codechef=true;
	void solve()
	{
		int n=ni(),m=ni();
		int[] x=na(n);
		int[] y=na(m);
		int i=0,j=0;
		int cnt=0;
		while(i<n && j<m)
		{
		   //System.out.println(i+" "+j);

			int currx=x[i],curry=y[j];
			//System.out.println(currx+" "+curry);
			boolean ch1=false,ch2=false;

			while(currx>curry)
			{
				j++;
				if(j>=m)break;
				curry+=y[j];
				ch1=true;
			}

			while(curry>currx)
			{
				i++;
				if(i>=n)break;
				currx+=x[i];
				ch2=true;
			}
			i++;j++;
			//System.out.println("i:"+i+" "+j);

			cnt++;
		}
		out.println(cnt);
	}

	static int pow(int a, int b, int p)
	{
		long ans = 1, base = a;
		while (b!=0)
		{
			if ((b & 1)!=0)
			{
				ans *= base;
				ans%= p;
			}
			base *= base;
			base%= p;
			b >>= 1;
		}
		return (int)ans;
	}

	static int inv(int x, int p)
	{
		return pow(x, p - 2, p);
	}

	void run() throws Exception
	{
		if(codechef)oj=true;
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception {new Rnd469().run();}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


//package mar18;

import java.io.ByteArrayInputStream;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Rnd469 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	//boolean codechef=true;
	boolean codechef=true;
	void solve()
	{
		int n=ni(),m=ni();
		int[] x=na(n);
		int[] y=na(m);
		int i=0,j=0;
		int cnt=0;
		while(i<n && j<m)
		{
			//System.out.println(i+" "+j);

			int currx=x[i],curry=y[j];
			boolean ch1=false,ch2=false;

			while(currx>curry)
			{
				j++;
				if(j>=m)break;
				curry+=y[j];
				ch1=true;
			}
			//System.out.println(currx+" "+curry);
			while(curry>currx)
			{
				i++;
				if(i>=n)break;
				currx+=x[i];
				ch2=true;
			}
			i++;j++;
			//System.out.println("i:"+i+" "+j);
			if(i==n-1 && j==m-1)break;
			cnt++;
		}
		out.println(cnt);
	}

	static int pow(int a, int b, int p)
	{
		long ans = 1, base = a;
		while (b!=0)
		{
			if ((b & 1)!=0)
			{
				ans *= base;
				ans%= p;
			}
			base *= base;
			base%= p;
			b >>= 1;
		}
		return (int)ans;
	}

	static int inv(int x, int p)
	{
		return pow(x, p - 2, p);
	}

	void run() throws Exception
	{
		if(codechef)oj=true;
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception {new Rnd469().run();}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


//package mar18;

import java.io.ByteArrayInputStream;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Rnd469 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	//boolean codechef=true;
	boolean codechef=true;
	void solve()
	{
		int n=ni(),m=ni();
		int[] x=na(n);
		int[] y=na(m);
		int i=0,j=0;
		int cnt=0;
		while(i<n && j<m)
		{
			//System.out.println(i+" "+j);

			int currx=x[i],curry=y[j];
			boolean ch1=false,ch2=false;

			while(currx>curry)
			{
				j++;
				if(j<m)curry+=y[j];
				ch1=true;
			}
			//System.out.println(currx+" "+curry);
			while(curry>currx)
			{
				i++;
				if(i<n)currx+=x[i];
				ch2=true;
			}
			i++;j++;
			//System.out.println("i:"+i+" "+j);
			if(i==n-1 && j==m-1)break;
			cnt++;
		}
		out.println(cnt);
	}

	static int pow(int a, int b, int p)
	{
		long ans = 1, base = a;
		while (b!=0)
		{
			if ((b & 1)!=0)
			{
				ans *= base;
				ans%= p;
			}
			base *= base;
			base%= p;
			b >>= 1;
		}
		return (int)ans;
	}

	static int inv(int x, int p)
	{
		return pow(x, p - 2, p);
	}

	void run() throws Exception
	{
		if(codechef)oj=true;
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception {new Rnd469().run();}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.*;
import java.util.*;

public class MainClass
{
    public static void main(String[] args)throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int m = in.nextInt();
        int[] A = new int[n];
        int[] B = new int[m];
        for (int i=0;i<n;i++)   A[i] = in.nextInt();
        for (int i=0;i<m;i++)   B[i] = in.nextInt();
        long[] C = new long[n];
        long[] D = new long[m];
        C[0] = A[0];    D[0] = B[0];
        for (int i=1;i<n;i++)   C[i] = C[i - 1] + A[i];
        for (int i=1;i<m;i++)   D[i] = D[i - 1] + B[i];
        int i = 0;
        int j = 0;
        int count = 0;
        while (i < n && j < m)
        {
            if (C[i] == D[j])
            {
                ++ i;
                ++ j;
                ++ count;
            }
            else if (C[i] > D[j])
            {
                ++ j;
            }
            else
                ++ i;
        }
        System.out.println(count);
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


	// _________________________RATHOD_____________________________________________________________
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            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 nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args)
    {
        FastReader sc=new FastReader();
        int n=sc.nextInt();
        int m=sc.nextInt();
        long ar1[]=new long[n];
        long ar2[]=new long[m];
        for(int i=0;i<n;i++)
        ar1[i]=sc.nextLong();
        for(int i=0;i<m;i++)
        ar2[i]=sc.nextLong();
        int i,j;
        i=-1;j=-1;
        long sum1=0;
        long sum2=0;
        int ans=0;
        while(i<n&&j<m)
        {
         if(sum1==sum2)
         {
             ans++;
             sum1=0;
             sum2=0;
             i++;
             j++;
             if(i<n&&j<m)
             {
               sum1=ar1[i];
               sum2=ar2[j];
             }

         }
         else if(sum1<sum2)
         {
             i++;
             sum1=sum1+ar1[i];
         }
         else
         {
            j++;
            sum2=sum2+ar2[j];
         }

        }
        System.out.println(ans-1);

    }

}


import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n,m;
        n=input.nextInt();
        m=input.nextInt();
        List<Integer> msg1 = new ArrayList<>();
        List<Integer> msg2 = new ArrayList<>();
        int files=0;
        int msgBlocks1=0,msgBlocks2=0;
        for (int i=0;i<n;i++){
            msg1.add(input.nextInt());
        }
        for (int j=0;j<m;j++){
            msg2.add(input.nextInt());
        }
        int k=0,i=0;
        boolean increase1 = false;
        boolean increase2 = false;
        while(k<n){
            if (msgBlocks1==0){
                msgBlocks1 = msg1.get(k);
            }else if (increase1){
                msgBlocks1 =msgBlocks1+ msg1.get(k);
            }
            if (msgBlocks2==0){
                msgBlocks2 = msg2.get(i);
            }else if (increase2){
                msgBlocks2 = msgBlocks2+msg2.get(i);
            }

            if (msgBlocks1==msgBlocks2){
                files++;
                k++;i++;
                msgBlocks1=0;
                msgBlocks2=0;
            }else if (msgBlocks1<msgBlocks2){
                k++;
                increase1 = true;
                increase2=false;
            }else if (msgBlocks2<msgBlocks1){
                i++;
                increase2 = true;
                increase1=false;
            }
        }
        System.out.println(files);

    }
}


import java.util.Scanner;

public class DiplomaCodeforces {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[m];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

        }

        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();

        }
        int cnt = 0;
        int i = 1;
        int j = 1;
        int suma = a[0];
        int sumb = b[0];

        while (i < n || j < m) {
            // System.out.println(suma + " " + sumb);
            if (suma == sumb) {
                cnt++;
                suma = a[i];
                sumb = b[j];
                i++;
                j++;
            } else if (suma > sumb) {
                sumb += b[j];
                j++;
            } else {
                suma += a[i];
                // System.out.println(a[i] + " here " + suma);
                i++;
            }
        }
        if (suma == sumb) {
            cnt++;
        }
        System.out.println(cnt);
    }
}


import java.util.Scanner;

public class DiplomaCodeforces {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[m];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

        }

        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();

        }
        int cnt = 0;
        int i = 1;
        int j = 1;
        int suma = a[0];
        int sumb = b[0];

        while (i < n && j < m) {
            // System.out.println(suma + " " + sumb);
            if (suma == sumb) {
                cnt++;
                suma = a[i];
                sumb = b[j];
                i++;
                j++;
            } else if (suma > sumb) {
                sumb += b[j];
                j++;
            } else {
                suma += a[i];
                // System.out.println(a[i] + " here " + suma);
                i++;
            }
        }
        if (i < n || j < m) {
            cnt++;
        }
        System.out.println(cnt);
    }
}


 import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.util.regex.*;
public class Myclass {

	public static void main(String[] args) {

		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n=in.nextInt();
		int m=in.nextInt();
		LinkedList<Long> v=new LinkedList<>();
		LinkedList <Long> v1=new LinkedList<>();
		long sum=0,sum1=0;
		long count=0;
		for(int i=0;i<n;i++)
		{
			v.add(in.nextLong());
		}
		for(int i=0;i<m;i++)
		{
			v1.add(in.nextLong());
		}
		sum1=v1.removeFirst();
		sum=v.removeFirst();
		while(v.size()!=0 && v1.size()!=0)
		{
			if(sum1>sum)
			{
				sum+=v.removeFirst();
			}
			else if(sum1<sum)
			{
				sum1+=v1.removeFirst();
			}
			else if(sum1==sum)
			{
				count++;
				if(v.size()!=0 && v1.size()!=0)
				{
					sum1=v1.removeFirst();
					sum=v.removeFirst();
				}
				else
					break;
			}
		}

		pw.println(count+1);
		pw.flush();
		pw.close();
	}
		static class InputReader
		{
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}
}


 import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.util.regex.*;
public class Myclass {

	public static void main(String[] args) {

		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n=in.nextInt();
		int m=in.nextInt();
		LinkedList<Long> v=new LinkedList<>();
		LinkedList <Long> v1=new LinkedList<>();
		long sum=0,sum1=0;
		long count=0;
		for(int i=0;i<n;i++)
		{
			v.add(in.nextLong());
		}
		for(int i=0;i<m;i++)
		{
			v1.add(in.nextLong());
		}
		sum1=v1.removeFirst();
		sum=v.removeFirst();
		while(v.size()!=0 && v1.size()!=0)
		{
			if(sum1>sum)
			{
				sum+=v.removeFirst();
			}
			else if(sum1<sum)
			{
				sum1+=v1.removeFirst();
			}
			else if(sum1==sum)
			{
				pw.println(v.size()+" "+v1.size());
				count++;
				if(v.size()!=0 && v1.size()!=0)
				{
					sum1=v1.removeFirst();
					sum=v.removeFirst();
				}
				else
					break;
			}
		}

		pw.println(count+1);
		pw.flush();
		pw.close();
	}
		static class InputReader
		{
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

public class Codechef
{

    public static void main (String[] args) throws java.lang.Exception
    {       Scanner in = new Scanner(System.in);

        int n,m,k=0,x=0,y=0,z,ans=0;
        n = in.nextInt();
        m = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i< n; i++)
            a[i] = in.nextInt();
        for( int i=0 ; i<m; i++){
            z = in.nextInt();
            y+=z;
            while(y>x)
                x+=a[k++];
            if(y==x) ans++;
        }
        System.out.println(ans);

}

}


// stay positive
//Woods are dark , deep and lovely  , I have  promises to keep and miles to
// go before I sleep :(
// stopping by wood on a snowy evening
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{

		int  n , m , ans= 0 ;
		Scanner in = new Scanner (System.in) ;
		n = in.nextInt() ;m = in.nextInt() ;
		int arr1[] = new int [ n +1] ; int arr2 []= new  int [ m +1] ;
		for ( int i = 1 ; i <= n ; i ++ )
		{
			arr1 [ i ] = in.nextInt() ;
			arr1 [ i ] += arr1 [ i - 1 ] ;
		}

		for ( int i = 1 ; i <= m ; i ++ )
		{
			arr2 [ i ] = in.nextInt() ;
			arr2 [ i ] += arr2 [ i - 1 ] ;
		}
		for ( int i = 1 ; i <= n ; i ++ )
		{
			if ( Arrays.binarySearch ( arr2 , arr1 [ i ] )>=0)
				ans ++ ;
		}
		System.out.println(ans ) ;

	}
}


import java.util.*;
import java.io.*;

public class p950B {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer st = new StringTokenizer(f.readLine());
		int s1 = Integer.parseInt(st.nextToken());
		int s2 = Integer.parseInt(st.nextToken());
		int[] a = load(s1, f.readLine());
		int[] b = load(s2, f.readLine());
		int i1, i2, sum1, sum2;
		i1 = i2 = sum1 = sum2 = 0;
		int result = -1; // overcount 0
		while(i1 < s1 && i2 < s2)
		{
			System.out.println(sum1 + " " + sum2 + " " + result);
			if(sum1 == sum2)
			{
				result++;
				sum1 = a[i1++];
				sum2 = b[i2++];
			}
			else if(sum1 > sum2)
				sum2 += b[i2++];
			else
				sum1 += a[i1++];
		}
		out.println(result + 1);
		out.close();
	}

	public static int[] load(int size, String s)
	{
		StringTokenizer st = new StringTokenizer(s);
		int[] a = new int[size];
		for(int i = 0; i < size; i++)
			a[i] = Integer.parseInt(st.nextToken());
		return a;
	}
}


import java.util.*;
import java.io.*;

public class p950B {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer st = new StringTokenizer(f.readLine());
		int s1 = Integer.parseInt(st.nextToken());
		int s2 = Integer.parseInt(st.nextToken());
		int[] a = load(s1, f.readLine());
		int[] b = load(s2, f.readLine());
		int i1, i2, sum1, sum2;
		i1 = i2 = sum1 = sum2 = 0;
		int result = -1; // overcount 0
		while(i1 < s1 && i2 < s2)
		{
			if(sum1 == sum2)
			{
				result++;
				sum1 = a[i1++];
				sum2 = b[i2++];
			}
			else if(sum1 > sum2)
				sum2 += b[i2++];
			else
				sum1 += a[i1++];
		}
		out.println(result + 1);
		out.close();
	}

	public static int[] load(int size, String s)
	{
		StringTokenizer st = new StringTokenizer(s);
		int[] a = new int[size];
		for(int i = 0; i < size; i++)
			a[i] = Integer.parseInt(st.nextToken());
		return a;
	}
}


import java.util.*;
import java.io.*;

public class Solution2 {

    private void solve() throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        int ans = 0;
        int[] a = new int[n];
        int[] b = new int[m];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        for (int i = 0; i < m; i++) {
            b[i] = in.nextInt();
        }
        int sum1 = 0;
        int sum2 = 0;
        int i = 0;
        int j = 0;
        while (i < n || j < m) {
            if (sum1 < sum2) {
                sum1 += a[i];
                i++;
            }
            else if (sum1 > sum2) {
                sum2 += b[j];
                j++;
            }
            if (sum1 == sum2) {
                ans++;
                if (i < n) sum1 = a[i];
                else sum1 = 0;
                if (j < m) sum2 = b[j];
                else sum2 = 0;
                i++;
                j++;
            }
        }
        if (sum1 == sum2 && sum1 != 0) ans++;
        System.out.println(ans - 1);
    }

    private String filename = "";
    private PrintWriter out;
    MyScanner in;

    private void run() throws IOException {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    private class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

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

        public MyScanner(String fileTitle) throws IOException {
            this.br = new BufferedReader(new FileReader(fileTitle));
        }

        public String nextLine() throws IOException {
            String s = br.readLine();
            return s == null ? "-1" : s;
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return "-1";
                }
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public Integer nextInt() throws IOException {
            return Integer.parseInt(this.next());
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(this.next());
        }

        public Double nextDouble() throws IOException {
            return Double.parseDouble(this.next());
        }

        public void close() throws IOException {
            this.br.close();
        }
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Solution2().run();
    }
}