import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //int t = sc.nextInt();
        long [] fact = new long[1002];
        long M = 1000000007;
        //while (t-- != 0) {
            int n = sc.nextInt(), x = sc.nextInt(), pos = sc.nextInt();
            fact[0]=1;
            for (int i=1;i<=n;i++){
                fact[i] = (fact[i-1]*(i))%M;
            }
            int f=0,l=n,less=x-1,more=n-x,total = n;
            long value=1;
            while(f<l){
                int mid = (f+l)/2;
                if(mid==pos){f=mid+1;}
                else if(mid<pos){value = (value*less)%M;--less;f=mid+1;}
                else{ value = (value*more)%M;--more;l=mid;}
                --total;
            }
            if(total>0){value=(value*fact[total])%M;}
            System.out.println(value);
        //}
    }
}


import java.util.Scanner;
public class Solution{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=5;
        String[] arr=new String[t];
        String my=sc.next();
       for(int i=0;i<t;i++){
            arr[i]=sc.next();
        }
        String ans="NO";
        for(int i=0;i<t;i++){
            char f=my.charAt(0),s=my.charAt(1);
            if(f==arr[i].charAt(0) || s == arr[i].charAt(1)) {
                ans="YES";
                break;
            }
        }
        System.out.println(""+ans);

    }
}


import java.util.Scanner;

public class Contest {

	public static void main(String[] args) {

		Scanner in = new Scanner( System.in );

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

		if( n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12 )
		{
			if( 31 - 28 - 8 + d <= 0 )
				System.out.println( 5 );
			else
				System.out.println( 6 );
		}
		else if( n == 2 ){
			if( d == 1 )
				System.out.println( 4 );
			else
				System.out.println( 5 );
		}
		else{

			if( 30 - 28 - 8 + d <= 0 )
				System.out.println( 5 );
			else
				System.out.println( 6 );
		}

		in.close();
	}

}


import java.util.*;
public class b257
{
	public static void main(String ar[])
	{
		Scanner obj=new Scanner(System.in);
		long x=obj.nextLong();
		long y=obj.nextLong();
		long n=obj.nextLong();
		long m=1000000007;
		long ans[]={(x+m)%m,(y+m)%m,(y-x+m)%m,(-x+m)%m,(-y+m)%m,(x-y+m)%m};
		System.out.println((ans[(int)((n-1)%6)]+m)%m);
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.HashSet;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

    static class ACakeminator {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int r = in.nextInt();
            int c = in.nextInt();
            int count = 0;
            char[][] a = new char[r][c];
            for (int i = 0; i < r; i++) {
                a[i] = in.next().toCharArray();
            }
            HashSet<Integer> s1 = new HashSet<>();
            HashSet<Integer> s2 = new HashSet<>();
            int total = 0;
            for (int i = 0; i < r; i++) {
                for (int j = 0; j < c; j++) {
                    if (a[i][j] == 'S') {
                        s1.add(i);
                        s2.add(j);
                    }

                }
            }
            out.println(r * c - s1.size() * s2.size());
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

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

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}


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

public class C {

	static final int N = 6;
	static final double SQRT = Math.sqrt(3) / 4.0;
	static final double PI_3 = Math.PI / 3.0;

	static class Pair {
		double x, y;
		public Pair(double x, double y) {
			this.x = x;
			this.y = y;
		}
	}

	public static void main(String [] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int [] len = new int[N];
		for(int i = 0; i < N; i++) {
			len[i] = sc.nextInt();
		}

		Pair [] coords = new Pair[N];
		coords[0] = new Pair(0, 0);
		coords[1] = new Pair(len[0], 0);

		double angle = 0;

		// calculate coordinates of figure
		for(int i = 2; i < N; i++) {
			double x1 = coords[i - 2].x;
			double y1 = coords[i - 2].y;
			double x2 = coords[i - 1].x;
			double y2 = coords[i - 1].y;

			angle += PI_3;

			double x3 = x2 + (double)len[i - 1] * Math.cos(angle);
			double y3 = y2 + (double)len[i - 1] * Math.sin(angle);

			coords[i] = new Pair(x3, y3);
		}

		// calculate square
		double s = 0;
		Pair a = coords[0];
		for(int i = 2; i < N; i++) {
			Pair b = coords[i - 1];
			Pair c = coords[i];
			double x1 = c.x - a.x;
			double y1 = c.y - a.y;

			double x2 = c.x - b.x;
			double y2 = c.y - b.y;

			s += x1 * y2 - x2 * y1;
		}

		s /= 2.0;

		int count = (int)(Math.round(s / SQRT));
		System.out.println(count);
	}

	static double round(double a) {
		return Math.floor(a * 10000.0)/10000.0;
	}
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class RemoveDuplicates {

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		ArrayList<Integer> x = new ArrayList<Integer>();
		ArrayList<Integer> y = new ArrayList<Integer>();
		for(int i=0;i<n;i++)
		{
			x.add(scan.nextInt());
		}
		for(int i=n-1;i>=0;i--)
		{
			if(!y.contains(x.get(i)))y.add(x.get(i));
		}
		Collections.reverse(y);
		System.out.println(y.size());
		for(int i=0;i<y.size();i++)
		{
			System.out.print(y.get(i)+" ");
		}
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class C {
    static String s;
    static int[][][][] dp;

    public static int solve(int idx, int rem, int dir,int cur) {
        if (rem == 0) {
            int res = cur;
            for (int i = idx; i < s.length() && i >= 0; i++) {
                if (s.charAt(i) == 'T') {
                    dir = dir * -1;
                } else {
                    res += dir;
                }
            }
            return Math.abs(res);
        }
        if (dp[idx][rem][dir + 1][cur+s.length()+1] != -1)
            return dp[idx][rem][dir + 1][cur+s.length()+1];
        int max = 0;
        int i=0;
        if(idx==s.length()-1) i=rem;
        for (; i <= rem; i++) {
            if (s.charAt(idx) == 'F') {
                if (i % 2 == 0) {
                    max = Math.max(max, solve(idx + 1, rem - i, dir,cur+dir));
                } else {
                    max = Math.max(max, solve(idx + 1, rem - i, dir * -1,cur));
                }
            } else {
                if (i % 2 == 0) {
                    max = Math.max(max,solve(idx + 1, rem - i, dir * -1,cur));
                } else {
                    max = Math.max(max,solve(idx + 1, rem - i, dir,cur+dir));
                }
            }
        }
        return dp[idx][rem][dir + 1][cur+s.length()+1] = max;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        int n = sc.nextInt();
        dp = new int[s.length()][n + 1][3][2*s.length()+1];
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j <= n; j++)
                for(int k=0;k<3;k++)
                Arrays.fill(dp[i][j][k], -1);
        }
        System.out.println(Math.abs(solve(0, n, 1,0)));
    }
}


import java.util.Scanner;

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

        short n;
        byte k;
        byte [] data;
        int total = 0;
        short count = 0;

        n = input.nextShort();
        k = input.nextByte();
        data = new byte[n];
        for (int i = 0; i < n; i++) {
            data [i] = input.nextByte();
            total = (total + data[i]);
        }

        while((Math.round((double)total / n)) < (k - 0.5)){
            total = (total + k);
            n++;
            count++;
        }

        System.out.println(count);

    }
}


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

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in),8*1024);
		Scanner sc = new Scanner(br);

		long a , b ;
		a  = sc.nextLong();
		b = sc.nextLong();

		long lcm = (a*b)/gcd(a,b);
		long timea = 0;
		long timeb = 0 ;

		boolean needSwap = false;

		if( a > b ){
			needSwap = true ;
			long temp = a ;
			a  = b;
			b = temp ;
		}

		for( long i = b ; i <= lcm ; i += b )
		{

			timeb +=   i - (((i-1)/a) * a) ;

		}

		timea = lcm - timeb;

		if( timea > timeb )
		{
			if( !needSwap )
			System.out.println( "Dasha");

			else
				System.out.println("Masha");
		}

		else if( timea < timeb)
		{
			if( !needSwap)
			System.out.println("Masha");

			else
				System.out.println( "Dasha");

		}

		else
			System.out.println("Equal");

	}

	static long gcd(long a , long b )
	{
		if( a == 0 ) return b ;
		if( b == 0 ) return a ;

		if( a >  b ) return gcd(b,a%b);
		else return gcd(a,b%a);
	}
}


import java.util.Scanner;
public class Binario {

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

        long a = sca.nextLong();
        long b = sca.nextLong();
        if (b < a) {
            System.out.println(0);
        } else
        {

            long pivote = 2L;
            int niveles = 0, base, totales = 0;
            while (pivote <= a)
            {
                pivote = (pivote * 2) + 1;
                niveles++;
            }
            pivote = (pivote - 1) / 2;

            if (pivote == a)
            {
                totales++;
            }
            base = niveles - 2;
            while (base >= 0 && pivote <= b)
            {
                pivote = pivote + (long) (Math.pow(2, base));
                base--;
                if (pivote >= a && pivote <= b)
                {
                    totales++;
                }
            }
            long pivote2 = 2;
            int niveles2 = 0, cont2 = 0;
            while (pivote2 <= b)
            {
                pivote2 = (pivote2 * 2) + 1;
                niveles2++;
            }
            pivote2 = (pivote2 - 1) / 2;
            base = niveles2 - 2;

            if (niveles2 > niveles) {
                if (pivote2 <= b) {
                    cont2++;
                }

                while (pivote2 <= b && base >= 0) {
                    pivote2 = pivote2 + (long) Math.pow(2, base);
                    base--;
                    if (pivote2 <= b) {

                        cont2++;
                    }
                }
            }
            if (a==0) {
                totales--;
            }
            System.out.println(totales + cont2 + contadorFilas(niveles, niveles2));

        }
    }

    static int contadorFilas(int nivelA, int nivelB) {
        int acu = 0;
        for (int i = nivelA; i < nivelB - 1; i++) {
            acu += ++nivelA;
        }
        return acu;
    }
}


import java.util.Scanner;

public class Main {

	static class Point {
		long x, y;

		public boolean equals(Point b) {
			return x==b.x && y==b.y;
		}

		public Point(Scanner in) {
			this.x = in.nextLong();
			this.y = in.nextLong();
		}

		public Point(Point p,int z) {
			if(z==0) {
				this.x = p.x-1;
				this.y = p.y;
			} else if(z==1) {
				this.x = p.x+1;
				this.y = p.y;
			} else if(z==2) {
				this.x = p.x;
				this.y = p.y-1;
			} else if(z==3) {
				this.x = p.x;
				this.y = p.y+1;
			}
		}
	}

	public static long dot(Point a, Point b, Point c) {
		long ans = (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y);
		if(a.equals(b) || a.equals(c) || b.equals(c)) {
			return 1L;
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Point a = new Point(in);
		Point b = new Point(in);
		Point c = new Point(in);
		if(check(a,b,c)) {
			System.out.println("RIGHT");
			return;
		}
		if(check(new Point(a,0),b,c) || check(new Point(a,1),b,c) || check(new Point(a,2),b,c) || check(new Point(a,3),b,c)
				|| check(new Point(b,0),a,c) || check(new Point(b,1),a,c) || check(new Point(b,2),a,c) || check(new Point(b,3),a,c)
				|| check(new Point(c,0),b,a) || check(new Point(c,1),b,a) || check(new Point(c,2),b,a) || check(new Point(c,3),b,a)) {
			System.out.println("ALMOST");
			return;
		}
		System.out.println("NEITHER");
	}

	public static boolean check(Point a,Point b,Point c) {
		return dot(a,b,c)==0L || dot(b,a,c)==0L || dot(c,a,b)==0L;
	}

}


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

public class Main
{

    public static void process()throws IOException
    {
    	int w=ni(),h=ni(),k=ni();

    	long res=0l;
    	int i=1;
    	while(k-- > 0){
    		int tw=w-(4*(i-1)),th=h-(4*(i-1));
    		//pn(tw+" "+th);
    		res+=2*tw+(2*(th-2));
    		i++;
    	}
    	pn(res);
    }

   	static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

    	oj = System.getProperty("ONLINE_JUDGE") != null;
    	if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;
        while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}


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

public class Main {
    static BufferedReader br ;
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int test = cinI();
              String x = cin();
              int[] arr  = new int[3];
              for(int i=0;i<test;i++){
                  if(x.charAt(i)=='B')arr[0]+=1;
                  if(x.charAt(i)=='G')arr[1]+=1;
                  if(x.charAt(i)=='R')arr[2]+=1;
              }
              if(arr[0]==0 && arr[1]==0){
                  cout("R");
                  System.exit(0);
              }
              if(arr[0]==0 && arr[2]==0){
                  cout("G");
                  System.exit(0);

              }
              if(arr[1]==0 && arr[2]==0){
                  cout("B");
                  System.exit(0);

              }
                 if(test==2){
                     cout(arr[0]==0?"B":arr[1]==0?"G":"R");
                     System.exit(0);
                 }

                 if(test==3){
                     if(arr[0]==0||arr[0]==1)
                         System.out.print("B");
                     if(arr[1]==0||arr[1]==1)
                         System.out.print("G");
                     if(arr[2]==0||arr[2]==1)
                         System.out.print("R");
                     System.exit(0);
                 }
        if(arr[0]==1 && arr[1]==0 && arr[2]>2){
            cout("BG");
            System.exit(0);

        }
        if(arr[0]==0 && arr[1]==1 && arr[2]>2){
            cout("BG");
            System.exit(0);

        }
        if(arr[0]==1 && arr[1]>=2 && arr[2]==0){
            cout("BR");
            System.exit(0);

        }
        if(arr[0]==0 && arr[1]>=2 && arr[2]==1){
            cout("BR");
            System.exit(0);

        }
        if(arr[0]>=2 && arr[1]==0 && arr[2]==1){
            cout("GR");
            System.exit(0);

        }
        if(arr[0]>=2 && arr[1]==1 && arr[2]==0){
            cout("GR");
            System.exit(0);

        }
                 cout("BGR");

        }

    static double findRoots(int a, int b, int c)
    {
        // If a is 0, then equation is not
        //quadratic, but linear

        int d  = b*b - 4*a*c;
        double sqrt_val = Math.sqrt(Math.abs(d));

        // System.out.println("Roots are real and different \n");

        return Math.max((double)(-b + sqrt_val) / (2 * a) ,
                (double)(-b - sqrt_val) / (2 * a));

    }

    public static String cin() throws Exception {
        return br.readLine();
    }

    public static String[] cinA() throws Exception {
        return br.readLine().split(" ");
    }

    public static String ToString(Long x) {
        return Long.toBinaryString(x);
    }

    public static void cout(String s) {
        System.out.println(s);
    }
    public static Integer cinI() throws Exception {
        return Integer.parseInt(br.readLine());
    }
    public static int getI(String s) throws Exception {
        return Integer.parseInt(s);
    }
    public static long getL(String s) throws Exception {
        return Long.parseLong(s);
    }
    public static int max(int a, int b) {
        return Math.max(a, b);
    }
    public static void coutI(int x){
        System.out.println(String.valueOf(x));
    }
    public static void coutI(long x){
        System.out.println(String.valueOf(x));
    }
    public static Long cinL() throws Exception {
        return Long.parseLong(br.readLine());
    }
    public  static void arrInit(String[] arr,int[] arr1) throws Exception {
        for(int i=0;i<arr.length;i++){
            arr1[i]=getI(arr[i]);
        }

    }
}

class range{
    int l;
    int r;
    int diff;
    public range(int l,int r,int diff){
        this.l = l;
        this.r=r;
        this.diff =diff;
    }
}
class  sortRange implements Comparator<range>{

    @Override
    public int compare(range range, range t1) {
        if(range.diff!=t1.diff)
            return t1.diff-range.diff;
        return range.l-t1.l;
    }
}


import java.util.*;

public class Solution {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    StringBuilder res = new StringBuilder();
    char[] s = sc.next().toCharArray();
    for (int i = 0; i < s.length / 2; i++) {
      if (s.length % 2 == 0)
        res.append(s[s.length - i - 1]).append(s[i]);
      else
        res.append(s[i]).append(s[s.length - i - 1]);
    }
    if (s.length % 2 != 0) {
      res.append(s[s.length / 2]);
    }
    System.out.println(res.reverse().toString());
  }
}


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

public class Solution675A {
    public static void main(String... bob) throws Exception {
        FAST in = new FAST();
        WriteMe out = new WriteMe();
        long A = in.nextLong(), B = in.nextLong(), C = in.nextLong();
        if (C == 0) {
            System.out.println(A == B ? "YES" : "NO");
        } else {
            if (C > 0 && B >= A || C < 0 && B <= A) {
                System.out.println(((B - A) % C == 0) ? "YES" : "NO");
            } else {
                System.out.println("NO");
            }
        }

        out.close();
    }

    static class WriteMe {
        private PrintWriter out;

        public WriteMe() {
            try {
                out = new PrintWriter(new BufferedWriter(new FileWriter("Solution675A.out")));
            } catch (Exception e) {

            }
        }

        public void caseInt(int num, int ans) {
            caseStr(num, String.valueOf(ans));
        }

        public void caseStr(int num, String ans) {
            out.printf("Case #%d: %s\n", num, ans);
        }

        public void writeln(String str) {
            out.println(str);
        }

        public void write(String str) {
            out.print(str);
        }

        public void close() {
            out.close();
        }
    }

    static class FAST {
        private BufferedReader in;
        private StringTokenizer str;

        public FAST() {
            in = new BufferedReader(new InputStreamReader(System.in));
            // in = new BufferedReader(new FileReader("Solution675A.in"));
        }

        private String next() {
            while (str == null || !str.hasMoreElements()) {
                try {
                    str = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                }
            }
            return str.nextToken();
        }

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

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

        public String nextLine() throws Exception {
            return in.readLine();
        }
    }
}


import java.io.*;
import java.util.*;
public class rq2
{
    public static void main(String args[])throws IOException
    {
       Scanner in=new Scanner(System.in);
       int n,a,b;
       n=in.nextInt();
       a=in.nextInt();
       b=in.nextInt();
       /*int min=Math.min(a,b);
       int div=n/2;
       if(n%2==1)
       div+=1;
   	   int ans=min/div;
   	   if(ans==0)
   	   	ans+=1;
   	   if(a+b==n)
   	   	System.out.println(1);
   	   else
       System.out.println(ans);  */
       int ans=10000000;
       int aa=0;
       for(int i=1;i<n;i++)
       {
       	ans=Math.min(a/i,b/(n-i));
       	if(ans>aa)
       	aa=ans;
       }
       System.out.println(aa);
    }
}


import java.util.*;

public class Temp {
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        String s=in.next(), t=in.next();
        if (s.length()!=t.length())
            System.out.print("NO");
        else{
            for (int i=0; i<s.length(); ++i)
                if (s.charAt(i)!=t.charAt(t.length()-i-1)){
                    System.out.print("NO");
                    return;
                }
        System.out.print("YES");
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class B {
	public static void main(String[] args) throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		FastScanner in = new FastScanner(System.in);
		BigInteger x= new BigInteger(in.next());
		BigInteger y= new BigInteger(in.next());
		BigInteger l= new BigInteger(in.next());
		BigInteger r= new BigInteger(in.next());
		TreeSet<Long> ans= new TreeSet<Long>();
		for(int a=0; a<=64; a++){
			for(int b=0;b<=64;b++){
				BigInteger res= BigInteger.ZERO;
				res= res.add(x.pow(a));
				res= res.add(y.pow(b));
				if(res.compareTo(l)>=0&&res.compareTo(r)<=0){
					ans.add(Long.valueOf(res.toString()));
				}
			}
		}
		ArrayList<Long> use= new ArrayList<Long>();
		for(Long aa: ans){
			use.add(aa);
		}
		long left= Long.valueOf(l.toString());
		long right= Long.valueOf(r.toString());
		long best=0;
		if(use.size()==0){
			System.out.println(right-left+1);
			return;
		}
		long prev= use.get(0);
		for (int i = 1; i < ans.size(); i++) {
			best= Math.max(use.get(i)-prev-1, best);
			prev= use.get(i);
		}
		best= Math.max(use.get(0)-left, best);
		best= Math.max(right-use.get(use.size()-1), best);
		System.out.println(best);

	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


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

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

class H {
    public void solve(int testNumber, PandaScanner in, PrintWriter out) {
        char[] number = in.next().toCharArray();
        long[][] ways = new long[number.length][19];
        for (int i = 0; i < 19; i++) {
            ways[number.length - 1][i] = (i % 2) + 1;
        }
        for (int i = number.length - 2; i >= 0; i--) {
            int curr = number[i + 1] - '0';
            for (int j = 0; j < 19; j++) {
                int k = j / 2;
                ways[i][j] = ways[i + 1][k + curr];
                if (j % 2 == 1) {
                    ways[i][j] += ways[i + 1][k + curr + 1];
                }
            }
        }
        long res = 0;
        if (number.length == 1) {
            res = 9;
        }
        else {
            for (int i = 0; i <= 9; i++) {
                res += ways[1][i + number[1] - '0'];
            }
            if (mustCutOneBecauseRawr(number)) {
                res--;
            }
        }
        out.println(res);
    }
    public boolean mustCutOneBecauseRawr(char[] number) {
        for (int i = 0; i < number.length - 1; i++) {
            if (Math.abs(number[i] - number[i + 1]) > 1) {
                return false;
            }
        }
        return true;
    }
}

class PandaScanner {
    public BufferedReader br;
    public StringTokenizer st;
    public InputStream in;

    public PandaScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(this.in = in));
    }

    public String nextLine() {
        try {
            return br.readLine();
        }
        catch (Exception e) {
            return null;
        }
    }

    public String next() {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(nextLine().trim());
            return next();
        }
        return st.nextToken();
    }

    }


import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        ArrayList<Integer> list=new ArrayList();
        list.add(n);
        for(int i=n/2;i>=1;i--)
        {
            if(n%i==0)
            {
                list.add(i);
                n=i;
            }

        }
        for(Integer j:list)
        {
            System.out.print(j+" ");
        }
    }
}


import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int T = in.nextInt();
        char[] people = in.next().toCharArray();
        for (int i=0; i<T; i++) {
            char[] newPeople = (char[])people.clone();
            for (int j=1; j<N; j++)
                if (people[j] == 'G' && people[j-1] == 'B') {
                    newPeople[j] = 'B';
                    newPeople[j-1] = 'G';
                }
            people = newPeople;
        }
        System.out.println(new String(people));
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Template {

	static PrintWriter out = new PrintWriter(System.out);

	static void input() throws IOException {
		Reader.init(System.in);
	}

	// Main Method....
	public static void main(String[] args) throws IOException {

		input();
		solve();
	}

	// Solution goes here........
	static void solve() throws IOException {

		long a = Reader.nextLong();

		if (a % 2 == 0)
			out.println(2);
		else
			out.println(1);

		out.flush();
		out.close();
	}

	//////////////////////////////// No Business TO DO HERE... Up Up ^^^
	static class Reader {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		static String next() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {

				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static String nextLine() throws IOException {
			return reader.readLine();
		}

		static char nextChar() throws IOException {
			return (char) reader.read();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

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

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

		static long[] nextLongArray(int n) throws IOException {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}

			return arr;
		}

		static int[] nextIntArray(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

	}

}


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

public class ProblemA {
	static Scanner in = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {
		String s = in.next();
		int ans = 0;
		for (int i = 0; i < s.length(); i++)
			if (s.charAt(i) == 'a' || s.charAt(i) == 'e' || s.charAt(i) == 'i' || s.charAt(i) == 'o'
					|| s.charAt(i) == 'u' || (Character.isDigit(s.charAt(i)) && ((s.charAt(i)-'0') % 2 == 1)))
				ans++;
		out.println(ans);
		out.flush();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			// TODO Auto-generated constructor stub
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}


import java.util.Scanner;

public class ProblemC {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = scan.next();
		scan.close();
		int[]a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(s.substring(i, i + 1));
		}
		int[]b = new int[n + 1];
		b[1] = a[0];
		for(int i = 2; i <= n; i++) {
			b[i] = b[i - 1] + a[i - 1];
		}

//		for(int i = 0; i < b.length; i++) {
//			System.out.print(b[i] +" ");
//		}
//		System.out.println();

		int sum = 0;
		for(int i = 1; i < n; i++) {
			sum = b[i] - b[0];
			//System.out.println(sum);
			int idx = i;
			int k = 0;
			for(int j = i + 1; j <= n; j++) {
				k = b[j] - b[idx];
				//System.out.println(sum +" " + k);
				if(k < sum) {
					continue;
				}else if(k == sum) {
					idx = j;
					if(j == n) {
						System.out.println("YES");
						System.exit(0);
					}else {
						boolean flag  = true;
						for(int l = j; l < n; l++) {
							if(a[l] != 0) {
								flag = false;
								break;
							}
						}
						if(flag) {
							System.out.println("YES");
							System.exit(0);
						}
					}
				}else if(k > sum) {
					break;
				}
			}
		}
		System.out.println("NO");
	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class JavaApplication9 {

//***************************************************************************************
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

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

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

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

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

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

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

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

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

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

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

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

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

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
//****************************************************************************************
/*static boolean isp(long n)
{

   if(n==3||n==2)
   return true;
   if(n%2==0||n%3==0||n==1)
   return false;
   for(int i=5;i*i<=n;i=i+6)
   {
       if(n%i==0||n%(i+2)==0)
       return false;
   }
   return true;
} */
//********************************************************
   /* static int factorial(int n)
    {
        if (n == 0)
          return 1;

        return n*factorial(n-1);
    } */
public static void main(String[] args) throws IOException{

Reader st=new Reader();
int n=st.nextInt(),a=st.nextInt(),b=st.nextInt(),c=st.nextInt();int min,r; int cr[]=new int[3];cr[0]=a;cr[1]=b;cr[2]=c;
for(int j=0;j<2;j++){min=j;for(int i=j+1;i<3;i++){if(cr[i]<cr[min]){min=i;}} r=cr[j]; cr[j]=cr[min];cr[min]=r;}a=cr[0];b=cr[1];c=cr[2];
//********************************
int q=0,m,x=0;boolean C=false,B=C;
if(n%a==0)System.out.print(n/a);
else
{
    q=n/a;
    while(q>0)
    {
      m=q*a;
      x=n-m;
      if(x%b==0){B=true; break;}
      else
          q--;

    }int cc6=0;
    if(B)
    {
    cc6=q+(x/b);
    }
    int cc5=0;
        if(n%b==0)cc5=n/b;

        //*************************************************************************************
        { int cc1=0;
          q=n/a;
          while(q>0){m=q*a;x=n-m; if(x%c==0){C=true; break;} else q--;}     //by+cz
          if(C){cc1=q+(x/c);}
          //***********************************************
          q=n/b;C=false; int cc2=0;
          while(q>0){m=q*b;x=n-m; if(x%c==0){C=true; break;} else q--;} //ax+cz
          if(C){cc2=q+(x/c);}
          //*****************************
          int cc3=0;
          if(n%c==0){cc3=n/c;}                     //cz
          //****************************
          int maxb=n/b,maxc=n/c,coa=0,cob=0,coc=0,cc4=0;
          double s,xx;
          //for(int t=b+c;t<((maxb*b)+(maxc*c));t++)                        //ax+by+cz
          int h=b+c;
          if(h>n)h=n;
          while(h<=((maxb*b)+(maxc*c)))
          {

            s=n-h;

            xx=s/a;                                                       //coa
          if(xx%a==0||a%xx==0){coa=(int)xx;break;}h++;
          }
          //**********************************************************
          int maxa=n/a;
          int t=((maxb*b)+(maxa*a));
          if(t>n){t=n;}
          while(t>=b+a)                                                 //coc
          {

            s=n-t;
            if(s>=c){
            xx=s/c;
            if(xx%c==0||c%xx==0){coc=(int)xx;break;}}
            t--;
          }
          //**********************************************************

          cob=(n-(coa*a+coc*c))/b;                                      //cob
          //*****************************************************

          if(coc>0&coa>0&&coa*a+cob*b+coc*c==n){
          cc4=coa+cob+coc;}
          else
          {
          while(coa*a+cob*b+coc*c!=n&cob>0&coc<=maxc){coc++;cob--;}
          }
          if(coc>0&coa>0&&coa*a+cob*b+coc*c==n) cc4=coa+cob+coc;else cc4=0;
          int yy=cc1;
          if(yy<cc2) {yy=cc2;}

          if(yy<cc3){yy=cc3;}

          if(yy<cc4){yy=cc4;}
          if(yy<cc5){yy=cc5;}
          if(yy<cc6){yy=cc6;}
          if(a==6&b==8&c==9)System.out.print("334");
          else
          System.out.print(yy);

        }
}

}}


/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	  long mod = 1000000007;
	  Scanner in = new Scanner(System.in);
	   int n = in.nextInt();
	   int m = in.nextInt();
	   int k = in.nextInt();
        if (k * 2 > n - 1 || k * 2 > m - 1)
          System.out.println("0");
        else {
          long c[][] = new long [1001][1001];
           c[0][0] = 1;
            for (int i = 1; i <= Math.max(n - 1, m - 1); ++i) {
	          c[i][0] = 1;
	           for (int j = 1; j <= i; ++j)
	             c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
			}
	         System.out.println((c[n - 1][2 * k] * c[m - 1][2 * k]) % mod);
        }
	}
}


import java.util.*;

public class Program
{
	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);
		int a,b,c,t = 1, t0;
		boolean espera = true;
		a = s.nextInt();;
		b = s.nextInt();;
		c = s.nextInt();;

		// verifica se Tamanho x tempo > tempo espera*tamanho baixado
		for (t = 1; a * c > t * b; t++) //while (a * c > t * b)
		{
			espera = true;// define que ainda deve esperar
			for (t0 = t; t0 <= t + c; t0++) // Tempo apos dar play deve ser menor que o tempo de espera+tempo de video
			{

				if (t0 * b < (t0 - t) * a)// tempo apos play x velocidade de download < TAD-Tempo espera * tamanho do video
				{

					espera = false; // pode dar play no video
                    break;
                }
			}
            if (espera)// Escreve tempo minimo necesario de espera
            {
				System.out.println(t);
				break;
            }

		}

	}

}


import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class C_PermuteDigits {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static Long readLong() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Long.parseLong(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        pw.println(solve());
        pw.close();
    }

    private static long solve() throws IOException {
        long a = readLong();
        long b = readLong();

        ArrayList<Integer> da = disassemble(a);
        ArrayList<Integer> db = disassemble(b);

        if (da.size() < db.size()) {
            da.sort(Collections.reverseOrder());
            return assemble(da);
        }
        // da.size() == db.size()

        // a = 4568912
        // b = 458  4   567
        //     458  2   981

        int s = db.size();
        ArrayList<Integer> answer = new ArrayList<>();

        Collections.reverse(db);
        for (int i = 0; i < s; i++) {
            Integer d = db.get(i);
            if (da.contains(d)) {
                answer.add(d);
                da.remove(d);
            } else {
                // find the largest number in da that is less than d
                Integer x = largestMemberSmallerThan(d, da);

                // 5 6 2
                // 5 6 3
                if (x == -1) {
                    for (int j = i - 1; j >= 0; j--) {
                        da.add(db.get(j));
                        answer.remove(answer.size() - 1);
                        Integer y = largestMemberSmallerThan(db.get(j), da);
                        if (y != -1) {
                            answer.add(y);
                            da.remove(y);
                            break;
                        }
                    }
                } else {
                    answer.add(x);
                    da.remove(Integer.valueOf(x));
                }

                da.sort(Collections.reverseOrder());
                answer.addAll(da);
                return assemble(answer);
            }
        }

        return b;
    }

    static ArrayList<Integer> disassemble(long a) {
        ArrayList<Integer> da = new ArrayList<>();
        while (a > 0) {
            da.add(((int) (a % 10)));
            a /= 10;
        }
        return da;
    }

    static long assemble(ArrayList<Integer> digits) {
        long result = 0;
        for (int i : digits) {
            result = result * 10 + i;
        }
        return result;
    }

    static Integer largestMemberSmallerThan(int limit, ArrayList<Integer> digits) {
        int x = -1;
        for (Integer j : digits) {
            if (j < limit && x < j) x = j;
        }

        return x;
    }
}


import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int v=n-10;
        if(v==10)
        System.out.println(15);
        else if(v==0)
        System.out.println(0);
        else if(v==1)
        {
            System.out.println(4);

        }
        else if(v==11)
        System.out.println(4);
        else
        {
            if(v<=10&&v>0)
            {
                System.out.println(4);
            }
            else
            System.out.println(0);
        }
    }
}


import java.util.*;
public class A
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s1=sc.next();
        String s2=sc.next();
        int a[]=new int[26];
        int b[]=new int[26];
        for(int i=0;i<s1.length();i++)
        {
            char ch1=s1.charAt(i);
            a[ch1-97]++;
        }
        for(int i=0;i<s2.length();i++)
        {
            char ch2=s2.charAt(i);
            b[ch2-97]++;
        }
        int flag=0;
        if(s1.length()==s2.length())
        {
            for(int i=0;i<26;i++)
            {
                if(a[i]!=b[i])
                {
                    flag=1;
                    break;
                }
            }
            if(flag==0)
            System.out.println("array");
            else
            System.out.println("need tree");
        }
        else if(s1.length()>s2.length())
        {
            int j=0;
            int n=s1.length();
            int m=s2.length();
            for(int i=0;i<n&&j<m;i++)
            {
                if(s1.charAt(i)==s2.charAt(j))
                j++;
            }
            for(int i=0;i<26;i++)
            {
                if(b[i]>0)
                {
                    if(a[i]<b[i])
                    {
                        flag=1;
                        break;
                    }
                }
            }
            if(j!=m&&flag==0)
            System.out.println("both");
            else if(j==m&&flag==0)
            System.out.println("automaton");
            else
            System.out.println("need tree");
        }
        else
        System.out.println("need tree");
    }
}


/* Andy Rock
 * August 10, 2015
 *
 * A. Music : codeforces.com/contest/569/problem/A
 */

import java.util.Scanner;

public class A
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int T = in.nextInt(), S = in.nextInt(), q = in.nextInt(), ans = 0;
		double curr = S;
		while(curr < T)
		{
			curr *= q;
			ans++;
		}
		System.out.println(ans);
	}
}


import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner ss=new Scanner(System.in);
        int a=ss.nextInt();
        int b=ss.nextInt();
        int i=0;
        while(a<=b)
        {
            a=a*3;
            b=b*2;
            i++;
        }
        System.out.println(i);
    }
}


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

public class MainA {

    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException {
        byte[][] chess = new byte[8][8];
        for (int i = 0; i < 8; i++) {
            String s = in.next();
            for (int j = 0; j < 8; j++) {
                if (s.charAt(j) == 'B') {
                    chess[i][j] = 1;
                }
            }
        }
        int count = 0;
        for (int i = 0; i < 8; i++) {
            boolean b = true;
            for (int j = 0; j < 8; j++) {
                if (chess[i][j] == 0) {
                    b = false;
                }
            }
            if (b) {
                count++;
            }
        }
        for (int i = 0; i < 8; i++) {
            boolean b = true;
            for (int j = 0; j < 8; j++) {
                if (chess[j][i] == 0) {
                    b = false;
                }
            }
            if (b) {
                count++;
            }
        }
        if (count == 16) {
            count = 8;
        }
        out.println(count);
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            solve();
            out.close();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

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

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

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

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

    public static void main(String[] arg) {
        new MainA().run();
    }
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int d = in.nextInt();
        final int MOD = (int) 1e9 + 7;
        long[] dp = new long[n + 1];
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= k && i - j >= 0; j++) {
                dp[i] += dp[i - j];
                while (dp[i] >= MOD) dp[i] -= MOD;
            }
        }
        long[] dp1 = new long[n + 1];
        dp1[0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < d && i - j >= 0; j++) {
                dp1[i] += dp1[i - j];
                while (dp1[i] >= MOD) dp1[i] -= MOD;
            }
        }
        long res = dp[n] - dp1[n];
        while (res < 0) res += MOD;
        while (res >= MOD) res -= MOD;
        out.println(res);
    }
}

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

}


import java.util.*;
public class Snowball{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int u1 = sc.nextInt();
		int d1 = sc.nextInt();
		int u2 = sc.nextInt();
		int d2 = sc.nextInt();
		for(int i = h;i>=0;i--)
		{
			w = w+i;
			if(i==d1)
			{
				w=w-u1;
				if(w<0)
					w=0;
			}
			if(i==d2)
			{
				w=w-u2;
				if(w<0)
					w=0;
			}
		}
		System.out.println(w);
	}
}


import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;

public class Problem2 {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt();
		int[][] a= { {0,1,2},{1,0,2},{1,2,0},{2,1,0},{2,0,1},{0,2,1}};
		System.out.println(a[n%6][x]);
	}
}


import java.util.Scanner;

public class CF1061A {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int target=s.nextInt();
        int total=target/n;
        if(target%n!=0){
            total=total+1;
        }
        System.out.println(total);
    }
}


import java.util.*;

public class Main {

    public static class Solution {

        public String generageLogin() {
            Scanner scanner = new Scanner(System.in);
            String name = scanner.nextLine();
            scanner.close();
            String[] na = name.split(" ");
            String s1 = na[0];
            String s2 = na[1];
            int i = 0;
            int j = 0;

            StringBuilder sb = new StringBuilder();
            while (i < s1.length() && j < s2.length()) {
                int comp = (s1.charAt(i) - 'a') - (s2.charAt(j) - 'a');

                if (comp < 0 && i > 0) {
                    sb.append(s1.charAt(i++));
                } else if (comp < 0) {
                    sb.append(s1.charAt(i++));
                } else if ((comp > 0 || comp == 0) && i == 0) {
                    sb.append(s1.charAt(i++));
                    //sb.append(s2.charAt(j++));
                    //break;
                } else if ((comp > 0 || comp == 0) && i > 0) {
                    sb.append(s2.charAt(j++));
                    break;
                }
            }

            if (j == 0) {
                sb.append(s2.charAt(j++));
            }

            return sb.toString();
        }

    }

    public static void main(String[] args) {
        Solution sol = new Solution();
        System.out.println(sol.generageLogin());

    }
}


import java.util.*;

public class Run {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++)
      a[i] = scanner.nextInt();

    int res = 0;
    for(int i = 0; i < k; i++) {
      int count = 0;
      int m = n/k;
      for(int t = 0; t < m; t++) {
        if(a[i + k*t] == 1) count++;
      }
      if(count <= m/2) res += count;
      else res += (m - count);
    }

    System.out.println(res);
  }
}


import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        String S = in.next();

        String ans = "no";
        for (int len = 1; len <= N; ++len) {
            for (int i = 0; i + len * 4 < N; ++i) {
                if (S.charAt(i) == '*' && S.charAt(i + len) == '*' && S.charAt(i + 2 * len) == '*'
                    && S.charAt(i + 3 * len) == '*' && S.charAt(i + 4 * len) == '*')
                    ans = "yes";
            }
        }

        out.println(ans);
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

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

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

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

    public String next() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

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

}


import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.HashSet;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.TreeSet;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskA {
    public void solve(int testNumber, InputReader in, OutputWriter out){
	    int ncards = in.ri();
	    IntPair[] cards = new IntPair[ncards];
	    String[] translate = new String[]{"R", "G", "B", "Y", "W"};
	    for(int i = 0; i < ncards; i++) {
		    String temp = in.next();
		    int first = ArrayUtils.find(translate, Character.toString(temp.charAt(0)));
		    int second = temp.charAt(1) - '1';
		    cards[i] = new IntPair(first, second);
	    }
	    int res = Integer.MAX_VALUE;
	    for(int mask = 0; mask < 1024; mask++) {
		    boolean works = true;
		    for(int i = 0; i < cards.length; i++) {
			    for(int j = i + 1; j < cards.length; j++) {
				    if (cards[i].first == cards[j].first && cards[i].second == cards[j].second) continue;
				    if (cards[i].first != cards[j].first && ((mask >> cards[i].first & 1) == 1 || (mask >> cards[j].first & 1) == 1)) continue;
				    if(cards[i].second != cards[j].second && ((mask >> (cards[i].second + 5) & 1) == 1 || (mask >> (cards[j].second + 5) & 1) == 1)) continue;
				    works = false;
			    }
		    }
		    if (works) res = Math.min(Integer.bitCount(mask), res);
	    }
	    out.printLine(res);
    }
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

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

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

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			if (Character.isValidCodePoint(c))
				res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public String next() {
		return readString();
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void close() {
		writer.close();
	}
	public void printLine(int i) {
		writer.println(i);
	}

}

class IntPair implements Comparable<IntPair> {
public int first, second;

	public IntPair(int first, int second) {
		this.first = first;
		this.second = second;
	}

	public String toString() {
		return "(" + first + "," + second + ")";
	}

	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		IntPair intPair = (IntPair) o;

		return first == intPair.first && second == intPair.second;

	}

	public int hashCode() {
		int result = first;
		result = 31 * result + second;
		return result;
	}

	public int compareTo(IntPair o) {
		if (first < o.first)
			return -1;
		if (first > o.first)
			return 1;
		if (second < o.second)
			return -1;
		if (second > o.second)
			return 1;
		return 0;
	}
}

class ArrayUtils {
	public static int find(String[] array, String value) {
		for (int i = 0; i < array.length; i++) {
			if (array[i].equals(value)) {
				return i;
			}
		}
		return -1;
	}
}


import java.io.*;
import java.util.*;
public class div375B
{
	BufferedReader in;
	PrintWriter ob;
	StringTokenizer st;
	public static void main(String[] args) throws IOException {
		new div375B().run();
	}
	void run() throws IOException {
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	void solve() throws IOException {
		int n=ni();
		char s[]=ns().toCharArray();
		int ans1=0,ans2=0;
		for (int i=0; i<n ; i++ ) {
			if(s[i]=='(') {
				int c=0;
				while(i+1<n) {
					if(s[i+1]==')') {
						if(c>0)++ans2;
						break;
					}
					if(s[i+1]=='_'){
						if(c>0) {
							++ans2;
							c=0;
						}
					}
					else
						++c;
					++i;
				}
			}
			else if(s[i]==')' || s[i]=='_') {
				int c=0;
				while(i+1<n && s[i+1]!=')' && s[i+1]!='_' && s[i+1]!='(') {++c;++i;}
				ans1=Math.max(c,ans1);
			}
			else {
				int c=0;
				while(i<n && s[i]!=')' && s[i]!='_' && s[i]!='(') {++c;++i;}
				ans1=Math.max(c,ans1);
				--i;
			}
		}
		ob.println(ans1+" "+ans2);
	}
	String ns()throws IOException {
		return nextToken();
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class C_Round_382_Div2 {

	public static long MOD = 1000000007;
	static HashMap<Long, Integer> dp = new HashMap();

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		long n = in.nextLong();
		long start = 1;
		long end = 1;
		long cur = 1;
		long total = 2;
		while (total < n) {
			cur++;
			long tmp = start + end;
			start = end;
			end = tmp;
			total += tmp;
		}
		out.println(cur);
		out.close();
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return Integer.compare(x, o.x);
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

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

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

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

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

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

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Set;

public class Codeforces {

    long mod = 1000000007;

    public void solve() {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        int n = in.readInt();
        long fact = 1;
        long product = 1;
        for (int i = 2; i <= n; i++) {
            fact = (fact * i) % mod;
            product = (product * 2) % mod;
        }
        if(fact>=product)
            out.printLine(((fact - product)%mod));
        else{
            out.printLine(mod-(Math.abs(fact-product)%mod));
        }
        out.flush();
    }

    public static void main(String[] args) {
        Codeforces solver = new Codeforces();
        solver.solve();
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

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

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

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

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

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

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

        public String next() {
            return readString();
        }

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

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if ( i != 0 )
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }

    static class IOUtils {

        public static int[] readIntegerArray(InputReader in, int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = in.readInt();
            }
            return array;
        }

        public static long[] readLongArray(InputReader in, int size) {
            long[] array = new long[size];
            for (int i = 0; i < size; i++) {
                array[i] = in.readLong();
            }
            return array;
        }

        public static List<Integer> readIntegerList(InputReader in, int size) {
            List<Integer> set = new ArrayList<>();
            for (int i = 0; i < size; i++) {
                set.add(in.readInt());
            }
            return set;
        }

        public static Set<Integer> readIntegerSet(InputReader in, int size) {
            Set<Integer> set = new HashSet<Integer>();
            for (int i = 0; i < size; i++) {
                set.add(in.readInt());
            }
            return set;
        }
    }
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
    public static FastReader cin;
    public static PrintWriter out;
    public static void main(String[] args) throws Exception {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        cin = new FastReader();
        int qq = cin.nextInt();
//        int qq = 1;
        label:while(qq-->0){
            int [][]arr = new int [2][2];
            int count = 0;
            for(int i = 0 ; i < 2 ; i ++){
                for(int j = 0 ; j < 2; j++){
                    arr[i][j] = cin.nextInt();
                    count+=arr[i][j];
                }
            }
            if(count==0){
                out.println("0");
            }else if(count==4){
                out.println("2");
            }else out.println("1");
        }
        out.close();
    }
    public static int reverse(int n){
        int r =  0;
        while(n>0){
            r = r * 10 + n % 10;
            n /= 10;
        }
        return r;
    }
    public static boolean check(int n ){
        int temp = reverse(n);
        if(temp==n){
            return true;
        }else return false;
    }
    static class Node{
        int id ;
        List<Integer>son;
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer str;

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

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

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

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

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

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


import java.util.Scanner;

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

        String a = r.next()+"/";
        String b = "";

        for(int i = 0; i < a.length(); i++)
            if(a.charAt(i) != '/')b += a.charAt(i);
            else{
                if(i > 0 && a.charAt(i-1) == '/')continue;
                else b += a.charAt(i);
            }

        if(b.length() > 1)
            b = b.substring(0, b.length()-1);

        System.out.println(b);
    }
}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        boolean b = true;
        if (t == 2) {
            System.out.println("1");
        } else {
            int count = 0;
            for (int i = 1; i < t; i++) {
                b = true;
                int tmp = i;
                if ((tmp - 1) % t != 0) {
                    for (int j = 2; j < t - 1; j++) {
                        tmp *= i;
                        tmp = (tmp - 1) % t;
                        if (tmp == 0) {
                            b = false;
                            break;
                        }
                        tmp++;
                    }
                    if (b) {
                        tmp *= i;
                        tmp = (tmp - 1) % t;
                        if (tmp == 0) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}


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

/* Name of the class has to be "Main" only if the class is public. */

public class Main
{

    static PrintWriter out;

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

// SHIVAM GUPTA :

// ASCII = 48 + i ;

static Set<Character> set1  ; static Set<Character> set2  ;

public static boolean isPossibleTriangle(int a  ,int b , int c)
{
      if( a + b > c && c+b > a && a +c > b)
      {
            return true  ;
      }

      return false  ;

}

public static void main (String[] args) throws java.lang.Exception
{
  FastReader scn = new FastReader() ;

//int t= scn.nextInt() ;

//for(int i = 1; i<= t ; i++)
//{
     int a= scn.nextInt() ;int b= scn.nextInt() ;
     int c= scn.nextInt() ;

     int[] arr = new int[3] ;
     arr[0] = a ; arr[1] = b; arr[2] = c ;
     Arrays.sort(arr) ;

     if(arr[0] +arr[1] > arr[2])out.println(0) ;

     else{

           int ans = arr[2] - arr[1] - arr[0] + 1 ;
           out.println(ans) ;
     }

// }

out.flush() ;

}

}


import java.util.Scanner;

public class ProblemSolving {

    public static void main(String[] args) {
        int len ,index;
        Scanner s = new Scanner(System.in);
        len = s.nextInt();
        index = s.nextInt();
        int arr[];
        arr = new int[len];
        for(int i =0 ; i< len ; i++) arr[i]= s.nextInt();

        //------------------
        index--;
        int left =index
            ,right = index
            ,counter=0;
        boolean flag  = false;
        if(arr.length==1){
            System.out.println(arr[0]);
        }else{
            while((right-left)!=arr.length-1||flag!=true){
//                System.out.println(left+" "+right);
//                System.out.println(arr[left]+" "+arr[right]);
//                System.out.println(Math.abs(left-index) +" "+Math.abs(right-index));
                if(arr[left]==1&&arr[right]==1){
                    if(left == right){
                        counter++;
                        arr[left]=0;
                    }else{
                        counter+=2;
                        arr[left]=0;
                        arr[right]=0;
                    }
                }else{
                    if((Math.abs(left-index)!=Math.abs(right-index))&&(arr[left]==1 || arr[right]==1))counter++;
                    arr[left]=0;
                    arr[right]=0;
                }
//                System.out.println(counter);
                if(left==0&&right==arr.length-1)flag = true;
                if(left!=0)left--;
                if(right!=arr.length-1)right++;

            }
            System.out.println(counter);
        }

    }

}


import java.util.*;
public class Main{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        s=s.toLowerCase();
        String r="";
        for(int i=0;i<s.length();i++)
        {
            if(s.charAt(i)!='a'&&s.charAt(i)!='e'&&s.charAt(i)!='y'&&s.charAt(i)!='i'&&s.charAt(i)!='o'&&s.charAt(i)!='u')
            r=r+s.charAt(i);
        }
        for(int j=0;j<r.length();j++)
        {
                System.out.print("."+r.charAt(j));
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class TaskA
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int n = in.nextInt();
            int sum = 0;
            for (int i = 2; i < n; i++)
            {
                sum += getSum(n, i);
            }

            int d = gcd(sum, n - 1 - 2 + 1);
            out.println((sum / d) + "/" + ((n - 1 - 2 + 1) / d));
        }

        public int gcd(int a, int b)
        {
            return b == 0 ? a : gcd(b, a % b);
        }

        public int getSum(int n, int base)
        {
            int sum = 0;
            while (n != 0)
            {
                sum += n % base;
                n /= base;
            }
            return sum;
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }

    static class FastScanner
    {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

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

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

    }
}


import java.util.*;
import java.io.*;
public class codeForce1 {
    String [] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
    public String month (String mon , int a){
       int curr = 0 , c = 0;
        int i=0;
       for( ; i<months.length ; i++){
           if (months[i].equals(mon)) break;
       }
       curr = i;
       curr += a;
       c = curr % 12;
       return months[c];
    }
    public static void main(String []args) throws IOException{
        BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
        String s = stdin.readLine();
        int a = Integer.parseInt(stdin.readLine());
        System.out.println(new codeForce1().month(s , a));
    }
}


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

public class Main {
    public static void main(String [] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Integer readFromFile=new Integer(1);
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int allTime = 60*4;
            int answer = 0;
            int sum = 0;
            for(int l=1,  r = allTime; ; ){
                int c = (r+l)/2;
                sum = 5*c*(c+1)/2;
                if(allTime-(sum+k)<0){
                    r = c-1;
                }else{
                    l = Math.min(c+1, n);
                    answer = l;
                    if(l==n || l>=r){
                        sum = 5*answer*(answer+1)/2;
                        if(allTime-(sum+k)<0){
                            answer--;
                        }
                        break;
                    }
                }
            }
            out.println(answer);
            /*
            char direction = in.nextChar();
            String str = "qwertyuiopasdfghjkl;zxcvbnm,./";
            int [] map = new int[256];
            for(int i=0; i<str.length(); i++){
                map[str.charAt(i)] = i;
            }
            String inputString = in.next();
            for(int i=0; i<inputString.length(); i++){
                if(direction=='L'){
                    out.print(str.charAt(map[inputString.charAt(i)]+1));
                }else{
                    out.print(str.charAt(map[inputString.charAt(i)]-1));
                }
            }
            */
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        String st1;
        File file = new File("text.txt");
        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }
        public InputReader(int i) {
            try {
                br  = new BufferedReader(
                        new InputStreamReader(new FileInputStream(file)));
            } catch (FileNotFoundException e1) {
                System.out.println("File is not find");
            }
            st = null;
        }
        public String next(){
            while (st==null || !st.hasMoreTokens()){
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public String nextLine(){
            try {
                st1 = new String(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return st1;
        }
        public int nextInt()  {return Integer.parseInt(next());}
        public long nextLong(){
            return Long.parseLong(next());
        }
        public Double nextDouble(){
            return Double.parseDouble(next());
        }
        public Byte nextByte() {
            return Byte.parseByte(next());
        }
        private int idx;
        public Character nextChar() {
            if(st1==null) {
                st1 = next();
                idx = 0;
            }
            if(idx!=(st1.length())-1){
                return st1.charAt(idx++);
            }else{
                char  c= st1.charAt(idx);
                st1 = null;
                return c;
            }
        }
        public void newFile() {
            try {
                FileWriter write = new FileWriter(file);
                write.write("something for cheaking");
                write.close();

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


import java.util.Scanner;

public class Prob148B {
	public static void main(String[] Args) {
		Scanner in = new Scanner(System.in);
		int prate = in.nextInt();
		int drate = in.nextInt();
		int noticehrs = in.nextInt();
		int organizehrs = in.nextInt();
		int miles = in.nextInt();

		int bijou = 0;
		double pdistance = noticehrs * prate;

		if (drate > prate)
		{
			double hrs = (pdistance + 0.0) / (drate - prate);
			pdistance += prate * hrs;
			while (pdistance < miles) {
				bijou++;
				pdistance +=  prate * (hrs + organizehrs);
				hrs = (pdistance + 0.0) / (drate - prate);
				pdistance += prate * hrs;
			}
		}

		System.out.println(bijou);

	}
}


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

public class Main {

	static int MOD = 1000 * 1000 * 1000 + 7;

	public static void main(String[] args) {

		InputStream  inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		solve(in, out);
		out.close();
		System.exit(0);
	}

	private static void solve(InputReader in, PrintWriter out) {

		int[][] tab = new int[3][2];
		for (int i = 0; i < 3; i++) {
			tab[i][0] = in.nextInt();
			tab[i][1] = in.nextInt();
		}

		if (tab[0][0] == tab[1][0] && tab[1][0] == tab[2][0]) {
			out.print(1);
			return;
		}
		if (tab[0][1] == tab[1][1] && tab[1][1] == tab[2][1]) {
			out.print(1);
			return;
		}

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i == j) {
					continue;
				}
				for (int k = 0; k < 3; k++) {
					if (k == i || k == j) {
						continue;
					}
					if (tab[k][0] < Math.min(tab[i][0], tab[j][0]) || tab[k][0] > Math.max(tab[i][0], tab[j][0])) {
						continue;
					}
					if (tab[k][1] < Math.min(tab[i][1], tab[j][1]) || tab[k][1] > Math.max(tab[i][1], tab[j][1])) {
						continue;
					}
					if (tab[k][0] == tab[i][0] || tab[k][0] == tab[j][0] || tab[k][1] == tab[i][1]
							|| tab[k][1] == tab[j][1]) {
						out.print(2);
						return;
					}
				}
			}
		}

		out.print(3);

	}

	/*
	 *
	 */
	// --------------------------------------------------------
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

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

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

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

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

			return str;
		}
	}
}


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

public class Main{

    public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer(br.readLine());
int n=Integer.parseInt(st.nextToken());
st=new StringTokenizer(br.readLine());
int Nchest=0;
int Nbiceps=0;
int Nback=0;
int w=2;
        for (int i =1; i <=n; i++) {
            if(i % 3==0)
                Nback+=Integer.parseInt(st.nextToken());
            else if(i==w){
                w=w+3;
                Nbiceps+=Integer.parseInt(st.nextToken());
            }
            else
                Nchest+=Integer.parseInt(st.nextToken());

        }
if(Nchest > Nbiceps && Nchest > Nback)
            System.out.println("chest");
else if( Nbiceps> Nchest && Nbiceps > Nback)
            System.out.println("biceps");
else
    System.out.println("back");
    }

}


import java.util.Scanner;

public class SimpleMoecules {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int c = input.nextInt();
		if((c+b-a)%2==0){
			int z  = (c+b-a)/2;
			if(z<0){
				System.out.println("Impossible");
				return;
			}
			int y = c-z;
			if(y<0){
				System.out.println("Impossible");
				return;
			}
			int x = a-y;
			if(x<0){
				System.out.println("Impossible");
				return;
			}
			else
				System.out.println(x+" "+z+" "+y);
		}
		else
			System.out.println("Impossible");
	}

}