import java.io.*;
import java.util.*;
//I am fading.......
//read the question correctly (is y a vowel? what are the exact constraints?)
//look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
public class Main
{
	public static void main(String[] args) throws Exception
	{
		int n=ni();
		int[]a=nia(n);
		int ct1=0,ct2=0;
		for(int i=0; i<n; i++)
			if(a[i]==1)
				ct1++;
			else
				ct2++;
		int co1[]=new int[2*n];
		int co2[]=new int[2*n];
		for(int i=0,j=0,k=0; i<n; i++)
			if(a[i]==1) co1[j++]=i;
			else if(a[i]==2) co2[k++]=i;
		for(int i=ct1; i<2*n; i++)
			co1[i]=1000000;
		for(int i=ct2; i<2*n; i++)
			co2[i]=1000000;
		int con1[]=new int[n];
		int con2[]=new int[n];
		for(int i=0; i<n; i++)
		{
			if(i!=0)
			{
			con1[i]+=con1[i-1];
			con2[i]+=con2[i-1];
			}
			if(a[i]==1)
				con1[i]++;
			else
				con2[i]++;
		}
		int ans=0;
		for(int i=Math.max(ct1, ct2); i>0; i--)
		{
			int te1=0,te2=0;
			for(int k=0,l=0; ;)
			{
				pair mac1=new pair(),mac2=new pair();
				if(co1[k+i-1]<co2[l+i-1])
				{
					k+=i;
					l=con2[co1[k-1]];
					te1++;
					mac1.a=te1;
					mac1.b=te2;

				}
				else if(co1[k+i-1]>co2[l+i-1])
				{
					l+=i;
					k=con1[co2[l-1]];
					te2++;
					mac2.a=te1;
					mac2.b=te2;

				}
				else
					break;
				if(k==ct1&&l==ct2)
				{
					if(te1>te2&&mac1.a==te1&&mac1.b==te2)
					{
						pr(Math.max(te1, te2)+" "+i);
						ans++;
					}
					if(te1<te2&&mac2.a==te1&&mac2.b==te2)
					{
						pr(Math.max(te1, te2)+" "+i);
						ans++;
					}

					break;
				}
			}
		}
		sop(ans);
		System.out.print(output);
	}

	///////////////////////////////////////////
	///////////////////////////////////////////
	///template from here
	static class pair
	{
		int a,b;
		pair(){}
		pair(int c,int d){a=c;b=d;}
		@Override
		public int hashCode(){return (a+" "+b).hashCode();}
		@Override public boolean equals(Object c){if(a==((pair)c).a&&b==((pair)c).b)return true;return false;}
	}
	static interface combiner
	{
		public int combine(int a, int b);
	}
	static final int mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static Reader in=new Reader();
	static StringBuilder output=new StringBuilder();
	static Random rn=new Random();
	public static void sort(int[]a)
	{
		int te;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
				a[i]^=a[te];
				a[te]^=a[i];
				a[i]^=a[te];
			}
		}
		Arrays.sort(a);
	}
	public static void sort(long[]a)
	{
		int te;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
			a[i]^=a[te];
			a[te]^=a[i];
			a[i]^=a[te];
			}
		}
		Arrays.sort(a);
	}
	public static void sort(double[]a)
	{
		int te;
		double te1;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
			te1=a[te];
			a[te]=a[i];
			a[i]=te1;
			}
		}
		Arrays.sort(a);
	}
	public static void sort(int[][]a)
	{
		Arrays.sort(a, new Comparator<int[]>()
		{
			public int compare(int[]a,int[]b)
			{
				if(a[0]>b[0])
					return 1;
				if(b[0]>a[0])
					return -1;
				return 0;
			}
		});
	}
	static int lowerbound(int[]a, int key)
	{
		/*
		 * returns index of smallest element larger than equal to given element between indices l and r inclusive
		 */
		int low=0,high=a.length-1,mid=(low+high)/2;
		while(low<high)
		{
			if(a[mid] >= key)
				high=mid;
			else
				low=mid+1;
			mid=(low+high)/2;
		}
		return mid;
	}
	static int upperbound(int[]a, int key)
	{
		int low=0,high=a.length-1,mid=(low+high+1)/2;
		while(low<high)
		{
			if(a[mid] <= key)
				low=mid;
			else
				high=mid-1;
			mid=(low+high+1)/2;
		}
		return mid;
	}
	static int lowerbound(int[]a, int l, int r, int key)
	{
		int low=l,high=r,mid=(low+high)/2;
		while(low<high)
		{
			if(a[mid] >= key)
				high=mid;
			else
				low=mid+1;
			mid=(low+high)/2;
		}
		return mid;
	}
	static int upperbound(int[]a, int l, int r, int key)
	{
		/*
		 * returns index of largest element smaller than equal to given element
		 */
		int low=l,high=r,mid=(low+high+1)/2;
		while(low<high)
		{
			if(a[mid] <= key)
				low=mid;
			else
				high=mid-1;
			mid=(low+high+1)/2;
		}
		return mid;
	}

	void sort(pair[]a)
	{
		Arrays.sort(a,new Comparator<pair>()
				{
			@Override
			public int compare(pair a,pair b)
			{
				if(a.a>b.a)
					return 1;
				if(b.a>a.a)
				return -1;
				return 0;
			}
				});
	}
	static int log2n(long a)
	{
		int te=0;
		while(a>0)
		{
			a>>=1;
			++te;
		}
		return te;
	}
	static class vecti
	{
		int a[],size;
		vecti(){a=new int[10];size=0;}
		vecti(int n){a=new int[n];size=0;}
		public void add(int b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	static class vectl
	{
		long a[];
		int size;
		vectl(){a=new long[10];size=0;}
		vectl(int n){a=new long[n];size=0;}
		public void add(long b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	static class vectd
	{
		double a[];
		int size;
		vectd(){a=new double[10];size=0;}
		vectd(int n){a=new double[n];size=0;}
		public void add(double b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	//output functions////////////////
	static void pr(Object a){output.append(a+"\n");}
	static void pr(){output.append("\n");}
	static void p(Object a){output.append(a);}
	static void pra(int[]a){for(int i:a)output.append(i+" ");output.append("\n");}
	static void pra(long[]a){for(long i:a)output.append(i+" ");output.append("\n");}
	static void pra(String[]a){for(String i:a)output.append(i+" ");output.append("\n");}
	static void pra(double[]a){for(double i:a)output.append(i+" ");output.append("\n");}
	static void sop(Object a){System.out.println(a);}
	static void flush(){System.out.println(output);output=new StringBuilder();}
	//////////////////////////////////
	//input functions/////////////////
	static int ni(){return Integer.parseInt(in.next());}
	static long nl(){return Long.parseLong(in.next());}
	static String ns(){return in.next();}
	static double nd(){return Double.parseDouble(in.next());}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[] pnia(int n){int a[]=new int[n+1];for(int i=1; i<=n; i++)a[i]=ni();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double[] nda(int n){double a[]=new double[n];for(int i=0; i<n; i++)a[i]=nd();return a;}
	//////////////////////////////////
	//some utility functions
	static void exit(){System.exit(0);}
	static int min(int... a){int min=a[0];for(int i:a)min=Math.min(min, i);return min;}
	static int max(int... a){int max=a[0];for(int i:a)max=Math.max(max, i);return max;}
	static int gcd(int... a){int gcd=a[0];for(int i:a)gcd=gcd(gcd, i);return gcd;}
	static String pr(String a, long b){String c="";while(b>0){if(b%2==1)c=c.concat(a);a=a.concat(a);b>>=1;}return c;}
	static long powm(long a, long b, long m){long an=1;long c=a;while(b>0){if(b%2==1)an=(an*c)%m;c=(c*c)%m;b>>=1;}return an;}
	static int gcd(int a, int b){if(b==0)return a;return gcd(b, a%b);}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 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();
        }
    }
}


import java.io.*;
import java.util.*;
//I am fading.......
//read the question correctly (is y a vowel? what are the exact constraints?)
//look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
public class Main
{
	public static void main(String[] args) throws Exception
	{
		int n=ni();
		int[]a=nia(n);
		int ct1=0,ct2=0;
		for(int i=0; i<n; i++)
			if(a[i]==1)
				ct1++;
			else
				ct2++;
		int co1[]=new int[2*n];
		int co2[]=new int[2*n];
		for(int i=0,j=0,k=0; i<n; i++)
			if(a[i]==1) co1[j++]=i;
			else if(a[i]==2) co2[k++]=i;
		for(int i=ct1; i<2*n; i++)
			co1[i]=1000000;
		for(int i=ct2; i<2*n; i++)
			co2[i]=1000000;
		int con1[]=new int[n];
		int con2[]=new int[n];
		for(int i=0; i<n; i++)
		{
			if(i!=0)
			{
			con1[i]+=con1[i-1];
			con2[i]+=con2[i-1];
			}
			if(a[i]==1)
				con1[i]++;
			else
				con2[i]++;
		}
		int ans=0;
		for(int i=ct1; i>0; i--)
		{
			int te1=0,te2=0;
			for(int k=0,l=0; ;)
			{
				if(co1[k+i-1]<co2[l+i-1])
				{
					k+=i;
					l=con2[co1[k-1]];
					te1++;
				}
				else if(co1[k+i-1]>co2[l+i-1])
				{
					l+=i;
					k=con1[co2[l-1]];
					te2++;
				}
				else
					break;
				if(k==ct1&&l==ct2)
				{
					if(te1!=te2)
					{
						pr(Math.max(te1, te2)+" "+i);
						ans++;
					}
					break;
				}
			}
		}
		sop(ans);
		System.out.print(output);
	}

	///////////////////////////////////////////
	///////////////////////////////////////////
	///template from here
	static class pair
	{
		int a,b;
		pair(){}
		pair(int c,int d){a=c;b=d;}
		@Override
		public int hashCode(){return (a+" "+b).hashCode();}
		@Override public boolean equals(Object c){if(a==((pair)c).a&&b==((pair)c).b)return true;return false;}
	}
	static interface combiner
	{
		public int combine(int a, int b);
	}
	static final int mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static Reader in=new Reader();
	static StringBuilder output=new StringBuilder();
	static Random rn=new Random();
	public static void sort(int[]a)
	{
		int te;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
				a[i]^=a[te];
				a[te]^=a[i];
				a[i]^=a[te];
			}
		}
		Arrays.sort(a);
	}
	public static void sort(long[]a)
	{
		int te;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
			a[i]^=a[te];
			a[te]^=a[i];
			a[i]^=a[te];
			}
		}
		Arrays.sort(a);
	}
	public static void sort(double[]a)
	{
		int te;
		double te1;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
			te1=a[te];
			a[te]=a[i];
			a[i]=te1;
			}
		}
		Arrays.sort(a);
	}
	public static void sort(int[][]a)
	{
		Arrays.sort(a, new Comparator<int[]>()
		{
			public int compare(int[]a,int[]b)
			{
				if(a[0]>b[0])
					return 1;
				if(b[0]>a[0])
					return -1;
				return 0;
			}
		});
	}
	static int lowerbound(int[]a, int key)
	{
		/*
		 * returns index of smallest element larger than equal to given element between indices l and r inclusive
		 */
		int low=0,high=a.length-1,mid=(low+high)/2;
		while(low<high)
		{
			if(a[mid] >= key)
				high=mid;
			else
				low=mid+1;
			mid=(low+high)/2;
		}
		return mid;
	}
	static int upperbound(int[]a, int key)
	{
		int low=0,high=a.length-1,mid=(low+high+1)/2;
		while(low<high)
		{
			if(a[mid] <= key)
				low=mid;
			else
				high=mid-1;
			mid=(low+high+1)/2;
		}
		return mid;
	}
	static int lowerbound(int[]a, int l, int r, int key)
	{
		int low=l,high=r,mid=(low+high)/2;
		while(low<high)
		{
			if(a[mid] >= key)
				high=mid;
			else
				low=mid+1;
			mid=(low+high)/2;
		}
		return mid;
	}
	static int upperbound(int[]a, int l, int r, int key)
	{
		/*
		 * returns index of largest element smaller than equal to given element
		 */
		int low=l,high=r,mid=(low+high+1)/2;
		while(low<high)
		{
			if(a[mid] <= key)
				low=mid;
			else
				high=mid-1;
			mid=(low+high+1)/2;
		}
		return mid;
	}

	void sort(pair[]a)
	{
		Arrays.sort(a,new Comparator<pair>()
				{
			@Override
			public int compare(pair a,pair b)
			{
				if(a.a>b.a)
					return 1;
				if(b.a>a.a)
				return -1;
				return 0;
			}
				});
	}
	static int log2n(long a)
	{
		int te=0;
		while(a>0)
		{
			a>>=1;
			++te;
		}
		return te;
	}
	static class vecti
	{
		int a[],size;
		vecti(){a=new int[10];size=0;}
		vecti(int n){a=new int[n];size=0;}
		public void add(int b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	static class vectl
	{
		long a[];
		int size;
		vectl(){a=new long[10];size=0;}
		vectl(int n){a=new long[n];size=0;}
		public void add(long b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	static class vectd
	{
		double a[];
		int size;
		vectd(){a=new double[10];size=0;}
		vectd(int n){a=new double[n];size=0;}
		public void add(double b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	//output functions////////////////
	static void pr(Object a){output.append(a+"\n");}
	static void pr(){output.append("\n");}
	static void p(Object a){output.append(a);}
	static void pra(int[]a){for(int i:a)output.append(i+" ");output.append("\n");}
	static void pra(long[]a){for(long i:a)output.append(i+" ");output.append("\n");}
	static void pra(String[]a){for(String i:a)output.append(i+" ");output.append("\n");}
	static void pra(double[]a){for(double i:a)output.append(i+" ");output.append("\n");}
	static void sop(Object a){System.out.println(a);}
	static void flush(){System.out.println(output);output=new StringBuilder();}
	//////////////////////////////////
	//input functions/////////////////
	static int ni(){return Integer.parseInt(in.next());}
	static long nl(){return Long.parseLong(in.next());}
	static String ns(){return in.next();}
	static double nd(){return Double.parseDouble(in.next());}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[] pnia(int n){int a[]=new int[n+1];for(int i=1; i<=n; i++)a[i]=ni();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double[] nda(int n){double a[]=new double[n];for(int i=0; i<n; i++)a[i]=nd();return a;}
	//////////////////////////////////
	//some utility functions
	static void exit(){System.exit(0);}
	static int min(int... a){int min=a[0];for(int i:a)min=Math.min(min, i);return min;}
	static int max(int... a){int max=a[0];for(int i:a)max=Math.max(max, i);return max;}
	static int gcd(int... a){int gcd=a[0];for(int i:a)gcd=gcd(gcd, i);return gcd;}
	static String pr(String a, long b){String c="";while(b>0){if(b%2==1)c=c.concat(a);a=a.concat(a);b>>=1;}return c;}
	static long powm(long a, long b, long m){long an=1;long c=a;while(b>0){if(b%2==1)an=(an*c)%m;c=(c*c)%m;b>>=1;}return an;}
	static int gcd(int a, int b){if(b==0)return a;return gcd(b, a%b);}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 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();
        }
    }
}


import java.io.*;
import java.util.*;
//I am fading.......
//read the question correctly (is y a vowel? what are the exact constraints?)
//look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
public class Main
{
	public static void main(String[] args) throws Exception
	{
		int n=ni();
		int[]a=nia(n);
		int ct1=0,ct2=0;
		for(int i=0; i<n; i++)
			if(a[i]==1)
				ct1++;
			else
				ct2++;
		int co1[]=new int[2*n];
		int co2[]=new int[2*n];
		for(int i=0,j=0,k=0; i<n; i++)
			if(a[i]==1) co1[j++]=i;
			else if(a[i]==2) co2[k++]=i;
		for(int i=ct1; i<2*n; i++)
			co1[i]=1000000;
		for(int i=ct2; i<2*n; i++)
			co2[i]=1000000;
		int con1[]=new int[n];
		int con2[]=new int[n];
		for(int i=0; i<n; i++)
		{
			if(i!=0)
			{
			con1[i]+=con1[i-1];
			con2[i]+=con2[i-1];
			}
			if(a[i]==1)
				con1[i]++;
			else
				con2[i]++;
		}
		int ans=0;
		List<pair> hola=new ArrayList<pair>();
		for(int i=Math.max(ct1, ct2); i>0; i--)
		{
			int te1=0,te2=0;
			for(int k=0,l=0; ;)
			{
				pair mac1=new pair(),mac2=new pair();
				if(co1[k+i-1]<co2[l+i-1])
				{
					k+=i;
					l=con2[co1[k-1]];
					te1++;
					mac1.a=te1;
					mac1.b=te2;

				}
				else if(co1[k+i-1]>co2[l+i-1])
				{
					l+=i;
					k=con1[co2[l-1]];
					te2++;
					mac2.a=te1;
					mac2.b=te2;

				}
				else
					break;
				if(k==ct1&&l==ct2)
				{
					if(te1>te2&&mac1.a==te1&&mac1.b==te2)
					{
						hola.add(new pair(Math.max(te1, te2),i));
						ans++;
					}
					if(te1<te2&&mac2.a==te1&&mac2.b==te2)
					{
						hola.add(new pair(Math.max(te1, te2),i));
						ans++;
					}

					break;
				}
			}
		}
		sop(ans);
		Collections.sort(hola, new Comparator<pair>()
				{
			public int compare(pair a,pair b)
			{
				if(a.a>b.a)
					return 1;
				if(b.a>a.a)
					return -1;
				if(a.b>b.b)
					return 1;
				if(b.b>a.b)
					return -1;
				return 0;
			}
				});
		for(pair te:hola)
			pr(te.a+" "+te.b);
		System.out.print(output);
	}

	///////////////////////////////////////////
	///////////////////////////////////////////
	///template from here
	static class pair
	{
		int a,b;
		pair(){}
		pair(int c,int d){a=c;b=d;}
		@Override
		public int hashCode(){return (a+" "+b).hashCode();}
		@Override public boolean equals(Object c){if(a==((pair)c).a&&b==((pair)c).b)return true;return false;}
	}
	static interface combiner
	{
		public int combine(int a, int b);
	}
	static final int mod=1000000007;
	static final double eps=1e-8;
	static final long inf=100000000000000000L;
	static Reader in=new Reader();
	static StringBuilder output=new StringBuilder();
	static Random rn=new Random();
	public static void sort(int[]a)
	{
		int te;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
				a[i]^=a[te];
				a[te]^=a[i];
				a[i]^=a[te];
			}
		}
		Arrays.sort(a);
	}
	public static void sort(long[]a)
	{
		int te;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
			a[i]^=a[te];
			a[te]^=a[i];
			a[i]^=a[te];
			}
		}
		Arrays.sort(a);
	}
	public static void sort(double[]a)
	{
		int te;
		double te1;
		for(int i=0; i<a.length; i+=2)
		{
			te=rn.nextInt(a.length);
			if(i!=te)
			{
			te1=a[te];
			a[te]=a[i];
			a[i]=te1;
			}
		}
		Arrays.sort(a);
	}
	public static void sort(int[][]a)
	{
		Arrays.sort(a, new Comparator<int[]>()
		{
			public int compare(int[]a,int[]b)
			{
				if(a[0]>b[0])
					return 1;
				if(b[0]>a[0])
					return -1;
				return 0;
			}
		});
	}
	static int lowerbound(int[]a, int key)
	{
		/*
		 * returns index of smallest element larger than equal to given element between indices l and r inclusive
		 */
		int low=0,high=a.length-1,mid=(low+high)/2;
		while(low<high)
		{
			if(a[mid] >= key)
				high=mid;
			else
				low=mid+1;
			mid=(low+high)/2;
		}
		return mid;
	}
	static int upperbound(int[]a, int key)
	{
		int low=0,high=a.length-1,mid=(low+high+1)/2;
		while(low<high)
		{
			if(a[mid] <= key)
				low=mid;
			else
				high=mid-1;
			mid=(low+high+1)/2;
		}
		return mid;
	}
	static int lowerbound(int[]a, int l, int r, int key)
	{
		int low=l,high=r,mid=(low+high)/2;
		while(low<high)
		{
			if(a[mid] >= key)
				high=mid;
			else
				low=mid+1;
			mid=(low+high)/2;
		}
		return mid;
	}
	static int upperbound(int[]a, int l, int r, int key)
	{
		/*
		 * returns index of largest element smaller than equal to given element
		 */
		int low=l,high=r,mid=(low+high+1)/2;
		while(low<high)
		{
			if(a[mid] <= key)
				low=mid;
			else
				high=mid-1;
			mid=(low+high+1)/2;
		}
		return mid;
	}

	void sort(pair[]a)
	{
		Arrays.sort(a,new Comparator<pair>()
				{
			@Override
			public int compare(pair a,pair b)
			{
				if(a.a>b.a)
					return 1;
				if(b.a>a.a)
				return -1;
				return 0;
			}
				});
	}
	static int log2n(long a)
	{
		int te=0;
		while(a>0)
		{
			a>>=1;
			++te;
		}
		return te;
	}
	static class vecti
	{
		int a[],size;
		vecti(){a=new int[10];size=0;}
		vecti(int n){a=new int[n];size=0;}
		public void add(int b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	static class vectl
	{
		long a[];
		int size;
		vectl(){a=new long[10];size=0;}
		vectl(int n){a=new long[n];size=0;}
		public void add(long b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	static class vectd
	{
		double a[];
		int size;
		vectd(){a=new double[10];size=0;}
		vectd(int n){a=new double[n];size=0;}
		public void add(double b){if(++size==a.length)a=Arrays.copyOf(a, 2*size);a[size-1]=b;}
		public void sort(){Arrays.sort(a, 0, size);}
		public void sort(int l, int r){Arrays.sort(a, l, r);}
	}
	//output functions////////////////
	static void pr(Object a){output.append(a+"\n");}
	static void pr(){output.append("\n");}
	static void p(Object a){output.append(a);}
	static void pra(int[]a){for(int i:a)output.append(i+" ");output.append("\n");}
	static void pra(long[]a){for(long i:a)output.append(i+" ");output.append("\n");}
	static void pra(String[]a){for(String i:a)output.append(i+" ");output.append("\n");}
	static void pra(double[]a){for(double i:a)output.append(i+" ");output.append("\n");}
	static void sop(Object a){System.out.println(a);}
	static void flush(){System.out.println(output);output=new StringBuilder();}
	//////////////////////////////////
	//input functions/////////////////
	static int ni(){return Integer.parseInt(in.next());}
	static long nl(){return Long.parseLong(in.next());}
	static String ns(){return in.next();}
	static double nd(){return Double.parseDouble(in.next());}
	static int[] nia(int n){int a[]=new int[n];for(int i=0; i<n; i++)a[i]=ni();return a;}
	static int[] pnia(int n){int a[]=new int[n+1];for(int i=1; i<=n; i++)a[i]=ni();return a;}
	static long[] nla(int n){long a[]=new long[n];for(int i=0; i<n; i++)a[i]=nl();return a;}
	static String[] nsa(int n){String a[]=new String[n];for(int i=0; i<n; i++)a[i]=ns();return a;}
	static double[] nda(int n){double a[]=new double[n];for(int i=0; i<n; i++)a[i]=nd();return a;}
	//////////////////////////////////
	//some utility functions
	static void exit(){System.exit(0);}
	static int min(int... a){int min=a[0];for(int i:a)min=Math.min(min, i);return min;}
	static int max(int... a){int max=a[0];for(int i:a)max=Math.max(max, i);return max;}
	static int gcd(int... a){int gcd=a[0];for(int i:a)gcd=gcd(gcd, i);return gcd;}
	static String pr(String a, long b){String c="";while(b>0){if(b%2==1)c=c.concat(a);a=a.concat(a);b>>=1;}return c;}
	static long powm(long a, long b, long m){long an=1;long c=a;while(b>0){if(b%2==1)an=(an*c)%m;c=(c*c)%m;b>>=1;}return an;}
	static int gcd(int a, int b){if(b==0)return a;return gcd(b, a%b);}
	static class Reader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public Reader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 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();
        }
    }
}


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collections;
import java.io.InputStream;

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

class TaskD {
    class Pair implements Comparable<Pair>{
        int s,t;
        public Pair(int s,int t)
        {
            this.s=s;
            this.t=t;
        }
        public int compareTo(Pair other)
        {
            if(s<other.s)
                return -1;
            else if(other.s>s)
                return 1;
            else if(t<other.t)
                return -1;
            else if(t>other.t)
                return 1;
            else
                return 0;
        }

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

        Bit bit1=new Bit(10000);
        Bit bit2=new Bit(10000);
        for(int i=0;i<a.length;i++)
            if(a[i]==1)
                bit1.update(i+1,1);
            else
                bit2.update(i+1,1);

        ArrayList<Pair> answers=new ArrayList<Pair>();
        for(int t=1;t<=a.length;t++)
        {
            int k=1;
            int s1=0;
            int s2=0;
            boolean flag=true;
            while(true)
            {
                int k1=getNext(bit1,k,t,a.length);
                int k2=getNext(bit2,k,t,a.length);
                if(k1<=k2 && bit1.sum_range(k,k1)==t)
                {
                    s1++;
                    int count=bit1.sum_range(k,k1);
                    if(count<t)
                    {
                        flag=false;
                        break;
                    }
                    if(k1==a.length)break;
                    k=k1+1;

                }
                else
                {
                    s2++;
                    int count=bit2.sum_range(k,k2);
                    if(count<t)
                    {
                        flag=false;
                        break;
                    }
                    if(k2==a.length)break;
                    k=k2+1;

                }
            }

            int s=Math.max(s1,s2);
            if(flag && s1!=s2)
                answers.add(new Pair(s,t));
        }
        Collections.sort(answers);
        out.println(answers.size());
        for(int i=0;i<answers.size();i++)
            out.println(answers.get(i).s + " " + answers.get(i).t);

    }
    int getNext(Bit bit,int start,int t,int length)
    {
        int hi=length;
        int lo=start;
        while(lo<hi)
        {
            int mid=lo+(hi-lo)/2;
            int count=bit.sum_range(start,mid);
            if(count<t)
                lo=mid+1;
            else
                hi=mid;
        }
        return lo;
    }
}

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());
    }

}

class Bit {
    int tree[];
    int maxn;
    public Bit(int maxn)
    {
        tree=new int[maxn];
        this.maxn=maxn;
    }
    public void update(int index,int value)
    {
        while(index<maxn)
        {
            tree[index]+=value;
            index+=(index&-index);
        }

    }
    public int sum_range(int l,int r)
    {
        return sum(r)-(l-1>0?sum(l-1):0);
    }
    public int sum(int index)
    {
        int sum=0;
        while(index>0)
        {
            sum+=tree[index];
            index-=(index&-index);
        }
        return sum;

    }

}


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collections;
import java.io.InputStream;

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

class TaskD {
    class Pair implements Comparable<Pair>{
        int s,t;
        public Pair(int s,int t)
        {
            this.s=s;
            this.t=t;
        }
        public int compareTo(Pair other)
        {
            if(s<other.s)
                return -1;
            else if(other.s>s)
                return 1;
            else if(t<other.t)
                return -1;
            else if(t>other.t)
                return 1;
            else
                return 0;
        }

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

        Bit bit1=new Bit(10000);
        Bit bit2=new Bit(10000);
        for(int i=0;i<a.length;i++)
            if(a[i]==1)
                bit1.update(i+1,1);
            else
                bit2.update(i+1,1);

        ArrayList<Pair> answers=new ArrayList<Pair>();
        for(int t=1;t<=a.length;t++)
        {
            int k=1;
            int s1=0;
            int s2=0;
            boolean flag=true;
            while(true)
            {
                int k1=getNext(bit1,k,t,a.length);
                int k2=getNext(bit2,k,t,a.length);
                if(k1<=k2 && bit1.sum_range(k,k1)==t)
                {
                    s1++;
                    int count=bit1.sum_range(k,k1);
                    if(count<t)
                    {
                        flag=false;
                        break;
                    }
                    if(k1==a.length)break;
                    k=k1+1;

                }
                else
                {
                    s2++;
                    int count=bit2.sum_range(k,k2);
                    if(count<t)
                    {
                        flag=false;
                        break;
                    }
                    if(k2==a.length)break;
                    k=k2+1;

                }
            }

            int s=Math.max(s1,s2);
            if(flag && s1!=s2)
                if(s1>s2 && a[a.length-1]==1)
                    answers.add(new Pair(s,t));
                else if(s2>s1 && a[a.length-1]==2)
                    answers.add(new Pair(s,t));
        }
        Collections.sort(answers);
        out.println(answers.size());
        for(int i=0;i<answers.size();i++)
            out.println(answers.get(i).s + " " + answers.get(i).t);

    }
    int getNext(Bit bit,int start,int t,int length)
    {
        int hi=length;
        int lo=start;
        while(lo<hi)
        {
            int mid=lo+(hi-lo)/2;
            int count=bit.sum_range(start,mid);
            if(count<t)
                lo=mid+1;
            else
                hi=mid;
        }
        return lo;
    }
}

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());
    }

}

class Bit {
    int tree[];
    int maxn;
    public Bit(int maxn)
    {
        tree=new int[maxn];
        this.maxn=maxn;
    }
    public void update(int index,int value)
    {
        while(index<maxn)
        {
            tree[index]+=value;
            index+=(index&-index);
        }

    }
    public int sum_range(int l,int r)
    {
        return sum(r)-(l-1>0?sum(l-1):0);
    }
    public int sum(int index)
    {
        int sum=0;
        while(index>0)
        {
            sum+=tree[index];
            index-=(index&-index);
        }
        return sum;

    }

}


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collections;
import java.io.InputStream;

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

class TaskD {
    class Pair implements Comparable<Pair>{
        int s,t;
        public Pair(int s,int t)
        {
            this.s=s;
            this.t=t;
        }
        public int compareTo(Pair other)
        {
            if(s<other.s)
                return -1;
            else if(other.s>s)
                return 1;
            else if(t<other.t)
                return -1;
            else if(t>other.t)
                return 1;
            else
                return 0;
        }

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

        Bit bit1=new Bit(a.length+1);
        Bit bit2=new Bit(a.length+1);
        for(int i=0;i<a.length;i++)
            if(a[i]==1)
                bit1.update(i+1,1);
            else
                bit2.update(i+1,1);

        ArrayList<Pair> answers=new ArrayList<Pair>();
        for(int t=1;t<=a.length;t++)
        {
            int k=1;
            int s1=0;
            int s2=0;
            boolean flag=true;
            while(true)
            {
                int k1=getNext(bit1,k,t,a.length);
                int k2=getNext(bit2,k,t,a.length);
                if(k1<=k2 && bit1.sum_range(k,k1)==t)
                {
                    s1++;
                    int count=bit1.sum_range(k,k1);
                    if(count<t)
                    {
                        flag=false;
                        break;
                    }
                    if(k1==a.length)break;
                    k=k1+1;

                }
                else
                {
                    s2++;
                    int count=bit2.sum_range(k,k2);
                    if(count<t)
                    {
                        flag=false;
                        break;
                    }
                    if(k2==a.length)break;
                    k=k2+1;

                }
            }

            int s=Math.max(s1,s2);
            if(flag && s1!=s2)
                if(s1>s2 && a[a.length-1]==1)
                    answers.add(new Pair(s,t));
                else if(s2>s1 && a[a.length-1]==2)
                    answers.add(new Pair(s,t));
        }
        Collections.sort(answers);
        out.println(answers.size());
        for(int i=0;i<answers.size();i++)
            out.println(answers.get(i).s + " " + answers.get(i).t);

    }
    int getNext(Bit bit,int start,int t,int length)
    {
        int hi=length;
        int lo=start;
        while(lo<hi)
        {
            int mid=lo+(hi-lo)/2;
            int count=bit.sum_range(start,mid);
            if(count<t)
                lo=mid+1;
            else
                hi=mid;
        }
        return lo;
    }
}

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());
    }

}

class Bit {
    int tree[];
    int maxn;
    public Bit(int maxn)
    {
        tree=new int[maxn];
        this.maxn=maxn;
    }
    public void update(int index,int value)
    {
        while(index<maxn)
        {
            tree[index]+=value;
            index+=(index&-index);
        }

    }
    public int sum_range(int l,int r)
    {
        return sum(r)-(l-1>0?sum(l-1):0);
    }
    public int sum(int index)
    {
        int sum=0;
        while(index>0)
        {
            sum+=tree[index];
            index-=(index&-index);
        }
        return sum;

    }

}


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long a,i,n,k,l,k1=0,l1=0,z=0,p=0;
    cin >> n >> k >> l;
    for(i=1;i<=n;i++)
    {
        cin >> a;
        if(a==1)k--;
        if(a==2)l--;
    }
    if((k>=0)and(l<=0))p=k+l;
    if((k<=0)and(l>=0))p=abs(k);
    if((k<=0)and(l<=0))p=abs(k)+abs(l);
    cout << p << endl;
    return 0;
}


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long a,i,n,k,l,k1=0,l1=0,z=0,p=0;
    cin >> n >> k >> l;
    for(i=1;i<=n;i++)
    {
        cin >> a;
        if(a==1)k--;
        if(a==2)l--;
    }
    if((k>0)and(l<0))p=k-abs(l);
    if((k<0)and(l>0))p=abs(k);
    if((k<0)and(l<0))p=abs(k)+abs(l);
    cout << p << endl;
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d;
    int sum=0,dd;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&d);
        if(d==1)
            sum++;
    }
    if(b>c)
        dd=b;
    else
        dd=c;
    if(sum>dd)
        {if(a-sum>c)
          printf("%d\n",sum-dd+a-b-c);
        else
            printf("%d\n",sum-dd);}
    else
      if(b+c>=a)
        printf("0\n");
      else
        printf("%d\n",a-b-c);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d;
    int sum=0,dd;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&d);
        if(d==1)
            sum++;
    }
    if(b>c)
        dd=b;
    else
        dd=c;
    if(sum>dd)
    {
        if(a-sum>abs(sum-b-c))
          printf("%d\n",sum-dd+a-sum+dd-b-c);
        else
          printf("%d\n",sum-dd);
    }
    else
      if(b+c>=a)
        printf("0\n");
      else
        printf("%d\n",a-b-c);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d;
    int sum=0,dd;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&d);
        if(d==1)
            sum++;
    }
    if(sum>b)
    {
        if(a-sum>c)
          printf("%d\n",sum-b+a-sum-c);
        else
          printf("%d\n",sum-b);
    }
    else
      if(b+c>=a)
        printf("0\n");
      else
        printf("%d\n",a-b-c);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<a;i++)
        scanf("%d",&d);
    if(b+c>=a)
        printf("0\n");
    else
        printf("%d\n",a-b-c);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d;
    int sum=0,dd;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&d);
        if(d==1)
            sum++;
    }
    if(b>c)
        dd=b;
    else
        dd=c;
    if(sum>dd)
        {if(a-sum>c)
          printf("%d\n",sum-dd+a-sum-c);
        else
            printf("%d\n",sum-dd);}
    else
      if(b+c>=a)
        printf("0\n");
      else
        printf("%d\n",a-b-c);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d;
    int sum=0,dd;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&d);
        if(d==1)
            sum++;
    }
    if(b>c)
        dd=b;
    else
        dd=c;
    if(sum>dd)
        {if(a-sum>c)
          printf("%d\n",sum-dd+a-sum+dd-b-c);
        else
            printf("%d\n",sum-dd);}
    else
      if(b+c>=a)
        printf("0\n");
      else
        printf("%d\n",a-b-c);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d;
    int sum=0,dd;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<a;i++)
    {
        scanf("%d",&d);
        if(d==1)
            sum++;
    }
    if(b>c)
        dd=b;
    else
        dd=c;
    if(sum>dd)
    {
        if(a-sum>abs(dd-b-c))
          printf("%d\n",sum-dd+a-sum+dd-b-c);
        else
          printf("%d\n",sum-dd);
    }
    else
      if(b+c>=a)
        printf("0\n");
      else
        printf("%d\n",a-b-c);
    return 0;
}


#include <iostream>

using namespace std;
long long a,b=0,v=0,g,d=0,k,m,n,i,j=1;
int main()
{
    cin>>n>>m>>k;
    for(i=1;i<n;i++)
    {
       cin>>a;
       if(a==2)v++;
       if(a>2)b++;
       if(a<=2)d++;
    }
    if(a==2) cout<<v<<endl;
    if(a<2)cout<<(d-d)+j<<endl;

    return 0;
}


#include <iostream>

using namespace std;
long long a,b,c,d,i,k,m,n,j;
int main()
{
    cin>>n>>m>>k;

  for(i=0;i<n;i++)
  {
      cin>>j;
      if(j==1)
      {
          if(m>0)m--;
          else c++;
      }
      if(j==2)
      {
          if(k>0)k--;
          else if(m>0)b--;
          else c++;
      }
  }
  cout<<c<<endl;

    return 0;
}


#include <iostream>

using namespace std;
long long a,b,c,d,i,k,m,n,j;
int main()
{
    cin>>n>>m>>k;

  for(i=0;i<n;i++)
  {
      cin>>j;
      if(j==1)
      {
          if(m>0)m--;
          else c++;
      }
      if(d==2)
      {
          if(k>0)k--;
          else if(m>0)b--;
          else c++;
      }
  }
  cout<<c<<endl;

    return 0;
}


#include <iostream>

using namespace std;
long long a,b=0,v=0,g,d=0,k,m,n,i;
int main()
{
    cin>>n>>m>>k;
    for(i=1;i<n;i++)
    {
       cin>>a;
       if(a==2)v++;
       if(a>=2)b++;
       if(a<=2)d++;
    }
    if(a==2 and a>=2 ) cout<<v<<endl;
    if(a<2)cout<<b<<endl;

    return 0;
}


#include <iostream>

using namespace std;
long long a,b=0,v=0,g,d=0,k,m,n,i,j=1;
int main()
{
    cin>>n>>m>>k;
    for(i=1;i<n;i++)
    {
       cin>>a;
       if(a==2)v++;
       if(a>2)b++;
       if(a<=2)d++;
    }
    if(a==2) cout<<v<<endl;
    if(a<!2)cout<<(d-d)+j<<endl;

    return 0;
}


#include <iostream>

using namespace std;
long long a,b=0,v=1,g,d=0,k,m,n,i;
int main()
{
    cin>>n>>m>>k;
    for(i=1;i<n;i++)
    {
       cin>>a;
       if(a>=2)v++;
       if(a==1)b++;
       if(a<=2)d++;
    }
    cout<<v;
    return 0;
}


#include <iostream>

using namespace std;
long long a,b=0,v=0,g,d=0,k,m,n,i;
int main()
{
    cin>>n>>m>>k;
    for(i=1;i<n;i++)
    {
       cin>>a;
       if(a==2)v++;
       if(a>=2)b++;
       if(a<=2)d++;
    }
    cout<<v;
    return 0;
}


#include <iostream>

using namespace std;
long long a,b=0,v=0,g,d=0,k,m,n,i;
int main()
{
    cin>>n>>m>>k;
    for(i=1;i<n;i++)
    {
       cin>>a;
       if(a==2)v++;
       if(a>=2)b++;
       if(a<=2)d++;
    }
    if(a==2 and a>=2 ) cout<<v;
    if(a<=2)cout<<b<<endl;

    return 0;
}


#include <iostream>

using namespace std;
long long a,b,c,d,i,k,m,n,j;
int main()
{
    cin>>n>>m>>k;

  for(i=0;i<n;i++)
  {
      cin>>j;
      if(j==1)
      {
          if(m>0)m--;
          else c++;
      }
      if(j==2)
      {
          if(k>0)k--;
          else if(m>0)m--;
          else c++;
      }
  }
  cout<<c<<endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <cstdlib>

using namespace std;

#define push_back pb

int main()
{
    int i,j,n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    for(i=0;i<n;i++)
    {
        //cout<<m<<" "<<k<<endl;
        cin>>j;
        if(j==1)
        {
            if(m>0) m--;
            else ans++;
        }
        else if(j==2)
        {
            if(k>0) k--;
            else if (m>0) m--;
            else ans++'
        }
    }

    cout<<ans<<endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <cstdlib>

using namespace std;

#define push_back pb

int main()
{
    int i,j,n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    int o=0,t=0;
    for(i=0;i<n;i++)
    {
        //cout<<m<<" "<<k<<endl;
        cin>>j;
        if(j==1)
        {
            o++;
        }
        else if(j==2)
        {
            t++;
        }
    }
    m-=o;
    if(m<0) ans+=abs(m);

    if(t>k)
    {
        t-=k;
        if(m>0)
        {
            t-=m;
        }
    }
    else
    {
        t=0;
    }
    cout<<ans+t<<endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <cstdlib>

using namespace std;

#define push_back pb

int main()
{
    int i,j,n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    for(i=0;i<n;i++)
    {
        //cout<<m<<" "<<k<<endl;
        cin>>j;
        if(j==1)
        {
            if(m>0) m--;
            else ans++;
        }
        else if(j==2)
        {
            if(k>0) k--;
            else if (m>0) m--;
            else ans++;
        }
    }

    cout<<ans<<endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <cstdlib>

using namespace std;

#define push_back pb

int main()
{
    int i,j,n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    int o=0,t=0;
    for(i=0;i<n;i++)
    {
        //cout<<m<<" "<<k<<endl;
        cin>>j;
        if(j==1)
        {
            if(m>0) m--;
            else ans++;
        }
        else if(j==2)
        {
            if(k>=m && k>0) k--;
            else if(k<=0 && m>0) m--;
            else ans++;
        }
    }

    cout<<ans<<endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <cstdlib>

using namespace std;

#define push_back pb

int main()
{
    int i,j,n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    int o=0,t=0;
    for(i=0;i<n;i++)
    {
        //cout<<m<<" "<<k<<endl;
        cin>>j;
        if(j==1)
        {
            if(m>0) m--;
            else ans++'
        }
        else if(j==2)
        {
            if(k>0) k--;
            else if (m>0) m--;
            else ans++'
        }
    }

    cout<<ans<<endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <cstdlib>

using namespace std;

#define push_back pb

int main()
{
    int i,j,n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    int o=0,t=0;
    for(i=0;i<n;i++)
    {
        //cout<<m<<" "<<k<<endl;
        cin>>j;
        if(j==1)
        {
            o++;
        }
        else if(j==2)
        {
            t++;
        }
    }
    m-=o;
    if(m<0)
    {
        ans+=abs(m);
    }
    else k+=m;

    if(t>k)
    {
        t-=k;
        if(m>0)
        {
            t-=m;
        }
    }
    else
    {
        t=0;
    }
    cout<<ans+t<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int n, m, k, a, ans;

int main(){

	scanf("%d%d%d", &n, &m, &k);

	while(n--){

		scanf("%d", &a);

		if(a==1){

			if(m) m--;

			else ans++;

		}

		else{

			if(k) k--;

			else if(m) m--;

			else ans++;

		}

	}

	printf("%d\n", ans);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

int b[3];

int main() {

#ifndef ONLINE_JUDGE

    freopen("in.in", "r", stdin);

//    freopen("out.out", "w", stdout);

#endif

	int n,m,k;

	scanf("%d%d%d",&n,&m,&k);

	for(int i=1; i<=n; i++){

		int a;

		scanf("%d",&a);

		b[a]++;

	}

	int aa=max(0,b[1]-m);

	int aaa=max(0,b[2]-k);

	printf("%d\n",aa+aaa);

	return 0;

}


#include <bits/stdc++.h>

#define NN 1100

using namespace std;

int a[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

		int n,m,k;

		scanf("%d%d%d",&n,&m,&k);

		for(int i=1;i<=n;i++) scanf("%d",&a[i]);

		int r=0;

		for(int i=1;i<=n;i++){

			if(a[i]==1) r++;

		}

		if(m>=r){

			int ans=max(0,n-m-k);

		 	printf("%d",ans);

		}

		if(m<r){

			int ans=r-m+max(0,n-r-k);

			printf("%d",ans);

		}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

int a[11000];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n,m,k;

	scanf("%d%d%d",&n,&m,&k);

	int nf=0,ns=0;

	for(int i=0;i<n;i++) {

		scanf("%d",&a[i]);

		if(a[i]==1) nf++;

		else ns++;

	}

	int ss=0;

	if(ns>k) ss+=(ns-k);

	if(nf+ss>m) {printf("%d",nf+ss-m);return 0;}

	printf("%d",0);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define hmod 911382323

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define LEN(a) (a.length())

#define x first

#define y second

#define ls (u<<1)

#define rs (ls + 1)

#define mid (st + ed >> 1)

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define rands(n) (rand()%n+1)

#define rand0(n) (rands(n)-1)

#define Rands(n) ((INT)rand()*rand()%n+1)

#define Rand0(n) (Rands(n)-1)

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

#define shit(a) (1 << (a))

#define all(a) ((a).begin(), (a).end())

#define rev(a) (power(a, mod-2, mod))

using namespace std;

typedef long long INT;

typedef unsigned long long UINT;

typedef unsigned int uint;

typedef complex<double> Complex;

typedef double DO;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef pair<int, pii> pip;

typedef pair<DO, DO> pdd;

typedef pair<int, DO> pid;

typedef pair<DO, int> pdi;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n, m, k;

	gn(n, m, k);

	int ans=0;

	for(int i=0; i<n; i++) {

		int t;

		gn(t);

		if(t==2) {

			if(k) k--;

			else if(m) m--;

			else ans++;

		}

		else {

			if(m) m--;

			else ans++;

		}

	}

	cout << ans << endl;

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n, m, k, x, ans=0;

	gn(n, m, k);

	while(n--) {

        gn(x);

        if(x==1) {

            if(m>0) m--;

            else ans++;

        }

        else {

            if(k>0) k--;

            else if(m>0) m--;

            else ans++;

        }

	}

	println(ans);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n, m, k, ans=0;

	gn(n, m, k);

	for(int i=1, x; i<=n; i++) {

        gn(x);

        if(x==1) {

            if(m>0) m--;

            else ans++;

        }

        else {

            if(m>0) m--;

            else if(k>0) k--;

            else ans++;

        }

	}

	println(ans);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE

    freopen("in.in", "r", stdin);

//    freopen("out.out", "w", stdout);

#endif

	int n,m,k,ans=0;

	scanf("%d%d%d",&n,&m,&k);

	for(int i=1; i<=n; i++){

		int a;

		scanf("%d",&a);

		if(a==1) {

			if(m>0) m--;

			else ans++;

		}

		if(a==2){

			if(k>0) k--;

			else if(m>0) m--;

			else ans++;

		}

	}

	printf("%d\n",ans);

}


#include <iostream>
#include <cmath>
using namespace std;
  long long i,n,k,m,a,z=10,kol1=0,kol2=0,ans=0;
int main()
{

    cin >>n >> m >> k;
    for (i=1; i<=n; i++)
    {
        cin >> a;
        if (a==1) kol1++;
        else kol2++;
    }

    m-=kol1;
    if (m<0) ans+=abs(m);
    k-=kol2;

    if (k<0 && m<=0) ans+=abs(k);
    else
    {
        if (m>0 && k<0)
        {
            k+=m;
            if (k<0) ans+=abs(k);

        }
    }

    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long long i,n,k,m,a,z=0,kol1=0,kol2=0,ans=0;

    cin >>n >> m >> k;
    for (i=1; i<=n; i++)
    {
        cin >> a;
        if (a==1) kol1++;
        else kol2++;
    }
    // m - glub
    // k - plos
    // kol1 - tolko glub
    // kol2 - vse

    m-=kol1;
    if (m<0) ans+=abs(m);
    k-=kol2;
    if (k<0 && m<=0) ans+=abs(k);
    else
    {
        if (m>0)
        {
            k+=m;
            if (k<0) ans+=abs(k);
            else ans+=k;
        }
    }

    cout << ans << endl;
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    long long i,n,k,m,a,z=0,x=0;
    cin>>n>>m>>k;
    for(i=1; i<=n; i++)
    {
        cin>>a;
        if(a=1)
        {
            if(m)
            {
                m--;

            }
            else z++;

        }
        else
        if(k)
        {
            k--;

        }
        else x++;

    }

cout<<z<<endl;

    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long long i,n,k,m,a,z=0,kol1=0,kol2=0,ans=0;

    cin >>n >> m >> k;
    for (i=1; i<=n; i++)
    {
        cin >> a;
        if (a==1) kol1++;
        else kol2++;
    }
    // m - glub
    // k - plos
    // kol1 - tolko glub
    // kol2 - vse

    m-=kol1;
    if (m<0) ans+=abs(m);
    k-=kol2;
    //cout << k << endl;
    if (k<0 && m<=0) ans+=abs(k);
    else
    {
        if (m>0 && k<0)
        {
            k+=m;
            if (k<0) ans+=abs(k);
            else ans+=k;
        }
    }

    cout << ans << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
   long long i,a,b,m,n,x,z=0,q=0,w=0,h=0;
   cin>>n>>a>>b;
   for(i=1;i<=n;i++)
   {
       cin>>x;

   }
    if(a==1)
   {
      z++;

   }
if(b==1)
{

        q++;

}
    if(a==2)
    {
        w++;

    }
    if(b==2)
    {
        h++;
    }
    cout <<z+q+w+h  << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long long i,n,k,m,a,z=0,kol1=0,kol2=0,ans=0;

    cin >>n >> m >> k;
    for (i=1; i<=n; i++)
    {
        cin >> a;
        if (a==1) kol1++;
        else kol2++;
    }

    m-=kol1;
    if (m<0) ans+=abs(m);
    k-=kol2;

    if (k<0 && m<=0) ans+=abs(k);
    else
    {
        if (m>0 && k<0)
        {
            k+=m;
            if (k<0) ans+=abs(k);

        }
    }

    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long long i,n,k,m,a,z=0,kol1=0,kol2=0,ans=0;

    cin >>n >> m >> k;
    for (i=1; i<=n; i++)
    {
        cin >> a;
        if (a==1) kol1++;
        else kol2++;
    }
    // m - glub
    // k - plos
    // kol1 - tolko glub
    // kol2 - vse

    m-=kol1;
    if (m<0) ans+=abs(m);
    k-=kol2;
    //cout << k << endl;
    if (k<0 && m<=0) ans+=abs(k);
    else
    {
        if (m>0 && k<0)
        {
            k+=m;
            if (k<0) ans+=abs(k);

        }
    }

    cout << ans << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    long long i,a,d,b,x,j=1,n;
    cin>>x;

    if(x%2==0)cout<<"I hate that ";
    if(x%2==0)j++;
    while(j<x)
    {

        if(x%2==1)cout<<"I hate that ";
        if(x%2==0)cout<<"I love that ";
        x=x-1;
    }
    if(x%2==1)cout<<"I hate it"<<endl;
    if(x%2==0)cout<<"I love it"<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;

#define FastIO           ios_base::sync_with_stdio(0)

#define Read(f)          freopen(f, "r", stdin)
#define Write(f)         freopen(f, "w", stdout)

#define Mem(a, b)        memset(a, b, sizeof a)
#define MemCp(a, b)      memcopy(a, b, sizeof a)
#define RADIANS(x)       (((1.0 * x * PI) / 180.0))
#define DEGREES(x)       (((x * 180.0) / (1.0 * pi)))
#define sq(x)            ((x)*(x))
#define debug(x)         cerr<<__LINE__<<" "<<#x<<" "<<x<<endl;

#define eps              1e-8
#define Pi               (2*acos(0.0))
#define INF              0x7f7f7f7f

#define in               scanf
#define out              printf
#define pb               push_back
#define popb             pop_back
#define ll             long long
#define ull           unsigned long long
#define ff              first
#define ss              second
#define mp               make_pair

#define Mx               10000005
#define Mod              10000

long dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
long dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

template < class T > T Abs(T a)
{
    return (a < 0 ? -a : a);
}

template < class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd(b, a%b) : a);
}

template < class T > T lcm(T a, T b)
{
    return ((a*b)/gcd(a, b));
}

template < class T > T bigMod(T b, T p, T m)
{
     if(p==0)
          return 1;
     else if( p & 1 )
          return ( b*bigMod(b, p-1, m))%m;
     else
     {
          T temp = bigMod(b, p>>1, m);
          return (sq(temp))%m;
     }
}

template < class T > T modInverse(T b, T m)
{
     return bigMod(b, m-2, m);
}

template < class T > T power(T b, T p)
{
     T res=1, x=b;
     while(p)
     {
          if(p&1) res*=x;
          x*=x;
          p=p>>1;
     }
     return res;
}

template<typename T> inline bool isOn(T mask,T pos)
{
    return mask&(1<<pos);
}

template<typename T> inline int Off(T mask,T pos)
{
    return mask^(1<<pos);
}

template<typename T> inline int On(T mask,T pos)
{
    return mask|(1<<pos);
}

bool stringMod(string a, long long n)
{
     long long num=0;
     for(long i=0; i<a.size(); i++)
          num=((num*10) + (a[i]-'0'))%n;

     if(num==0)
          return 1;
     else
          return 0;
}

bool prime[Mx+2];
vector <long long> primes;

void seive()
{
     for(long long i=4; i<=Mx; i+=2)
          prime[i]=1;

     for(long long i=3; i*i<=Mx; i+=2)
     {
          if(prime[i]==0)
          {
               for(long long j=2*i; j<=Mx; j+=i)
                    prime[j]=1;
          }
     }

     primes.pb(2);
     for(long long i=3; i<=Mx; i+=2)
          if(prime[i]==0)
               primes.pb(i);
}

int main()
{
    int t;
    int a,b,c,n,m,res=0;
    map<int,int>mp;
    int cc=0;
    cin>>a>>b>>c;
    rep(i,a)
    {

        cin>>n;
        //cout<<b<<" "<<c<<" "<<endl;
        int f=0,ff=0;
        if(n==1)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
           {
               cc++;
           }
        }
        if(n==2)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
            {
                if(c>0)
                {
                    c--;
                    ff=1;
                }
            }
            if(f==0 and ff==0)res++;
        }
        //cout<<b<<" "<<c<<endl;

    }
    while(cc)
    {
        if(c<=1)break;
        cc-=2;
    }
    cout<<res+cc<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;

#define FastIO           ios_base::sync_with_stdio(0)

#define Read(f)          freopen(f, "r", stdin)
#define Write(f)         freopen(f, "w", stdout)

#define Mem(a, b)        memset(a, b, sizeof a)
#define MemCp(a, b)      memcopy(a, b, sizeof a)
#define RADIANS(x)       (((1.0 * x * PI) / 180.0))
#define DEGREES(x)       (((x * 180.0) / (1.0 * pi)))
#define sq(x)            ((x)*(x))
#define debug(x)         cerr<<__LINE__<<" "<<#x<<" "<<x<<endl;

#define eps              1e-8
#define Pi               (2*acos(0.0))
#define INF              0x7f7f7f7f

#define in               scanf
#define out              printf
#define pb               push_back
#define popb             pop_back
#define ll             long long
#define ull           unsigned long long
#define ff              first
#define ss              second
#define mp               make_pair

#define Mx               10000005
#define Mod              10000

long dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
long dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

template < class T > T Abs(T a)
{
    return (a < 0 ? -a : a);
}

template < class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd(b, a%b) : a);
}

template < class T > T lcm(T a, T b)
{
    return ((a*b)/gcd(a, b));
}

template < class T > T bigMod(T b, T p, T m)
{
     if(p==0)
          return 1;
     else if( p & 1 )
          return ( b*bigMod(b, p-1, m))%m;
     else
     {
          T temp = bigMod(b, p>>1, m);
          return (sq(temp))%m;
     }
}

template < class T > T modInverse(T b, T m)
{
     return bigMod(b, m-2, m);
}

template < class T > T power(T b, T p)
{
     T res=1, x=b;
     while(p)
     {
          if(p&1) res*=x;
          x*=x;
          p=p>>1;
     }
     return res;
}

template<typename T> inline bool isOn(T mask,T pos)
{
    return mask&(1<<pos);
}

template<typename T> inline int Off(T mask,T pos)
{
    return mask^(1<<pos);
}

template<typename T> inline int On(T mask,T pos)
{
    return mask|(1<<pos);
}

bool stringMod(string a, long long n)
{
     long long num=0;
     for(long i=0; i<a.size(); i++)
          num=((num*10) + (a[i]-'0'))%n;

     if(num==0)
          return 1;
     else
          return 0;
}

bool prime[Mx+2];
vector <long long> primes;

void seive()
{
     for(long long i=4; i<=Mx; i+=2)
          prime[i]=1;

     for(long long i=3; i*i<=Mx; i+=2)
     {
          if(prime[i]==0)
          {
               for(long long j=2*i; j<=Mx; j+=i)
                    prime[j]=1;
          }
     }

     primes.pb(2);
     for(long long i=3; i<=Mx; i+=2)
          if(prime[i]==0)
               primes.pb(i);
}

int main()
{
    int t;
    int a,b,c,n,m,res=0;
    map<int,int>mp;
    int cc=0;
    cin>>a>>b>>c;
    rep(i,a)
    {

        cin>>n;
        //cout<<b<<" "<<c<<" "<<endl;
        int f=0,ff=0;
        if(n==1)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
           {
               cc++;
           }
        }
        if(n==2)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
            {
                if(c>0)
                {
                    c--;
                    ff=1;
                }
            }
            if(f==0 and ff==0)res++;
        }
        //cout<<b<<" "<<c<<endl;

    }
    while(cc)
    {
        if(c<=1)break;
        c-=2;
        cc--;
    }
    cout<<res+cc<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;

#define FastIO           ios_base::sync_with_stdio(0)

#define Read(f)          freopen(f, "r", stdin)
#define Write(f)         freopen(f, "w", stdout)

#define Mem(a, b)        memset(a, b, sizeof a)
#define MemCp(a, b)      memcopy(a, b, sizeof a)
#define RADIANS(x)       (((1.0 * x * PI) / 180.0))
#define DEGREES(x)       (((x * 180.0) / (1.0 * pi)))
#define sq(x)            ((x)*(x))
#define debug(x)         cerr<<__LINE__<<" "<<#x<<" "<<x<<endl;

#define eps              1e-8
#define Pi               (2*acos(0.0))
#define INF              0x7f7f7f7f

#define in               scanf
#define out              printf
#define pb               push_back
#define popb             pop_back
#define ll             long long
#define ull           unsigned long long
#define ff              first
#define ss              second
#define mp               make_pair

#define Mx               10000005
#define Mod              10000

long dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
long dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

template < class T > T Abs(T a)
{
    return (a < 0 ? -a : a);
}

template < class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd(b, a%b) : a);
}

template < class T > T lcm(T a, T b)
{
    return ((a*b)/gcd(a, b));
}

template < class T > T bigMod(T b, T p, T m)
{
     if(p==0)
          return 1;
     else if( p & 1 )
          return ( b*bigMod(b, p-1, m))%m;
     else
     {
          T temp = bigMod(b, p>>1, m);
          return (sq(temp))%m;
     }
}

template < class T > T modInverse(T b, T m)
{
     return bigMod(b, m-2, m);
}

template < class T > T power(T b, T p)
{
     T res=1, x=b;
     while(p)
     {
          if(p&1) res*=x;
          x*=x;
          p=p>>1;
     }
     return res;
}

template<typename T> inline bool isOn(T mask,T pos)
{
    return mask&(1<<pos);
}

template<typename T> inline int Off(T mask,T pos)
{
    return mask^(1<<pos);
}

template<typename T> inline int On(T mask,T pos)
{
    return mask|(1<<pos);
}

bool stringMod(string a, long long n)
{
     long long num=0;
     for(long i=0; i<a.size(); i++)
          num=((num*10) + (a[i]-'0'))%n;

     if(num==0)
          return 1;
     else
          return 0;
}

bool prime[Mx+2];
vector <long long> primes;

void seive()
{
     for(long long i=4; i<=Mx; i+=2)
          prime[i]=1;

     for(long long i=3; i*i<=Mx; i+=2)
     {
          if(prime[i]==0)
          {
               for(long long j=2*i; j<=Mx; j+=i)
                    prime[j]=1;
          }
     }

     primes.pb(2);
     for(long long i=3; i<=Mx; i+=2)
          if(prime[i]==0)
               primes.pb(i);
}

int main()
{
    int t;
    int a,b,c,n,m,res=0;
    map<int,int>mp;
    int cc=0;
    cin>>a>>b>>c;
    rep(i,a)
    {

        cin>>n;
        //cout<<b<<" "<<c<<" "<<endl;
        int f=0,ff=0;
        if(n==1)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
           {
               cc++;
           }
        }
        if(n==2)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
            {
                if(c>0)
                {
                    c--;
                    ff=1;
                }
            }
            if(f==0 and ff==0)res++;
        }

    }

    cout<<res+cc<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;

#define FastIO           ios_base::sync_with_stdio(0)

#define Read(f)          freopen(f, "r", stdin)
#define Write(f)         freopen(f, "w", stdout)

#define Mem(a, b)        memset(a, b, sizeof a)
#define MemCp(a, b)      memcopy(a, b, sizeof a)
#define RADIANS(x)       (((1.0 * x * PI) / 180.0))
#define DEGREES(x)       (((x * 180.0) / (1.0 * pi)))
#define sq(x)            ((x)*(x))
#define debug(x)         cerr<<__LINE__<<" "<<#x<<" "<<x<<endl;

#define eps              1e-8
#define Pi               (2*acos(0.0))
#define INF              0x7f7f7f7f

#define in               scanf
#define out              printf
#define pb               push_back
#define popb             pop_back
#define ll             long long
#define ull           unsigned long long
#define ff              first
#define ss              second
#define mp               make_pair

#define Mx               10000005
#define Mod              10000

long dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
long dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

template < class T > T Abs(T a)
{
    return (a < 0 ? -a : a);
}

template < class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd(b, a%b) : a);
}

template < class T > T lcm(T a, T b)
{
    return ((a*b)/gcd(a, b));
}

template < class T > T bigMod(T b, T p, T m)
{
     if(p==0)
          return 1;
     else if( p & 1 )
          return ( b*bigMod(b, p-1, m))%m;
     else
     {
          T temp = bigMod(b, p>>1, m);
          return (sq(temp))%m;
     }
}

template < class T > T modInverse(T b, T m)
{
     return bigMod(b, m-2, m);
}

template < class T > T power(T b, T p)
{
     T res=1, x=b;
     while(p)
     {
          if(p&1) res*=x;
          x*=x;
          p=p>>1;
     }
     return res;
}

template<typename T> inline bool isOn(T mask,T pos)
{
    return mask&(1<<pos);
}

template<typename T> inline int Off(T mask,T pos)
{
    return mask^(1<<pos);
}

template<typename T> inline int On(T mask,T pos)
{
    return mask|(1<<pos);
}

bool stringMod(string a, long long n)
{
     long long num=0;
     for(long i=0; i<a.size(); i++)
          num=((num*10) + (a[i]-'0'))%n;

     if(num==0)
          return 1;
     else
          return 0;
}

bool prime[Mx+2];
vector <long long> primes;

void seive()
{
     for(long long i=4; i<=Mx; i+=2)
          prime[i]=1;

     for(long long i=3; i*i<=Mx; i+=2)
     {
          if(prime[i]==0)
          {
               for(long long j=2*i; j<=Mx; j+=i)
                    prime[j]=1;
          }
     }

     primes.pb(2);
     for(long long i=3; i<=Mx; i+=2)
          if(prime[i]==0)
               primes.pb(i);
}

int main()
{
    int t;
    int a,b,c,n,m,res=0;
    map<int,int>mp;
    int cc=0;
    cin>>a>>b>>c;
    int ar[100100];
    rep(i,a)
    cin>>ar[i];
    sort(ar,ar+a);
    rep(i,a)
    {

        //cin>>n;
        //cout<<b<<" "<<c<<" "<<endl;
        int f=0,ff=0;
        if(ar[i]==1)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
           {
               cc++;
           }
        }
        if(ar[i]==2)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
            {
                if(c>0)
                {
                    c--;
                    ff=1;
                }
            }
            if(f==0 and ff==0)res++;
        }
    }
    cout<<res+cc<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;

#define FastIO           ios_base::sync_with_stdio(0)

#define Read(f)          freopen(f, "r", stdin)
#define Write(f)         freopen(f, "w", stdout)

#define Mem(a, b)        memset(a, b, sizeof a)
#define MemCp(a, b)      memcopy(a, b, sizeof a)
#define RADIANS(x)       (((1.0 * x * PI) / 180.0))
#define DEGREES(x)       (((x * 180.0) / (1.0 * pi)))
#define sq(x)            ((x)*(x))
#define debug(x)         cerr<<__LINE__<<" "<<#x<<" "<<x<<endl;

#define eps              1e-8
#define Pi               (2*acos(0.0))
#define INF              0x7f7f7f7f

#define in               scanf
#define out              printf
#define pb               push_back
#define popb             pop_back
#define ll             long long
#define ull           unsigned long long
#define ff              first
#define ss              second
#define mp               make_pair

#define Mx               10000005
#define Mod              10000

long dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
long dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

template < class T > T Abs(T a)
{
    return (a < 0 ? -a : a);
}

template < class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd(b, a%b) : a);
}

template < class T > T lcm(T a, T b)
{
    return ((a*b)/gcd(a, b));
}

template < class T > T bigMod(T b, T p, T m)
{
     if(p==0)
          return 1;
     else if( p & 1 )
          return ( b*bigMod(b, p-1, m))%m;
     else
     {
          T temp = bigMod(b, p>>1, m);
          return (sq(temp))%m;
     }
}

template < class T > T modInverse(T b, T m)
{
     return bigMod(b, m-2, m);
}

template < class T > T power(T b, T p)
{
     T res=1, x=b;
     while(p)
     {
          if(p&1) res*=x;
          x*=x;
          p=p>>1;
     }
     return res;
}

template<typename T> inline bool isOn(T mask,T pos)
{
    return mask&(1<<pos);
}

template<typename T> inline int Off(T mask,T pos)
{
    return mask^(1<<pos);
}

template<typename T> inline int On(T mask,T pos)
{
    return mask|(1<<pos);
}

bool stringMod(string a, long long n)
{
     long long num=0;
     for(long i=0; i<a.size(); i++)
          num=((num*10) + (a[i]-'0'))%n;

     if(num==0)
          return 1;
     else
          return 0;
}

bool prime[Mx+2];
vector <long long> primes;

void seive()
{
     for(long long i=4; i<=Mx; i+=2)
          prime[i]=1;

     for(long long i=3; i*i<=Mx; i+=2)
     {
          if(prime[i]==0)
          {
               for(long long j=2*i; j<=Mx; j+=i)
                    prime[j]=1;
          }
     }

     primes.pb(2);
     for(long long i=3; i<=Mx; i+=2)
          if(prime[i]==0)
               primes.pb(i);
}

int main()
{
    int t;
    int a,b,c,n,m,res=0;
    map<int,int>mp;
    int cc=0;
    cin>>a>>b>>c;
    rep(i,a)
    {

        cin>>n;
        //cout<<b<<" "<<c<<" "<<endl;
        int f=0,ff=0;
        if(n==1)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
           {
               cc++;
           }
        }
        if(n==2)
        {
         /*   if(b>0)
            {
                b--;
                f=1;
            }*/
            if(f==0)
            {
                if(c>0)
                {
                    c--;
                    ff=1;
                }
            }
            if(f==0 and ff==0)res++;
        }
        //cout<<b<<" "<<c<<endl;

    }
    while(cc)
    {
        if(c<=1)break;
        c-=2;
        cc--;
    }
    cout<<res+cc<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;

#define FastIO           ios_base::sync_with_stdio(0)

#define Read(f)          freopen(f, "r", stdin)
#define Write(f)         freopen(f, "w", stdout)

#define Mem(a, b)        memset(a, b, sizeof a)
#define MemCp(a, b)      memcopy(a, b, sizeof a)
#define RADIANS(x)       (((1.0 * x * PI) / 180.0))
#define DEGREES(x)       (((x * 180.0) / (1.0 * pi)))
#define sq(x)            ((x)*(x))
#define debug(x)         cerr<<__LINE__<<" "<<#x<<" "<<x<<endl;

#define eps              1e-8
#define Pi               (2*acos(0.0))
#define INF              0x7f7f7f7f

#define in               scanf
#define out              printf
#define pb               push_back
#define popb             pop_back
#define ll             long long
#define ull           unsigned long long
#define ff              first
#define ss              second
#define mp               make_pair

#define Mx               10000005
#define Mod              10000

long dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
long dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

template < class T > T Abs(T a)
{
    return (a < 0 ? -a : a);
}

template < class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd(b, a%b) : a);
}

template < class T > T lcm(T a, T b)
{
    return ((a*b)/gcd(a, b));
}

template < class T > T bigMod(T b, T p, T m)
{
     if(p==0)
          return 1;
     else if( p & 1 )
          return ( b*bigMod(b, p-1, m))%m;
     else
     {
          T temp = bigMod(b, p>>1, m);
          return (sq(temp))%m;
     }
}

template < class T > T modInverse(T b, T m)
{
     return bigMod(b, m-2, m);
}

template < class T > T power(T b, T p)
{
     T res=1, x=b;
     while(p)
     {
          if(p&1) res*=x;
          x*=x;
          p=p>>1;
     }
     return res;
}

template<typename T> inline bool isOn(T mask,T pos)
{
    return mask&(1<<pos);
}

template<typename T> inline int Off(T mask,T pos)
{
    return mask^(1<<pos);
}

template<typename T> inline int On(T mask,T pos)
{
    return mask|(1<<pos);
}

bool stringMod(string a, long long n)
{
     long long num=0;
     for(long i=0; i<a.size(); i++)
          num=((num*10) + (a[i]-'0'))%n;

     if(num==0)
          return 1;
     else
          return 0;
}

bool prime[Mx+2];
vector <long long> primes;

void seive()
{
     for(long long i=4; i<=Mx; i+=2)
          prime[i]=1;

     for(long long i=3; i*i<=Mx; i+=2)
     {
          if(prime[i]==0)
          {
               for(long long j=2*i; j<=Mx; j+=i)
                    prime[j]=1;
          }
     }

     primes.pb(2);
     for(long long i=3; i<=Mx; i+=2)
          if(prime[i]==0)
               primes.pb(i);
}

int main()
{
    int t;
    int a,b,c,n,m,res=0;
    map<int,int>mp;
    int cc=0;
    cin>>a>>b>>c;
    rep(i,a)
    {

        cin>>n;
        //cout<<b<<" "<<c<<" "<<endl;
        int f=0,ff=0;
        if(n==1)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(b==0 and f==0)
           {
               cc++;
           }
        }
        if(n==2)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(b==0 and f==0)
            {
                if(c>0)
                {
                    c--;
                    ff=1;
                }
            }
            if(f==0 and ff==0)res++;
        }
        //cout<<b<<" "<<c<<endl;

    }
    while(cc)
    {
        if(c<=1)break;
        cc--;
    }
    cout<<res+cc<<endl;
    return 0;
}


using namespace std;
#include<bits/stdc++.h>
typedef long long  ll;

///Print
#define pf(a)  printf("%lld",a)
#define pff(a,b)  printf("%lld %lld",a,b)
#define pfff(a,b,c)  printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define spc printf(" ")
#define Ca(no) printf("Case %lld: ",++no)
#define Canl(no) printf("Case %lld:\n",++no)
#define Cah(no) printf("Case #%lld: ",++no)
#define Cahnl(no) printf("Case #%lld:\n",++no)

///Scanf
#define sf(n)       scanf("%lld", &n)
#define sff(a,b)    scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)

///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FOR(x,m,n) for(__typeof(n) x=(m);x<=(n);x++)
#define foreach(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)

///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define sqr(x) ((x)*(x))
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define xx first
#define yy second

///Min AND Max
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))

#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))

#define inf (1e15)
#define eps (1e-9)
#define PI acos(-1.0)
#define pi 3.14159265358979323846
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Dist(x1,y1,x2,y2) (sqrt(sqr((x1)-(x2))+sqr((y1)-(y2))))
#define spDist(lat1,long1,lat2,long2,r) ((r)*acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos((long1)-(long2))))
#define area(x1,y1,x2,y2,x3,y3) ( x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2) )
#define sqr(x) ((x)*(x))
#define distSqr(x1,y1,x2,y2) ( sqr(x1-x2) + sqr(y1-y2) )
#define dist4adj(x1,y1,x2,y2) ( abs(x1-x2) + abs(y1-y2) )
#define dist8adj(x1,y1,x2,y2) max( abs(x1-x2) , abs(y1-y2) )

///File
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)

/**Define Bitwise operation**/

template<class T> inline T lowbit(T n){return (n^(n-1))&n;}//NOTES:lowbit(
template<class T> inline int countbit(T n){return (n==0)?0:(1+countbit(n&(n-1)));}
#define check(n, pos) (n & (1<<(pos)))
#define biton(n, pos) (n | (1<<(pos)))
#define bitoff(n, pos) (n & ~(1<<(pos)))

#define ledzero(n) (__builtin_clz(n))
#define trailzero(n) (__builtin_ctz(n))
#define onbit(n) (__builtin_popcount(n))

///upper bound and lower bound
#define LB(a,value) (lower_bound(all(a),value)-a.begin())
#define UB(a,value) (upper_bound(all(a),value)-a.begin())

///DEBUG
#define dbg(x) cout<<#x<<": "<<x<<endl
#define dbgar(i,a) cout<<#a<<"["<<i<<"] = "<<a[i]<<" "<<endl

#define trace(x) cerr<<x<<endl;
#define d1(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define d2(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define d3(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" = "<<z<<endl;
#define d4(a,b,c,d) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#a" = "<<a<<" | "#b" = "<<b<<" | "#c" = "<<c<<" | "#d" = "<<d<<endl;
#define d5(a,b,c,d,e) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#a" = "<<a<<" | "#b" = "<<b<<" | "#c" = "<<c<<" | "#d" = "<<d<<" | "#e" = "<<e<<endl;
#define d6(a,b,c,d,e,f) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#a" = "<<a<<" | "#b" = "<<b<<" | "#c" = "<<c<<" | "#d" = "<<d<<" | "#e" = "<<e<<" | "#f" = "<<f<<endl;

///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}

///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
template<class T> inline T Mod(T n,T m) {return (n%m+m)%m;} ///For Positive Negative No.

template<class T>T multiplication(T n,T p,T m){if(p==0)return (T)0;T x=multiplication(n,p/2,m);x=(x+x)%m;if(p&1)x=(x+n)%m;return x;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}

///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}/// extract words or numbers from a line

template<class T> string itos(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}///NOTES:toString(
ll stoi(string s){ll r=0;istringstream sin(s);sin>>r;return r;}///NOTES:toInt(
double toDouble(string s){double r=0;istringstream sin(s);sin>>r;return r;}

/**Direction**/
///8 Direction
///int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
///4 Direction
///int col[4] = {1, 0, -1, 0};int row[4] = {0, 1, 0, -1};
///Knight Direction
///int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};
///Hexagonal Direction
///int dx[]={-1,-1,+0,+1,+1,+0};int dy[]={-1,+1,+2,+1,-1,-2};
///struct

struct node
{
    ll x,y;
    ll z;
}arr[200005];

bool com(node a, node b)
{
    return a.x<b.x;
}

typedef   queue <int> qi;
typedef   pair<ll,ll>  pii;
typedef   vector< pii > vpii;
typedef   vector<long long>   vi;
typedef   vector<string>  vs;
typedef   vector<char> vc;
///MAP
typedef   map<string,ll>  msi;
typedef   map<ll,ll>  mii;
typedef   map<char,ll>  mci;
typedef map<char,char>  mcc;

ll b,c=0,n,m,r=0,rr=0,f=0,ff=0,ks=0,res=0;

ll ar[654321],ar1[654321];mii mpp;

 string s,s1,s2;

int main()
{
    //ios_base::sync_with_stdio(false);
   // cin.tie(false);
   ll n,a,b;

   cin>>n>>a>>b;

   rep(i,n)
   {
       cin>>ar[i];
   }

   rep(i,n)
   {
       if(ar[i]==1)
       {
           if(a==0)c++;
           else a--;
       }
       else
       {
           if(b==0)
           {
               if(a==0)
               {
                   c++;
               }
               else a--;
           }
           else b--;
       }
   }
   cout<<c;

   return 0;

}


#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;

#define FastIO           ios_base::sync_with_stdio(0)

#define Read(f)          freopen(f, "r", stdin)
#define Write(f)         freopen(f, "w", stdout)

#define Mem(a, b)        memset(a, b, sizeof a)
#define MemCp(a, b)      memcopy(a, b, sizeof a)
#define RADIANS(x)       (((1.0 * x * PI) / 180.0))
#define DEGREES(x)       (((x * 180.0) / (1.0 * pi)))
#define sq(x)            ((x)*(x))
#define debug(x)         cerr<<__LINE__<<" "<<#x<<" "<<x<<endl;

#define eps              1e-8
#define Pi               (2*acos(0.0))
#define INF              0x7f7f7f7f

#define in               scanf
#define out              printf
#define pb               push_back
#define popb             pop_back
#define ll             long long
#define ull           unsigned long long
#define ff              first
#define ss              second
#define mp               make_pair

#define Mx               10000005
#define Mod              10000

long dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
long dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

template < class T > T Abs(T a)
{
    return (a < 0 ? -a : a);
}

template < class T > T gcd(T a, T b)
{
    return (b != 0 ? gcd(b, a%b) : a);
}

template < class T > T lcm(T a, T b)
{
    return ((a*b)/gcd(a, b));
}

template < class T > T bigMod(T b, T p, T m)
{
     if(p==0)
          return 1;
     else if( p & 1 )
          return ( b*bigMod(b, p-1, m))%m;
     else
     {
          T temp = bigMod(b, p>>1, m);
          return (sq(temp))%m;
     }
}

template < class T > T modInverse(T b, T m)
{
     return bigMod(b, m-2, m);
}

template < class T > T power(T b, T p)
{
     T res=1, x=b;
     while(p)
     {
          if(p&1) res*=x;
          x*=x;
          p=p>>1;
     }
     return res;
}

template<typename T> inline bool isOn(T mask,T pos)
{
    return mask&(1<<pos);
}

template<typename T> inline int Off(T mask,T pos)
{
    return mask^(1<<pos);
}

template<typename T> inline int On(T mask,T pos)
{
    return mask|(1<<pos);
}

bool stringMod(string a, long long n)
{
     long long num=0;
     for(long i=0; i<a.size(); i++)
          num=((num*10) + (a[i]-'0'))%n;

     if(num==0)
          return 1;
     else
          return 0;
}

bool prime[Mx+2];
vector <long long> primes;

void seive()
{
     for(long long i=4; i<=Mx; i+=2)
          prime[i]=1;

     for(long long i=3; i*i<=Mx; i+=2)
     {
          if(prime[i]==0)
          {
               for(long long j=2*i; j<=Mx; j+=i)
                    prime[j]=1;
          }
     }

     primes.pb(2);
     for(long long i=3; i<=Mx; i+=2)
          if(prime[i]==0)
               primes.pb(i);
}

int main()
{
    int t;
    int a,b,c,n,m,res=0;
    map<int,int>mp;
    int cc=0;
    cin>>a>>b>>c;
    rep(i,a)
    {

        cin>>n;
        //cout<<b<<" "<<c<<" "<<endl;
        int f=0,ff=0;
        if(n==1)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
           {
               cc++;
           }
        }
        if(n==2)
        {
            if(b>0)
            {
                b--;
                f=1;
            }
            if(f==0)
            {
                if(c>0)
                {
                    c--;
                    ff=1;
                }
            }
            if(f==0 and ff==0)res++;
        }
        //cout<<b<<" "<<c<<endl;

    }
    while(cc)
    {
        if(c<=1)break;
        c-=1;
        cc--;
    }
    cout<<res+cc<<endl;
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[4]={0},b;
    for(int i=0;i<n;i++)
    cin>>b,a[b]++;
    cout<<(a[1]-m>0?a[1]-m:0)+(a[2]-k>0?a[2]-k:0)<<endl;
}


#include <iostream>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[4]={0},b;
    for(int i=0;i<n;i++)
    cin>>b,a[b]++;
    int a1=m-a[1],a2=a[1]-m,b1=k-a[2],b2=a[2]-k;
    if(a1<=0)cout<<a2+(b1>0?0:b2)<<endl;
    else cout<<(b1<0?0:b2-a1)<<endl;

}


#include <iostream>
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[4]={0},b;
    for(int i=0;i<n;i++)
    cin>>b,a[b]++;
    int a1=m-a[1],a2=a[1]-m,b1=k-a[2],b2=a[2]-k;
    if(a1<=0)cout<<a2+(b1>0?0:b2)<<endl;
    else cout<<(b1>0?0:b2-a1)<<endl;

}


#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main()
{
       int n,b,p;
       int i,j,k,x;
       int sum=0;
       vector<int> a;

       cin>>n>>b>>p;
       for(i=0;i<n;i++)
       {
           cin>>x;
           a.push_back(x);
       }

       for(i=0;i<n;i++)
       {
            if(a[i]==1)
                {
                    if(b>0)
                    {
                        b--;
                    }

                    else
                    {
                        sum++;
                    }
                }
            else
            {
                    if(b>0 && p>0)
                    {
                            if(b>p)
                                b--;
                            else
                                p--;
                    }

                    else if(b>0 && p<=0)
                    {
                        b--;
                    }
                    else if(b<=0 && p>0)
                    {
                        p--;
                    }
                    else
                    {
                        sum++;
                    }
            }
       }

       cout<<sum;

       return 0;
}


#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main()
{
       int n,b,p;
       int i,j,k,x;
       int sum=0;
       vector<int> a;

       cin>>n>>b>>p;
       for(i=0;i<n;i++)
       {
           cin>>x;
           a.push_back(x);
       }

       for(i=0;i<n;i++)
       {
            if(a[i]==1)
                {
                    if(b>0)
                    {
                        b--;
                    }

                    else
                    {
                        sum++;
                    }
                }
            else
            {
                    if(b>0 && p>0)
                    {
                            if(b>p)
                                b--;
                            else
                                p--;
                    }

                    else if(b>0 && p<=0)
                    {
                        b--;
                    }
                    else if(b<=0 && p>0)
                    {
                        p--;
                    }
                    else if(b<0 && p<0)
                    {
                        sum++;
                    }
            }
       }

       cout<<sum;

       return 0;
}


#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main()
{
       int n,b,p;
       int i,j,k,x;
       int sum=0;

       cin>>n>>b>>p;
       int a[n];
       for(i=0;i<n;i++)
       {
           cin>>a[i];
       }

       for(i=0;i<n;i++)
       {
            if(a[i]==1)
                {
                    if(b>0)
                    {
                        b--;
                    }

                    else
                    {
                        sum++;
                    }
                }
            else
            {
                    if(b>0 && p>0)
                    {
                            if(b>p)
                                b--;
                            else
                                p--;
                    }

                    else if(b>0 && p<=0)
                    {
                        b--;
                    }
                    else if(b<=0 && p>0)
                    {
                        p--;
                    }
                    else if(b<=0 && p<=0)
                    {
                        sum++;
                    }
            }
       }

       cout<<sum;

       return 0;
}
//


#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main()
{
       int n,b,p;
       int i,j,k,x;
       int sum=0;

       cin>>n>>b>>p;
       int a[n];
       for(i=0;i<n;i++)
       {
           cin>>a[i];
       }

       for(i=0;i<n;i++)
       {
            if(a[i]==1)
                {
                    if(b>0)
                    {
                        b--;
                    }

                    else
                    {
                        sum++;
                    }
                }
            else
            {
                    if(b>0 && p>0)
                    {
                            if(b>p)
                                b--;
                            else
                                p--;
                    }

                    else if(b>0 && p<=0)
                    {
                        b--;
                    }
                    else if(b<=0 && p>0)
                    {
                        p--;
                    }
                    else if(b<=0 && p<=0)
                    {
                        sum++;
                    }
            }
       }

       cout<<sum;

       return 0;
}