import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.math.*;
import java.lang.*;
import java.util.stream.Collectors;

import static java.lang.Math.*;

public class Main implements Runnable
{
    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        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 long nextLong()
        {
            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 double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            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);
        }
    }
    public static void main(String args[]) throws Exception
    {
        new Thread(null, new Main(),"Main",1<<27).start();
    }

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

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

    static void sortbycolomn(long arr[][], int col)
    {

        Arrays.sort(arr, new Comparator<long[]>() {

            @Override

            public int compare(final long[] entry1,
                               final long[] entry2) {

                if (entry1[col] > entry2[col])
                    return 1;
                else
                    return -1;
            }
        });
    }

    static String sortString(String str) {
        int MAX_CHAR = 256;
        int letters[] = new int[MAX_CHAR];
        for (char x : str.toCharArray()) {

            // 'a'-'a' will be 0, 'b'-'a' will be 1,
            // so for location of character in count
            // array we will do str[i]-'a'.
            letters[x - 'a']++;
        }

        // Traverse the hash array and print
        // characters
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < MAX_CHAR; i++) {
            for (int j = 0; j < letters[i]; j++) {
                sb.append((char) (i + 'a'));
            }
        }
        return sb.toString();
    }
    public int lb(int[] a, int val){
        int min = 0, len = a.length, max = len;
        while(min<max){
            int mid = min + (max-min)/2;
            if(a[mid]>=val){
                max = mid;
            }
            else{
                min = mid+1;
            }
        }
        return max;
    }
    public int ub(int[] a, int val){
        int min = 0, len = a.length, max = len;
        while(min<max){
            int mid = min + (max-min)/2;
            if(a[mid]>val){
                max = mid;
            }
            else {
                min = mid + 1;
            }
        }
        return max;
    }
    public int lb(List<Integer> a, int val){
        int min = 0, len = a.size(), max = len;
        while(min<max){
            int mid = min + (max-min)/2;
            if(a.get(mid)>=val){
                max = mid;
            }
            else{
                min = mid+1;
            }
        }
        return max;
    }
    public int ub(List<Integer> a, int val){
        int min = 0, len = a.size(), max = len;
        while(min<max){
            int mid = min + (max-min)/2;
            if(a.get(mid)>val){
                max = mid;
            }
            else {
                min = mid + 1;
            }
        }
        return max;
    }
    public void run()
    {
        InputReader in = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        long n = in.nextLong();
        long prev = n;
        long i = 2;
        while(i*i<=n){
            if(n%i==0){
                n-=i;
//                w.println(n);
                break;
            }
            i++;
        }
        if(n==prev) w.println(1);
        else w.println(1+n/2);
        w.flush();
        w.close();
    }
}


import java.util.*;
public class transformation {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        int num2 = scan.nextInt(),k=num2;
        ArrayList<Integer> arr = new ArrayList<>();
        while(num2>num1){
            if(num2%2==0){
                num2=num2/2;
                arr.add(num2);
            }
            else if(num2%10==1){
                num2=num2/10;
                arr.add(num2);
            }
            else
                break;
        }
        if(num1==num2){
            System.out.println("YES");
            System.out.println(arr.size()+1);
            for(int i=arr.size()-1;i>=0;i--){
                System.out.print(arr.get(i)+" ");
            }
            System.out.print(k);
        }
        else
            System.out.println("NO");
    }
}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        int a1 = kb.nextInt();
        int b1 = kb.nextInt();
        int c1 = kb.nextInt();
        int a2 = kb.nextInt();
        int b2 = kb.nextInt();
        int c2 = kb.nextInt();
        int D = a1*b2-a2*b1;
        if((a1==0&&b1==0&&c1!=0)||(a2==0&&b2==0&&c2!=0))System.out.println(0);
        else if((a1==0&&b1==0&&c1==0)||(a2==0&&b2==0&&c2==0))System.out.println(-1);
        else if(D!=0)System.out.println(1);
        else if(a1*c2==a2*c1&&b1*c2==b2*c1)System.out.println(-1);
        else System.out.println(0);
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String player = "Mahmoud";
        boolean flag = true;

        while (flag) {
            if (player.contains("Mahmoud")) {
                if (n % 2 == 0) {
                    flag = false;
                } else if(n==1){
                    player = "Ehab";
                    flag = false;
                } else {
                    int random = (int) (Math.random() * (n - 2 + 1) + 2) / 2 * 2;
                    n-=random;
                }
            } else if (player.contains("Ehab")) {
                if (n % 2 == 1) {
                    flag = false;
                } else {
                    int random = (int) (Math.random() * ((n-1) - 1 + 1) + 1) / 2 * 2;
                    random++;
                    n-=random;
                }
            }
        }
        System.out.println(player);
    }
}


import java.io.*;
import java.util.*;
public class a279
{
    public static void main(String args[])throws IOException
    {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        String s;
        //System.out.println("Enter");
        s=in.readLine();
        StringTokenizer st=new StringTokenizer(s);
        int x,y,sum;
        x=Integer.parseInt(st.nextToken());
        y=Integer.parseInt(st.nextToken());
        if(x==0 && y==0)
        {
            System.out.println("0");
            System.exit(0);
        }
        if(x==y)
        {
            if(x>0 && y>0)
            System.out.println(Math.min(1+(x-1)*4,2+(y-1)*4));
            else if(x<0 && y<0)
            System.out.println(Math.min(3+(-x-1)*4,4+(-y-1)*4));
            System.exit(0);
        }
        else if(y==-x && y>0 && x<0)
        {
            System.out.println(Math.min(3+(-x-1)*4,2+(y-1)*4));
            System.exit(0);
        }
        else if(y==-x+1 && x>0 && y<=0)
        {
            System.out.println(Math.min(1+(x-1)*4,4+(-y-1)*4));
            System.exit(0);
        }
        else if (x>=0 && y>=0)
        {
            System.out.println(Math.max(1+(x-1)*4,2+(y-1)*4));
            System.exit(0);
        }
        else if(x<=0 && y>=0)
        {
            System.out.println(Math.max(3+(-x-1)*4,2+(y-1)*4));
            System.exit(0);
        }
        else if(x<=0 && y<=0)
        {
            System.out.println(Math.max(3+(-x-1)*4,4+(-y-1)*4));
            System.exit(0);
        }
        else if(x>=0 && y<=0)
        {
            System.out.println(Math.max(1+(x-1)*4,4+(-y-1)*4));
            System.exit(0);
        }
    }
}


import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
/*
1000000000000 1000000000002

*/
public class Main {

    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        StringTokenizer st=new StringTokenizer(br.readLine());
        long n=Long.parseLong(st.nextToken());
        long k=Long.parseLong(st.nextToken());
        if(n+n-1>=k){
            if(k<=n){
                long start = 1;
                long end = k-1;
                long ans = (end - start + 1) / 2;
                if ((end - start + 1) % 2 == 1) {
                    ans++;
                }
                if(k%2==0){
                    if ((end - start + 1) % 2 == 1) {
                        ans--;
                    }
                }
                pw.println(ans);
            }else {
                long start = k - n;
                long end = n;
                long ans = (end - start + 1) / 2;
                if ((end - start + 1) % 2 == 1) {
                    ans++;
                }
                if(k%2==0){
                    if ((end - start + 1) % 2 == 1) {
                        ans--;
                    }
                }
                pw.println(ans);
            }
        }else {
            pw.println("0");
        }

        pw.close();
    }
}


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

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        PrintWriter pw = new PrintWriter(System.out);
        rect rect1 = new rect(sc.nextLong(), sc.nextLong(), sc.nextLong(), sc.nextLong());
        rect rect2 = new rect(sc.nextLong(), sc.nextLong(), sc.nextLong(), sc.nextLong());
        rect rect3 = new rect(sc.nextLong(), sc.nextLong(), sc.nextLong(), sc.nextLong());
        long s1 = s(rect1, rect2);
        long s2 = s(rect1, rect3);
        long s3 = sAll(rect1, rect2, rect3);
        if(s1 + s2 - s3 == s(rect1))
            pw.print("NO");
        else
            pw.print("YES");
        pw.close();
    }

    public static long s(rect rect) {
        return (rect.x2 - rect.x1) * (rect.y2 - rect.y1);
    }

    public static long s(rect rect1, rect rect2) {
        if (max(rect1.x1, rect2.x1) >= min(rect1.x2, rect2.x2) || max(rect1.y1, rect2.y1) >= min(rect1.y2, rect2.y2))
            return 0;
        return (max(rect1.x1, rect2.x1) - min(rect1.x2, rect2.x2)) * (max(rect1.y1, rect2.y1) - min(rect1.y2, rect2.y2));
    }

    public static long sAll(rect rect1, rect rect2, rect rect3) {
        if (max(rect1.x1, max(rect2.x1, rect3.x1)) >= min(rect1.x2, min(rect2.x2, rect3.x2)) || max(rect1.y1, max(rect2.y1, rect3.y1)) >= min(rect1.y2, min(rect2.y2, rect3.y2)))
            return 0;
        return (max(rect1.x1, max(rect2.x1, rect3.x1)) - min(rect1.x2, min(rect2.x2, rect3.x2))) * (max(rect1.y1, max(rect2.y1, rect3.y1)) - min(rect1.y2, min(rect2.y2, rect3.y2)));
    }
}

class rect {
    long x1, y1, x2, y2;

    public rect(long x1, long y1, long x2, long y2) {
        this.x1 = x1;
        this.y1 = y1;
        this.x2 = x2;
        this.y2 = y2;
    }
}

class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");

    public Scanner() throws FileNotFoundException {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

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

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

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

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


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        char[] c1 = scan.nextLine().trim().toCharArray();
        char[] c2 = scan.nextLine().trim().toCharArray();
        char[] virus = scan.nextLine().trim().toCharArray();
        int n1 = c1.length;
        int n2 = c2.length;
        int m = virus.length;
        int[][][] dp = new int[n1 + 1][n2 + 1][m + 1];
        int[][][] step = new int[n1 + 1][n2 + 1][m + 1];

        // preprocessor
        int[] next = new int[m + 1];
        next[0] = -1;
        next[1] = 0;
        int pos = 2;
        int pre = 0;
        while (pos < m) {
            if (virus[pos - 1] == virus[pre]) {
                pre++;
                next[pos] = pre;
                pos++;
            } else if (pre > 0) {
                pre = next[pre];
            } else {
                next[pos] = 0;
                pos++;
            }
        }

        for (int i = 1; i <= n1; i++) {
            for (int j = 1; j <= n2; j++) {
                for (int k = 0; k < m; k++) {
                    if (c1[i - 1] == c2[j - 1]) {
                        int kk = k;
                        while (kk >= 0 && c1[i - 1] != virus[kk]) {
                            kk = next[kk];
                        }
                        if (dp[i][j][kk + 1] < 1 + dp[i - 1][j - 1][k]) {
                            dp[i][j][kk + 1] = 1 + dp[i - 1][j - 1][k];
                            step[i][j][kk + 1] = 100 + k;
                        }
                    }

                    if (dp[i][j][k] < dp[i - 1][j][k]) {
                        dp[i][j][k] = dp[i - 1][j][k];
                        step[i][j][k] = -1;
                    }
                    if (dp[i][j][k] < dp[i][j - 1][k]) {
                        dp[i][j][k] = dp[i][j - 1][k];
                        step[i][j][k] = 1;
                    }
                }
            }
        }

        int result = 0;
        int maxK = 0;
        for (int i = 0; i < m; i++) {
            if (result < dp[n1][n2][i]) {
                result = dp[n1][n2][i];
                maxK = i;
            }
        }
        //System.out.println(result + ", " + maxK);
        if (result == 0) {
            System.out.println(result);
        } else {
            char[] cc = new char[result];
            int ccIdx = result - 1;
            int n1Idx = n1;
            int n2Idx = n2;
            int mIdx = maxK;
            while (ccIdx >= 0) {
                switch (step[n1Idx][n2Idx][mIdx]) {
                case -1:
                    n1Idx--;
                    break;
                case -2:
                    n1Idx--;
                    n2Idx--;
                    break;
                case 1:
                    n2Idx--;
                    break;
                case 0:
                    cc[ccIdx--] = c1[n1Idx - 1];
                    n1Idx--;
                    n2Idx--;
                    mIdx--;
                    break;
                default:
                    cc[ccIdx--] = c1[n1Idx - 1];
                    mIdx = step[n1Idx][n2Idx][mIdx] - 100;
                    n1Idx--;
                    n2Idx--;
                    break;
                }
            }
            System.out.println(cc);
        }
    }
}


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

public class D {

    final static long MOD = 1000000007;

    void solve() throws IOException {
        in("__std"); out("__std");

        int n = readInt();
        int k = 0;
        for (int i = 0; i < n; ++i) {
            if (readInt() == 2) ++k;
        }
        long a = 1;
        long b = 1;
        for (int i = 2; i <= n - k; ++i) {
            long c = a * i % MOD;
            a = (a + b) % MOD;
            b = c;
        }
        for (int i = 0; i < k; ++i) {
            a = a * (n - i) % MOD;
        }
        println(a);

        exit();
    }

    void in(String name) throws IOException {
        if (name.equals("__std")) {
            in = new BufferedReader(new InputStreamReader(System.in));
        } else {
            in = new BufferedReader(new FileReader(name));
        }
    }

    void out(String name) throws IOException {
        if (name.equals("__std")) {
            out = new PrintWriter(System.out);
        } else {
            out = new PrintWriter(name);
        }
    }

    void exit() {
        out.close();
        System.exit(0);
    }

    char readChar() throws IOException {
        return (char) in.read();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readToken());
    }

    long readLong() throws IOException {
        return Long.parseLong(readToken());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readToken());
    }

    String readLine() throws IOException {
        st = null;
        return in.readLine();
    }

    String readToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    boolean eof() throws IOException {
        return !in.ready();
    }

    void print(String format, Object ... args) {
        out.print(new Formatter(Locale.US).format(format, args));
    }

    void println(String format, Object ... args) {
        out.println(new Formatter(Locale.US).format(format, args));
    }

    void print(Object value) {
        out.print(value);
    }

    void println(Object value) {
        out.println(value);
    }

    void println() {
        out.println();
    }

    StringTokenizer st;

    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new D().solve();
    }
}


import java.util.*;

public class IP {
	public static void main(String[] Args) {
		Scanner in = new Scanner(System.in);
		int min = 10000, k = 0;
		for (; k < 4; k++)
			min = Math.min(min, in.nextInt());
		int a = in.nextInt(), b = Math.min(min - 1, in.nextInt()) + 1;
		System.out.print(Math.max(b - a, 0));
	}
}


import java.util.Scanner;
/**
 * @author Eduardo Osorio
 * A01334501
 */
public class Unimodal_Array {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String r = "YES";
		boolean c1 = true, c2 = true, c3 = true;

		int a[] = new int [n];

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

			a[i] = sc.nextInt();

		}

		for (int i=0;i<n-1;i++) {
			if (c3 == true &&  a[i] > a[i+1]){

				c1 = false;
				c2 = false;

			} else if (c2 == true &&  a[i] == a[i+1]){

				r = "YES";
				c1 = false;
				c3 = true;

			} else if (c1 == true && a[i] < a[i+1]){

				c3 = true;

			} else {

				r = "NO";
				c1 = false;
				c2 = false;
				c3 = false;

			}
		}

		System.out.println(r);

		sc.close();
	}
}


import java.util.*;
public class hello
{
    public static void main(String []args)
    {
       Scanner sc=new Scanner(System.in);
       int x=sc.nextInt();
       int y=sc.nextInt();
       int z=sc.nextInt();

       if(x>y)
       {
    	   if(x-y-z>0)
    	   {
    		   System.out.println("+");
    	   }
    	   else
    	   {
    		   if(x-y==0&&z==0)
    		   {
    			   System.out.println("0");
    		   }
    		   else
    		   {
    		   System.out.println("?");
    		   }
    	   }
       }
       else
       {
    	   if(y-x-z>0)
    	   {
    		   System.out.println("-");
    	   }
    	   else
    	   {
    		   if(y-x==0&&z==0)
    		   {
    			   System.out.println("0");
    		   }
    		   else
    		   {
    		   System.out.println("?");
    		   }
    	   }
       }

    }
}


import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    //Code not meant for understanding, proceed with caution, You have been warned.
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int m = ni();
        long inv = pow(m, mod-2);
        long ans = inv;
        long[] e= new long[m+1];
        for(int i = m; i>= 2; i--){
            long y = m/i;
            e[i] = mul(new long[]{y, 2*m-y, pow(m-y,mod-2),pow(m,mod-2)});
            for(int j = i*2; j<= m; j+=i)e[i] = (e[i]+mod-e[j])%mod;
            ans+=e[i];
            if(ans>=mod)ans-=mod;
        }
        pn(ans);
    }
    long mul(long[] a){
        long ans= 1;
        for(long x:a)ans = (ans*x)%mod;return ans;
    }
    long pow(long a, long p){
        long o = 1;
        while(p>0){
            if(p%2==1)o = (a*o)%mod;
            a = (a*a)%mod;
            p>>=1;
        }
        return o;
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)1e18;
    final int INF = (int)1e9, MX = (int)1e5+7;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

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

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

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

        String nextLine() throws Exception{
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

    public static BufferedReader in;
    public static StringTokenizer tok = new StringTokenizer("");

    public static String readLine() { // читает строку до самого конца
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static String readString() { // читает строку до пробела/табуляции/перевода строки

        while (!tok.hasMoreTokens()) {
            String line = readLine();
            if (null == line) return null; // ввода больше нет
            tok = new StringTokenizer(line); // сюда можно передать вторым параметром строку с символами, по которым надо отсекать, по умолчанию это пробел и табуляция
        }

        return tok.nextToken();
    }

    public static int readInt() { // аналогично для readLong(), readDouble(), ...
        return Integer.parseInt(readString());
    }

    public static void main(String[] args){
        in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = readInt();
        int k = readInt();
        int m = readInt();
        int a = readInt();

        //ArrayList<Candidate> candidates = new ArrayList<>();
        Candidate[] candidates = new Candidate[n];
        for (int i = 0; i < n; i++) {
            candidates[i]  = new Candidate(i,0,0,1);
        }
        for (int i = 0; i < a; i++) {
            int l = readInt()-1;
            candidates[l].vote(i);
        }
        Arrays.sort(candidates);

        int minFor2 = candidates[k-1].votes;

        for (int i = k; i < n; i++) {
            if(candidates[i].votes + (m-a) > minFor2)
                candidates[i].type = 2;
            else
                candidates[i].type = 3;
        }

        if(n > k) {
            for (int i = 0; i < k; i++) {
                int ndVotes = candidates[i].votes + 1;
                int votes = 0;
                for (int j = i + 1; j < k + 1; j++) {
                    votes +=ndVotes - candidates[j].votes;
                }
                if (votes <= m - a)
                    candidates[i].type = 2;
            }
        }

        if(m-a > 0)
        {
            for (int i = 0; i < k; i++) {
                if(candidates[i].votes == 0) candidates[i].type = 2;
            }
        }
        else {
            for (int i = 0; i < k; i++) {
                if (candidates[i].votes == 0) candidates[i].type = 3;
            }
        }

        int[] ans = new int[n];

        for (int i = 0; i < n; i++) {
            ans[candidates[i].id] = candidates[i].type;
        }

        for (int i = 0; i < n; i++) {
            out.print(ans[i]+" ");
        }

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

    static class Candidate implements Comparable<Candidate>{
        public int id;
        public int votes;
        public int lastT;
        public int type;

        public Candidate(int id,int votes,int lastT,int type)
        {
            this.id = id;
            this.votes = votes;
            this.lastT = lastT;
            this.type = type;
        }

        public void vote(int lastT)
        {
            votes++;
            this.lastT = lastT;
        }

        public int compareTo(Candidate p){
            if(p.votes > this.votes)
                return 1;
            else if(p.votes == this.votes)
                return p.lastT < this.lastT?1:-1;
            else return -1;
        }
    }
}


import java.util.*;

public class LearnFromMaths
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        long arr[]=new long[1000000];
        int k=0;
        long x=0;
        long ans=0;
        for(int i=1;i<=81;i++)
        {
            x=b*(long)Math.pow(i,a)+c;
            if(x<1e9  && x>0 && sum(x,i))
            {
                ans++;
                arr[k++]=x;
            }
        }
        System.out.println(ans);
        for(int i=0;i<k;i++)

        {
            System.out.print(arr[i]+" ");
        }
    }
    public static boolean sum(long y,int i){
        long sum = 0;
        for (sum = 0; y > 0; sum += y % 10,y/= 10);
        return sum==i;
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long m = in.nextLong();
            ModuloArithmetic moduloArithmetic = new ModuloArithmetic(998244353L);

            long factm = moduloArithmetic.factorial(m);
            long fact1 = moduloArithmetic.factorial(m - (n - 1));
            long fact2 = moduloArithmetic.factorial(n - 1);
            long pow2 = n >= 3 ? moduloArithmetic.powmod(2, n - 3) : 1;
            long t = moduloArithmetic.mul(fact1, fact2);
            long ans = moduloArithmetic.div(factm, t);
            ans = moduloArithmetic.mul(ans, n - 2);
            ans = moduloArithmetic.mul(ans, pow2);
            out.println(ans);
        }

    }

    static class InputReader {
        final InputStream is;
        final byte[] buffer = new byte[1024];
        int curCharIdx;
        int nChars;

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

        public int read() {
            if (curCharIdx >= nChars) {
                try {
                    curCharIdx = 0;
                    nChars = is.read(buffer);
                    if (nChars == -1)
                        return -1;
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return buffer[curCharIdx++];
        }

        public long nextLong() {
            int sign = 1;
            int c = skipDelims();
            if (c == '-') {
                sign = -1;
                c = read();
                if (isDelim(c))
                    throw new RuntimeException("Incorrect format");
            }
            long val = 0;
            while (c != -1 && !isDelim(c)) {
                if (!isDigit(c))
                    throw new RuntimeException("Incorrect format");
                val = 10L * val + (c - '0');
                c = read();
            }
            return val * sign;
        }

        private final int skipDelims() {
            int c = read();
            while (isDelim(c)) {
                c = read();
            }
            return c;
        }

        private static boolean isDelim(final int c) {
            return c == ' ' ||
                    c == '\n' ||
                    c == '\t' ||
                    c == '\r' ||
                    c == '\f';
        }

        private static boolean isDigit(final int c) {
            return '0' <= c && c <= '9';
        }

    }

    static class Algorithms {
        public static long powmod(long a, long n, long mod) {
            long res = 1;
            while (n != 0) {
                if ((n & 1) == 1)
                    res = (res * a) % mod;
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long inverseByModulo(long a, long n) {
            long t = 0, newt = 1, r = n, newr = a;
            while (newr != 0) {
                long q = r / newr;

                long temp = newt;
                newt = t - q * newt;
                t = temp;

                temp = newr;
                newr = r - q * newr;
                r = temp;
            }

            if (r > 1)
                return 0;
            if (t < 0)
                t += n;
            return t;
        }

    }

    static class ModuloArithmetic {
        final long MODULO;

        public ModuloArithmetic(long mod) {
            this.MODULO = mod;
        }

        public long mul(long a, long b) {
            return (a * b) % MODULO;
        }

        public long div(long a, long b) {
            return (a * Algorithms.inverseByModulo(b, MODULO)) % MODULO;
        }

        public long factorial(long n) {
            long ans = 1;
            for (int i = 2; i <= n; i++) ans = mul(ans, i);
            return ans;
        }

        public long powmod(long k, long n) {
            return Algorithms.powmod(k, n, MODULO);
        }

    }
}


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

public class Main {
   public static void main(String[] args) throws FileNotFoundException
   {
	   (new Main()).solve();
   }
   public void Main() {
   }

   void solve()  throws FileNotFoundException {
      Scanner in = new Scanner(System.in);
	  PrintWriter out = new PrintWriter(System.out);
     // Scanner in = new Scanner(new FileReader("input.txt"));
	//  PrintWriter out = new PrintWriter("output.txt");
	  String s = in.next();
	  ArrayList<Integer> a = new ArrayList<Integer>();
	  int prevh = -1;
	  int prevm = -1;
	  boolean flag = true;

	  for (int j = 2; j < 100; j++) {
		  int h = 0;
		  int m = 0;
		  for (int i = 0; i < s.indexOf(':'); i++) {
			  int t = (int) s.charAt(i) - (int)'0';
			  if (t >=0 && t <= 9) {

			  } else {
				  t = (int) s.charAt(i) - (int)'A' + 10;
			  }
			  if (t >= j) {
				  h = -1;
				  break;
			  }
			  h = h * j + t;
		  }
		  for (int i = s.indexOf(':') + 1; i < s.length(); i++) {
			  int t = (int) s.charAt(i) - (int)'0';
			  if (t >=0 && t <= 9) {

			  } else {
				  t = (int) s.charAt(i) - (int)'A' + 10;
			  }
			  if (t >= j) {
				  m = -1;
				  break;
			  }
			  m = m * j + t;
		  }
		  if (h >= 0 && h <= 23 && m >= 0 && m <= 59) {
			  a.add(j);
			  if (h == prevh && m == prevm) {
				  flag = false;
				  break;
			  }
		  }
				  prevh = h;
				  prevm = m;

	  }

	  if (flag) {
		  if (a.size() == 0) {
			  out.print(0);
		  }
		  for (Integer t : a) {
			  out.print(t + " ");
		  }
	  } else {
		  out.print(-1);
	  }

	  out.close();
   }

};


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

public class CODE_OBSTUFICATIION {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		String s = nik.next();
		boolean b = true;
		HashMap<Character, Integer> hm = new HashMap<>();
		for (int i = 0; i < s.length(); i++) {
			int temp = s.charAt(i) - 'a';
			if (hm.size() < temp) {
				b = false;
				break;
			} else {
				hm.put(s.charAt(i), hm.getOrDefault(s.charAt(i) + 1, 0));
			}

		}

		System.out.println(b == true ? "YES" : "NO");

	}

}


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

public class Main
{
    static long mod=1000000007;
    static long p=(long)1e10;
    public static void main(String[] args) throws Exception
    {
    	FastReader in=new FastReader();
    	PrintWriter pw=new PrintWriter(System.out);
    	int n=in.nextInt();
    	long sum=0,max=0;
    	for(int i=0;i<n;i++)
    	{
    		long temp=in.nextInt();
    		sum+=temp;
    		max=Math.max(temp,max);
    	}
    	long ans=n*max-sum;
    	while(ans<=sum)
    	{
    		max++;
    		ans=n*max-sum;
    	}
    	pw.println(max);
    	pw.flush();
    }

}

class pair<A,B>
{
    A f;
    B s;

    public pair(A a,B b)
    {
        f=a;
        s=b;
    }
}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;

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

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

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

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


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

/**
 * CodeForces : 338
 *
 * @author vinaysaini E. Hexagons
 */
public class cf338e {

	static int dx[] = { 1, -1, -2, -1, 1, 2 };
	static int dy[] = { 2, 2, 0, -2, -2, 0 };

	public static void main(String[] args) {
		long x = 0, y = 0;

		long n = in.nextLong();
		long ringNumber = getRing(n);
		long stepsUpTo = 3 * ringNumber * ringNumber + 3 * ringNumber;
		x = 2 * ringNumber;
		long remainingSteps = n - stepsUpTo;
		if (remainingSteps > 0) {
			x = x + dx[0];
			y = y + dy[0];
			remainingSteps--;
		}
		if (remainingSteps >= ringNumber) {
			x += dx[1] * ringNumber;
			y += dy[1] * ringNumber;
			remainingSteps -= ringNumber;
		} else {
			x += dx[1] * remainingSteps;
			y += dy[1] * remainingSteps;
			remainingSteps -= remainingSteps;
		}
		if (remainingSteps >= ringNumber+1) {
			x += dx[2] * (ringNumber+1);
			y += dy[2] * (ringNumber+1);
			remainingSteps -= ringNumber+1;
		} else {
			x += dx[2] * remainingSteps;
			y += dy[2] * remainingSteps;
			remainingSteps -= remainingSteps;
		}
		if (remainingSteps >= ringNumber+1) {
			x += dx[3] * (ringNumber+1);
			y += dy[3] * (ringNumber+1);
			remainingSteps -= ringNumber+1;
		} else {
			x += dx[3] * remainingSteps;
			y += dy[3] * remainingSteps;
			remainingSteps -= remainingSteps;
		}
		if (remainingSteps >= ringNumber+1) {
			x += dx[4] * (ringNumber+1);
			y += dy[4] * (ringNumber+1);
			remainingSteps -= ringNumber+1;
		} else {
			x += dx[4] * remainingSteps;
			y += dy[4] * remainingSteps;
			remainingSteps -= remainingSteps;
		}
		if (remainingSteps >= ringNumber+1) {
			x += dx[5] * (ringNumber+1);
			y += dy[5] * (ringNumber+1);
			remainingSteps -= ringNumber+1;
		} else {
			x += dx[5] * remainingSteps;
			y += dy[5] * remainingSteps;
			remainingSteps -= remainingSteps;
		}
		if (remainingSteps >= ringNumber) {
			x += dx[0] * ringNumber;
			y += dy[0] * ringNumber;
			remainingSteps -= ringNumber;
		} else {
			x += dx[0] * remainingSteps;
			y += dy[0] * remainingSteps;
			remainingSteps -= remainingSteps;
		}

		out.println(x + " " + y);
		out.close();
	}

	static long getRing(long n) {
		long l = 0;
		long r = (long) 1e9;
		while (l < r) {
			long m = (l + r) / 2;
			long sum = 3 * m * m + 3 * m;
			if (n < sum) {
				r = m;
			} else
				l = m + 1;
		}
		return l - 1;
	}

	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static FastScanner in = new FastScanner();

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	} // --fast i/o ends here----//

}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class MAin {

	public static void main(String[] args) {

		BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));

		try {

			int n=Integer.parseInt(bufferedReader.readLine());

			int[] num=new int[n];

			int minI=-90;
			int maxI=-90;
			String[] input=bufferedReader.readLine().split(" ");
			int min=Integer.MAX_VALUE;
			int max=Integer.MIN_VALUE;
			for(int i=0;i<n;i++){

				int val=Integer.parseInt(input[i]);

				if (val>max) {
					max=val;
					maxI=i;
				}

				if (val<min) {
					min=val;
					minI=i;
				}

			}

			int a,b,c,d;

			a=minI-0;
			b=n-minI-1;

			c=maxI-0;
			d=n-maxI-1;

			int max1=Math.max(a, b);

			int max2=Math.max(c, d);

			int ans=Math.max(max1, max2);

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		new Solver().solve().end();
	}
}

class Solver {
	PrintWriter out;
	FastReader cd;
	@SuppressWarnings("unused")
	public static final int INF = 0x3f3f3f3f;
	@SuppressWarnings("unused")
	public static final double MINI = 1e-6, ATOM = 1e-8;

	Solver() {
		out = new PrintWriter(System.out, true);
		cd = new FastReader();
	}

	Solver solve() {
		String[] time1 = cd.next().split(":"), time2 = cd.next().split(":");
		int real1 = Integer.parseInt(time1[0])*60 + Integer.parseInt(time1[1]), real2 = Integer.parseInt(time2[0]) * 60 + Integer.parseInt(time2[1]);
		int res = (real1 + real2) / 2;
		out.printf("%02d:%02d", res / 60, res % 60);
		return this;
	}

	void end() {
		out.close();
		cd.close();
	}

	@SuppressWarnings("unused")
	class FastReader {
		private BufferedReader in;
		private StringTokenizer tokenizer;

		FastReader() {
			in = new BufferedReader(new InputStreamReader(System.in), 23333);
			tokenizer = null;
		}

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

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

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

		int[] nextInts(int len) {
			int[] a = new int[len];
			for (int i = 0; i < a.length; i++) {
				a[i] = cd.nextInt();
			}
			return a;
		}

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

		void close() {
			try {
				in.close();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
}


import java.util.*;
import java.util.StringTokenizer;
import java.io.*;
public class Main {
    static int []arr;
    static int [][]dp;
    static String s;
    static ArrayList<Integer>[]G;

    public static int solve(int idx,int rem)
    {
        if (rem<=0) return 0;
        if (dp[idx][rem]!=-1) return dp[idx][rem];
        dp[idx][rem]=(int)1e6;
        for (int i=1;i<=3;++i)
        {
            if (i==1&&s.charAt(idx-1)=='R') continue;
            if (i==2&&s.charAt(idx-1)=='G') continue;
            if (i==3&&s.charAt(idx-1)=='B') continue;
            for (int u:G[i])
                if (arr[u]>arr[idx])
                    dp[idx][rem]=Math.min(dp[idx][rem],(solve(u, rem - arr[u])+Math.abs(u-idx)));
        }
        return dp[idx][rem];
    }

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

        int n=sc.nextInt();
        int pos=sc.nextInt();
        int k=sc.nextInt();
        G = new ArrayList[5];
        for (int i=0;i<5;++i) G[i] = new ArrayList();
        arr =new int [n+5];
        dp=new int [n+5][k+5];
        for (int i=0;i<=n+1;++i)
            for (int j=0;j<=k+1;++j)
                dp[i][j]=-1;

        for (int i=1;i<=n;++i) arr[i]=sc.nextInt();
        s=sc.nextLine();
        for (int i=0;i<n;++i)
        {
            char ch=s.charAt(i);
            if ( ch == 'R')
                G[1].add(i + 1);
            else if (ch == 'G')
                G[2].add(i + 1);
            else G[3].add(i + 1);
        }

        int cnt=(int)1e6;
        for (int i=1;i<=n;++i)
            cnt=Math.min(cnt,solve(i,k-arr[i])+Math.abs(i-pos));

        out.println((cnt>=(int)1e6)?-1:cnt);
        out.close();
    }
    static class Scanner
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

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

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

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

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


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

// PROBLEM : Can teleport between cells corresponding to the same string
public class B {
    static int n;
    static char[][] G;
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        G = new char[n][n];
        F = new HashMap<Long, Integer>();
        for(int r=0; r<n; r++) {
            G[r] = in.next().toCharArray();
        }
        int ans = ch_to_val(G[0][0],true)-f(0,new boolean[]{true},false);
        if(ans > 0) System.out.println("FIRST");
        if(ans < 0) System.out.println("SECOND");
        if(ans == 0) System.out.println("DRAW");
    }

    static int ch_to_val(char ch, boolean first) {
        if(ch=='a') return first ? 1 : -1;
        if(ch=='b') return first ? -1 : 1;
        return 0;
    }

    static long hash(int sum, boolean[] R) {
        long hash = sum;
        for(int i=0; i<R.length; i++)
            hash = hash*2 + (R[i] ? 1 : 0);
        return hash;
    }

    // Returns max score for person to play; given square has already been claimed
    static HashMap<Long,Integer> F;
    static int f(int sum, boolean[] R, boolean first) {
        long key = hash(sum, R);
        if(F.containsKey(key)) return F.get(key);
        if(sum == 2*(n-1)) return 0;

        int ans = -1000;
        int ns = sum+1;
        Character[] CH = new Character[ns+1];
        for(int r=0; r<=sum+1; r++) {
            boolean can_see = (r<R.length && R[r]) || (r-1>=0 && R[r-1]);
            if(!can_see) continue;
            int c = ns-r;
            if(c<0 || c>=n || r<0 || r>=n) continue;
            CH[r] = G[r][c];
        }

        for(int r=0; r<=sum+1; r++) {
            if(CH[r] != null) {
                char ch = CH[r];
                boolean[] NR = new boolean[ns+1];
                for(int rr=0; rr<=sum+1; rr++)
                    if(CH[rr]!=null && CH[rr] == ch) {
                        NR[rr] = true;
                        CH[rr] = null;
                    }
                ans = Math.max(ans, ch_to_val(ch,first) - f(ns, NR, !first));
            }
        }
        F.put(key, ans);
        return ans;
    }
}


import java.util.Scanner;

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

		int n = r.nextInt();
		int w = r.nextInt();
		int a = r.nextInt()-1;
		int b = r.nextInt()-1;

		int am = a%w;
		int bm = b%w;

		int res = 3;

		if(w == 1)res = 1;
		else if(a == b)res = 1;
		else if(a/w == b/w)res = 1;
		else if(am == 0 && bm == w-1)res = 1;
		else if(am == 0 && b == n-1)res = 1;
		else if(b/w - a/w == 1)res = 2;
		else if(am == 0)res = 2;
		else if(bm == w-1)res = 2;
		else if(b == n-1)res = 2;
		else if(am - bm == 1)res = 2;
		else res = 3;

		System.out.println(Math.max(1, res));
	}
}


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

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

class TaskC {

    int getN(int x) {
        if (x == 1) return 1;
        if (x == 2) return 3;
        if (x == 3) return 5;
        if (x == 4) return 3;
        if (x == 5) return 3;
        if (x <= 13) return 5;
        for (int i = 7; i <= 100; i += 2) {
            int v = i * i + 1;
            v /= 2;
            if (x <= v) return i;
        }
        return 101;
    }

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int x = in.readInt();
        out.printLine(getN(x));
    }
}

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 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 static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(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();
    }

}


import java.util.Scanner;

public class B {
	Scanner sc = new Scanner(System.in);

	void run() {
		int m = sc.nextInt();
		int zero = 0;
		for (int i = 5; zero < m; i += 5) {
			int tmp = i;
			while (tmp > 0 && tmp % 5 == 0) {
				zero ++;
				tmp /= 5;
			}
			if (zero == m) {
				StringBuilder out = new StringBuilder();
				out.append("5\n");
				for (int j = i; j <= i + 4; j++) out.append(j + " ");
				System.out.println(out);
				return;
			}
		}
		System.out.println(0);
	}

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


import java.util.*;
import java.io.*;
import java.io.FileWriter;
import java.math.BigInteger;
import java.math.BigDecimal;
// Solution

public class Main
{
  public static void main (String[] argv)
  {
	  new Main();
  }

  boolean test = false;
  final int[][] dirs8 = {{0,1}, {0,-1}, {-1,0}, {1,0}, {1,1},{1,-1},{-1,1},{-1,-1}};
  final int[][] dirs4 = {{0,1}, {0,-1}, {-1,0}, {1,0}};
  final int MOD = 1000000007;  //998244353;

  final int WALL = -1;
  final int EMPTY = -2;
  final int VISITED = 1;
  final int FULL = 2;

  final int START = 1;
  final int END = 0;

  int[] fac;
  int[] ifac;
  int[] rfac;

  int[] pow2;

  int[] mobius;
  int[] sieve;
  int[][] factors;

  final int UNVISITED = -2;

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

    //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in")));

    //int nt = in.nextInt();
    int nt = 1;
    StringBuilder sb = new StringBuilder();

    for (int it = 0; it < nt; it++)
    {
       long n = in.nextLong();
       long k = in.nextLong();

       if (k == 1){
           System.out.println(n);
           return;
       }

//System.out.println("n = " + n + " k = " + k);
       //binary search on odd numbers
       long lo = 1, hi = n / 2;

       while (lo <= hi)
       {

           long mid = (hi + lo) / 2;
           long val = mid * 2 - 1;
//System.out.println("lo = " + lo + " hi = " + hi + ", mid = " + mid + ", val = " + val);
           if (cnt(val, n) >= k) {
               //System.out.println("cnt >= 100");
               lo = mid + 1;
           }
           else {
               //System.out.println("cnt < 100");
               hi = mid - 1;
           }
       }
       long cand = hi * 2 - 1;
       if (cnt(cand, n) < k) cand = 0;

       lo = 1;
       hi = n / 2;

       while (lo <= hi)
       {
           long mid = (hi + lo) / 2;
           long val = mid * 2;
           if (cnt(val, n) >= k)
               lo = mid + 1;
           else hi = mid - 1;
       }

       cand = Math.max(cand, hi * 2);
       System.out.println(cand);
    }

    System.out.print(sb);

  }

  private long cnt(long v, long n)
  {
//System.out.println("cnting " + v + " " + n);
      if (v > n) return 0;

      long cnt = 0;
      if (v % 2 == 1) {
          long segSize = 1;
          long start = v;
          while(start <= n){
              long end = Math.min(n, start + segSize - 1);
              cnt += end - start + 1;

              segSize *= 2;
              start *= 2;
          }

      }else {

          long segSize = 2;
          long start = v;
          while(start <= n){
              long end = Math.min(n, start + segSize - 1);
              cnt += end - start + 1;

              segSize *= 2;
              start *= 2;
          }

      }
//System.out.println("cnt = " + cnt);
      return cnt;
  }

  class Node implements Comparable<Node>{
      int lo, hi;
      public Node(int lo, int hi)
      {
          this.lo = lo;
          this.hi = hi;
      }

      @Override
      public int compareTo(Node o){
          if (lo != o.lo) return lo - o.lo;
          return hi - o.hi;
      }
  }

  private long[][] matIdentity(int n)
  {
      long[][] a = new long[n][n];
      for (int i = 0; i < n; i++)
          a[i][i] = 1;
      return a;
  }
  private long[][] matPow(long[][] mat0, long p)
  {
      int n = mat0.length;
      long[][] ans = matIdentity(n);
      long[][] mat = matCopy(mat0);
      while (p > 0)
      {
          if (p % 2 == 1){
              ans = matMul(ans, mat);
          }

          p /= 2;
          mat = matMul(mat, mat);
      }
      return ans;
  }

  private long[][] matCopy(long[][] a)
  {
      int n = a.length;
      long[][] b = new long[n][n];
      for (int i = 0; i < n; i++)
          for (int j = 0; j < n; j++)
              b[i][j] = a[i][j];
      return b;
  }
  private long[][] matMul(long[][] a, long[][] b)
  {
      int n = a.length;

      long[][] c = new long[n][n];
      for (int i = 0; i < n; i++)
      {
          for (int j = 0; j < n; j++)
          {
              for (int k = 0; k < n; k++)
                  c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % MOD;
          }
      }

      return c;
  }

  private long[] matMul(long[][] a, long[] b)
  {
      int n = a.length;

      long[] c = new long[n];
      for (int i = 0; i < n; i++)
      {
          for (int j = 0; j < n; j++)
              c[i] = (c[i] + a[i][j] * b[j]) % MOD;
      }

      return c;
  }

  class Mark implements Comparable<Mark> {
      int type, h;
      long x;
      public Mark(int h, long x, int type)
      {
         this.h = h;
         this.x = x;
         this.type = type;
      }

      @Override
      public int compareTo(Mark o)
      {
          if (this.x == o.x) return type - o.type; // let end comes before start
          return Long.compare(x, o.x);
      }
  }

  private boolean coLinear(int[] p, int[] q, int[] r)
  {
      return 1L * (p[1] - r[1]) * (q[0] - r[0]) == 1L * (q[1] - r[1]) * (p[0] - r[0]);
  }

  private void fill(char[] a, int lo, int c, char letter)
  {
      //System.out.println("fill " + lo + " " + c + " " + letter);
      for (int i = lo; i < lo + c; i++) a[i] = letter;
  }

  private int cntBitOne(String s){
      int c = 0, n = s.length();
      for (int i = 0; i < n; i++)
          if (s.charAt(i) == '1') c++;
      return c;
  }

  class DSU {
      int n;
      int[] par;
      int[] sz;
      int nGroup;

      public DSU(int n)
      {
          this.n = n;
          par = new int[n];
          sz = new int[n];
          for (int i = 0;  i < n; i++){
              par[i] = i;
              sz[i] = 1;
          }
          nGroup = n;
      }

      private boolean add(int p, int q) {
          int rp = find(p);
          int rq = find(q);
          if (rq == rp) return false;

          if (sz[rp] <= sz[rq]) {
              sz[rq] += sz[rp];
              par[rp] = rq;
          }else {
              sz[rp] += sz[rq];
              par[rq] = rp;
          }
          nGroup--;
          return true;
      }

      private int find(int p)
      {
          int r = p;
          while (par[r] != r) r = par[r];

          while (r != p) {
              int t = par[p];
              par[p] = r;
              p = t;
          }
          return r;
      }

  }

  // μ(n) = 1 if n is a square-free positive integer with an even number of prime factors. e.g.  6, 15
  // μ(n) = −1 if n is a square-free positive integer with an odd number of prime factors. e.g.  2, 3, 5, 2*3*5
  // μ(n) = 0 if n has a squared prime factor. e.g : 2*2,  3*3*5
  private void build_pow2_function(int n)
  {
      pow2 = new int[n+1];
       pow2[0] = 1;
       for (int i = 1; i <= n; i++) pow2[i] = (int)(1L * pow2[i-1] * 2 % MOD);
  }

  private void build_fac_function(int n)
  {
      fac = new int[n+1];
      fac[0] = 1;
      for (int i = 1; i <= n; i++)
          fac[i] = (int)(1L * fac[i-1] * i % MOD);
  }

  private void build_ifac_function(int n)
  {
      ifac = new int[n+1];
      ifac[0] = 1;
      for (int i = 1; i <= n; i++)
          ifac[i] = (int)(1L * ifac[i-1] * inv(i) % MOD);
  }

  private void build_sieve_function(int n)
  {
      sieve = new int[n+1];
      for (int i = 2; i <= n; i++)
        sieve[i] = i;
      for (int i = 2; i <= n; i++)
      {
        if (sieve[i] == i){
            for (long j = 1L * i * i; j <= n; j += i)
                sieve[(int)j] = i;
        }
      }
  }

  private void build_mobius_function(int n)
  {
      mobius = new int[n+1];
      sieve = new int[n+1];
      factors = new int[n+1][];
      //for (int i = 1; i <= n; i++)factors[i] = new ArrayList<>();
      for (int i = 2; i <= n; i++)
        sieve[i] = i;
      for (int i = 2; i <= n; i++)
      {
        if (sieve[i] == i){
            mobius[i] = -1;
            for (long j = 1L * i * i; j <= n; j += i)
                sieve[(int)j] = i;
        }
      }

      for (int i = 6; i <= n; i++)
      {
          if (sieve[i] != i) {
              int pre = i / sieve[i];
              if (pre % sieve[i] != 0)
                  mobius[i] = -mobius[pre];
          }
      }
      int[] sz = new int[n+1];
      long tot = 0;
      for (int i = 2; i <= n; i++)
      {
          if (mobius[i] != 0)
          {
              for (int j = i * 2; j <= n; j += i) {
                  sz[j]++;
                  tot++;
              }
          }
      }
      for (int i = 2; i <= n; i++) {
          factors[i] = new int[sz[i]];
          sz[i] = 0;
      }

      for (int i = 2; i <= n; i++)
      {
          if (mobius[i] != 0)
          {
              for (int j = i * 2; j <= n; j += i) {
                  factors[j][sz[j]++] = i;
                  //factors[j].add(i);
              }
          }
      }
      //System.out.println("tot  =  "  + tot);
  }

  private int[] build_z_function(String s)
  {
      int n = s.length();
      int[] zfun = new int[n];

      int l = -1, r = -1;
      for (int i = 1; i < n; i++)
      {
         // Set the start value
         if (i <= r)
            zfun[i] = Math.min(zfun[i-l], r - i + 1);

         while (i + zfun[i] < n && s.charAt(i + zfun[i]) == s.charAt(zfun[i]))
             zfun[i]++;

         if (i + zfun[i] - 1> r){
             l = i;
             r = i + zfun[i] - 1;
         }
      }

      if (test)
      {
          System.out.println("Z-function of " + s);
          for (int i = 0; i < n; i++) System.out.print(zfun[i] + " ");
          System.out.println();
      }
      return zfun;
  }

  class BIT {
      int[] bit;
      int n;

      public BIT(int n){
          this.n = n;
          bit = new int[n+1];
      }

      private int query(int p)
      {
          int sum = 0;
          for (; p > 0; p -= (p & (-p)))
             sum += bit[p];

          return sum;
      }

      private void add(int p, int val)
      {
         //System.out.println("add to BIT " + p);
         for (; p <= n; p += (p & (-p)))
            bit[p] += val;
      }

  }

  private List<Integer> getMinFactor(int sum)
  {
      List<Integer>  factors = new ArrayList<>();

               for (int sz = 2; sz <= sum / sz; sz++){
                   if (sum % sz == 0) {
                       factors.add(sz);
                       factors.add(sum / sz);
                   }
               }
               if (factors.size() == 0)
                   factors.add(sum);

      return factors;
  }

  /* Tree class */
  class Tree {
      int V = 0;
      int root = 0;
      List<Integer>[] nbs;
      int[][] timeRange;
      int[] subTreeSize;
      int t;
      boolean dump = false;

      public Tree(int V, int root)
      {
          if (dump)
              System.out.println("build tree with size = " + V + ", root = " + root);

          this.V = V;
          this.root = root;
          nbs = new List[V];
          subTreeSize = new int[V];
          for (int i = 0; i < V; i++)
              nbs[i] = new ArrayList<>();

      }

      public void doneInput()
      {
          dfsEuler();
      }

      public void addEdge(int p, int q)
      {
          nbs[p].add(q);
          nbs[q].add(p);
      }

      private void dfsEuler()
      {
          timeRange = new int[V][2];
          t = 1;
          dfs(root);
      }

      private void dfs(int node)
      {
          if (dump)
              System.out.println("dfs on node " + node + ", at time " + t);
          timeRange[node][0] = t;

          for (int next : nbs[node]) {
              if (timeRange[next][0] == 0)
              {
                  ++t;
                  dfs(next);
              }
          }
          timeRange[node][1] = t;
          subTreeSize[node] = t - timeRange[node][0] + 1;
      }

      public List<Integer> getNeighbors(int p) {
          return nbs[p];
      }

      public int[] getSubTreeSize(){
          return subTreeSize;
      }

      public int[][] getTimeRange()
      {
          if (dump){
              for (int i = 0; i < V; i++){
                  System.out.println(i + ": " + timeRange[i][0] + " - " + timeRange[i][1]);
              }
          }
          return timeRange;
      }

  }

  /* segment tree */
  class SegTree {
      int[] a;
      int[] tree;
      int[] treeMin;
      int[] treeMax;
      int[] lazy;
      int n;
      boolean dump = false;

      public SegTree(int n)
      {
          if (dump)
              System.out.println("create segTree with size " + n);
          this.n = n;
          treeMin = new int[n*4];
          treeMax = new int[n*4];
          lazy = new int[n*4];
      }

      public SegTree(int n, int[] a) {
          this(n);
          this.a = a;
          buildTree(1, 0, n-1);
      }

      private void buildTree(int node, int lo, int hi)
      {
          if (lo == hi) {
              tree[node] = lo;
              return;
          }

          int m = (lo + hi) / 2;
          buildTree(node * 2, lo, m);
          buildTree(node * 2 + 1, m + 1, hi);
          pushUp(node, lo, hi);
      }

      private void pushUp(int node, int lo, int hi)
      {
          if (lo >= hi) return;

          // note that, if we need to call pushUp on a node, then lazy[node] must be zero.

          //the true value is the value + lazy
          treeMin[node] = Math.min(treeMin[node * 2] + lazy[node * 2], treeMin[node * 2 + 1] + lazy[node * 2 + 1]);
          treeMax[node] = Math.max(treeMax[node * 2] + lazy[node * 2], treeMax[node * 2 + 1] + lazy[node * 2 + 1]);
          // add combine fcn
      }

      private void pushDown(int node, int lo, int hi)
      {
          if (lazy[node] == 0) return;

          int lz = lazy[node];
          lazy[node] = 0;

          treeMin[node] += lz;
          treeMax[node] += lz;

          if (lo == hi) return;

          int mid = (lo + hi) / 2;
          lazy[node * 2] += lz;
          lazy[node * 2 + 1] += lz;
      }

      public int rangeQueryMax(int fr, int to)
      {
          return rangeQueryMax(1, 0, n-1, fr, to);
      }

      public int rangeQueryMax(int node, int lo, int hi, int fr, int to)
      {
          if (lo == fr && hi == to)
              return treeMax[node] + lazy[node];

          int mid = (lo + hi) / 2;
          pushDown(node, lo, hi);

          if (to <= mid) {
              return rangeQueryMax(node * 2, lo, mid, fr, to);
          }else if (fr > mid)
              return rangeQueryMax(node * 2 + 1, mid + 1, hi, fr, to);
          else {
              return Math.max(rangeQueryMax(node * 2, lo, mid, fr, mid),
                              rangeQueryMax(node * 2 + 1, mid + 1, hi, mid + 1, to));
          }
      }

      public int rangeQueryMin(int fr, int to)
      {
          return rangeQueryMin(1, 0, n-1, fr, to);
      }

      public int rangeQueryMin(int node, int lo, int hi, int fr, int to)
      {
          if (lo == fr && hi == to)
              return treeMin[node] + lazy[node];

          int mid = (lo + hi) / 2;
          pushDown(node, lo, hi);

          if (to <= mid) {
              return rangeQueryMin(node * 2, lo, mid, fr, to);
          }else if (fr > mid)
              return rangeQueryMin(node * 2 + 1, mid + 1, hi, fr, to);
          else {
              return Math.min(rangeQueryMin(node * 2, lo, mid, fr, mid),
                              rangeQueryMin(node * 2 + 1, mid + 1, hi, mid + 1, to));
          }
      }

       public void rangeUpdate(int fr, int to, int delta){
           rangeUpdate(1, 0, n-1, fr, to, delta);
       }

      public void rangeUpdate(int node, int lo, int hi, int fr, int to, int delta){
          pushDown(node, lo, hi);
          if (fr == lo && to == hi)
          {
              lazy[node] = delta;
              return;
          }

          int m = (lo + hi) / 2;
          if (to <= m)
              rangeUpdate(node * 2, lo, m, fr, to, delta);
          else if (fr > m)
              rangeUpdate(node * 2 + 1, m + 1, hi, fr, to, delta);
          else  {
              rangeUpdate(node *  2, lo, m, fr, m, delta);
              rangeUpdate(node * 2 + 1, m + 1, hi, m + 1, to, delta);
          }

          // re-set the in-variant
          pushUp(node, lo, hi);
      }

      public int query(int node, int lo, int hi, int fr, int to)
      {
          if (fr == lo && to == hi)
              return tree[node];

          int m = (lo + hi) / 2;
          if (to <= m)
              return  query(node * 2, lo, m, fr, to);
          else if (fr > m)
              return query(node * 2 + 1, m + 1, hi, fr, to);

          int lid = query(node * 2, lo, m, fr, m);
          int rid = query(node * 2 + 1, m + 1, hi, m + 1, to);
          return a[lid] >= a[rid] ? lid : rid;
      }

  }

  private long inv(long v)
  {
      return pow(v, MOD-2);
  }

  private long pow(long v, long p)
  {
      long ans = 1;
      while (p > 0)
      {
          if (p % 2 == 1)
              ans = ans * v % MOD;
          v = v * v % MOD;
          p = p / 2;
      }
      return ans;
  }

  private double dist(double x, double y, double xx, double yy)
  {
      return Math.sqrt((xx - x) * (xx - x) + (yy - y) * (yy - y));
  }

  private int mod_add(int a, int b) {
      int v = a + b;
      if (v >= MOD) v -= MOD;
      return v;
  }

  private long overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
      if (x1 > x3) return overlap(x3, y3, x4, y4, x1, y1, x2, y2);

      if (x3 > x2 || y4 < y1 || y3 > y2) return 0L;

      //(x3, ?, x2, ?)
      int yL = Math.max(y1, y3);
      int yH = Math.min(y2, y4);
      int xH = Math.min(x2, x4);

      return f(x3, yL, xH, yH);
  }
  //return #black cells in rectangle
  private long f(int x1, int y1, int x2, int y2) {
      long dx = 1L + x2 - x1;
      long dy = 1L + y2 - y1;
      if (dx % 2 == 0 || dy % 2 == 0 || (x1 + y1) % 2 == 0)
          return 1L * dx * dy / 2;
      return 1L * dx * dy / 2 + 1;
  }

  private int distM(int x, int y, int xx, int yy) {
      return abs(x - xx) + abs(y - yy);
  }

  private boolean less(int x, int y, int xx, int yy) {
      return x < xx || y > yy;
  }

  private int mul(int x, int y) {
      return (int)(1L * x * y % MOD);
  }

  private int nBit1(int v) {
      int v0 = v;
      int c = 0;
      while (v != 0) {
          ++c;
          v = v & (v - 1);
      }
      return c;
  }

  private long abs(long v) {
      return v > 0 ? v : -v;
  }

  private int abs(int v) {
      return v > 0 ? v : -v;
  }

  private int common(int v) {
      int c = 0;
      while (v != 1) {
          v = (v >>> 1);
          ++c;
      }

      return c;
  }

  private void reverse(char[] a, int i, int j) {
      while (i < j) {
          swap(a, i++, j--);
      }
  }

  private void swap(char[] a, int i, int j) {
      char t = a[i];
      a[i] = a[j];
      a[j] = t;
  }

  private int gcd(int x, int y) {
      if (y == 0) return x;
      return gcd(y, x % y);
  }
  private long gcd(long x, long y) {
      if (y == 0) return x;
      return gcd(y, x % y);
  }
  private int max(int a, int b) {
      return a >  b ? a : b;
  }

  private long max(long a, long b) {
      return a >  b ? a : b;
  }

  private int min(int a, int b) {
      return a >  b ? b : a;
  }

  private long min(long a, long b) {
      return a >  b ? b : a;
  }

  static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(BufferedReader in)
        {
            br = in;
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    String line = br.readLine();
                    if (line == null || line.length() == 0) return "";
                    st = new StringTokenizer(line);
                }
                catch (IOException  e)
                {
                    return "";
                    //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)
            {
                return null;
                //e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
import java.math.*;
import static java.lang.Character.isDigit;
import static java.lang.Character.isLowerCase;
import static java.lang.Character.isUpperCase;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Character.isDigit;

public class Main{
    static void debug(Object...os){
        System.err.println(deepToString(os));
    }
    int[] maxMove=new int[3];
    int[] power=new int[3];
    void run(){
        E init = new E();
        init.xs=new int[3];
        for(int i=0;i<3;i++) {
            init.xs[i]=nextInt();maxMove[i]=nextInt();power[i]=nextInt();
        }
        init.lift=new int[3];
        fill(init.lift,-1);
        init.lifted=new boolean[3];
        init.throwed=new boolean[3];
        init.moved=new boolean[3];
        dfs(init);
        System.out.println(res);
    }
    int res = 0;
    HashSet<Long> set=new HashSet<Long>();
    void dfs(E e) {
        if(set.contains(e.hash()))return;
        set.add(e.hash());
        if(e.reachable()<res)return;
        res = max(res,e.getmaxX());
        for(int i=0;i<3;i++) {
            // move
            boolean ok=true;
            if(e.moved[i])ok=false;
            if(e.lift[i]!=-1)ok=false;
            if(e.lifted[i])ok=false;
            if(ok) {
                ArrayList<Integer> cand = new ArrayList<Integer>();
                cand.add(e.xs[i]-maxMove[i]);
                cand.add(e.xs[i]+maxMove[i]);
                for(int j=0;j<3;j++)if(i!=j)cand.add(e.xs[j]-1);
                for(int j=0;j<3;j++)if(i!=j)cand.add(e.xs[j]+1);
                for(int j : cand)if(e.xs[i]-maxMove[i]<=j && j<=e.xs[i]+maxMove[i]) {
//              for(int j=e.xs[i]-maxMove[i];j<=e.xs[i]+maxMove[i];j++) {
                    if(j<0)continue;
                    E ne = e.myClone();
                    ne.xs[i] = j;
                    ne.moved[i] = true;
                    dfs(ne);
                }
            }
            // lift
            ok=true;
            if(e.throwed[i])ok=false;
            if(e.lift[i]!=-1)ok=false;
            if(e.lifted[i])ok=false;
            if(ok)for(int j=0;j<3;j++)if(i!=j) {
                if(abs(e.xs[i]-e.xs[j])!=1)continue;
                if(e.lifted[j])continue;
                E ne = e.myClone();
                ne.lift[i] = j;
                ne.lifted[j] = true;
                dfs(ne);
            }
            // throw
            ok=true;
            if(e.lifted[i])ok=false;
            if(e.lift[i]==-1)ok=false;
            if(ok) {
                assert !e.throwed[i];
//              ArrayList<Integer> cand = new ArrayList<Integer>();
//              cand.add(e.xs[i]-power[i]);
//              cand.add(e.xs[i]+power[i]);
//              for(int j=0;j<3;j++)if(i!=j)cand.add(e.xs[j]-1);
//              for(int j=0;j<3;j++)if(i!=j)cand.add(e.xs[j]+1);
//              for(int j:cand)if(e.xs[i]-power[i]<=j && j<=e.xs[i]+power[i]){
                for(int j=e.xs[i]-power[i];j<=e.xs[i]+power[i];j++) {
                    if(j<0)continue;
                    E ne = e.myClone();
                    ne.xs[ne.lift[i]] = j;
                    ne.lifted[ne.lift[i]] = false;
                    ne.lift[i] = -1;
                    ne.throwed[i] = true;
                    dfs(ne);
                }
            }
        }
    }

    class E{
        int[] xs;
        int[] lift;
        boolean[] lifted;
        boolean[] moved;
        boolean[] throwed;
        E myClone() {
            E res=new E();
            res.xs = xs.clone();
            res.lift=lift.clone();
            res.lifted=lifted.clone();
            res.moved=moved.clone();
            res.throwed=throwed.clone();
            return res;
        }
        public int reachable(){
            int x=getmaxX();
            for(int i=0;i<3;i++) {
                if(!moved[i])x += maxMove[i];
                if(!throwed[i])x += power[i];
            }
            return x;
        }
        public int getmaxX(){
            int res=Integer.MIN_VALUE;
            for(int x:xs)res=max(res,x);
            return res;
        }
        long hash=-1;
        long hash() {
            if(hash!=-1)return hash;
            hash=0;
            for(int x:xs)hash=hash<<6|x;
            for(int x:lift)hash=hash<<2|x+1;
            for(boolean b:lifted)hash=hash<<1|(b?1:0);
            for(boolean b:moved)hash=hash<<1|(b?1:0);
            for(boolean b:throwed)hash=hash<<1|(b?1:0);
            return hash;
        }

        public int hashCode(){
            final int prime=31;
            int result=1;
            result=prime*result+getOuterType().hashCode();
            result=prime*result+Arrays.hashCode(lift);
            result=prime*result+Arrays.hashCode(lifted);
            result=prime*result+Arrays.hashCode(moved);
            result=prime*result+Arrays.hashCode(throwed);
            result=prime*result+Arrays.hashCode(xs);
            return result;
        }
        public String toString(){
            return "E [lift="+Arrays.toString(lift)+", lifted="+Arrays.toString(lifted)+", moved="
            +Arrays.toString(moved)+", throwed="+Arrays.toString(throwed)+", xs="+Arrays.toString(xs)+"]";
        }
        public boolean equals(Object obj){
            if(this==obj) return true;
            if(obj==null) return false;
            if(getClass()!=obj.getClass()) return false;
            E other=(E)obj;
            if(!getOuterType().equals(other.getOuterType())) return false;
            if(!Arrays.equals(lift,other.lift)) return false;
            if(!Arrays.equals(lifted,other.lifted)) return false;
            if(!Arrays.equals(moved,other.moved)) return false;
            if(!Arrays.equals(throwed,other.throwed)) return false;
            if(!Arrays.equals(xs,other.xs)) return false;
            return true;
        }
        private Main getOuterType(){
            return Main.this;
        }

    }

    int nextInt(){
        try{
            int c=System.in.read();
            if(c==-1) return c;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=System.in.read();
                if(c==-1) return c;
            }
            if(c=='-') return -nextInt();
            int res=0;
            do{
                res*=10;
                res+=c-'0';
                c=System.in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    long nextLong(){
        try{
            int c=System.in.read();
            if(c==-1) return -1;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=System.in.read();
                if(c==-1) return -1;
            }
            if(c=='-') return -nextLong();
            long res=0;
            do{
                res*=10;
                res+=c-'0';
                c=System.in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

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

    String next(){
        try{
            StringBuilder res=new StringBuilder("");
            int c=System.in.read();
            while(Character.isWhitespace(c))
                c=System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    String nextLine(){
        try{
            StringBuilder res=new StringBuilder("");
            int c=System.in.read();
            while(c=='\r'||c=='\n')
                c=System.in.read();
            do{
                res.append((char)c);
                c=System.in.read();
            }while(c!='\r'&&c!='\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}


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

public class Main implements Runnable {

    private void solve() throws IOException {
        int x = nextInt();
        int y = nextInt();
        int n = nextInt();

        double minRest = 100;
        long minB = 0;
        long minA = 0;
        for (int i = 1; i <= n; i++) {
            long nk = nok(i, y);
            long td = x * (nk / y);
            long ii = nk / i;

            long tc = td / ii;
            long tr = td % ii;
            if (tr * 2 > ii) {
                tc++;
                tr = ii - tr;
            }
            double rest = tr;
            rest = rest / nk;
            if (rest < minRest) {
                minRest = rest;
                minB = i;
                minA = tc;
            }
        }
        writer.println(minA + "/" + minB);
    }

    long nod(long a, long b) {
        if (a < b) {
            long t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }
        return nod(b, a % b);
    }

    long nok(long a, long b) {
        return (a / nod(a, b)) * b;
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    @Override
    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}


import java.util.Scanner;

/**
 * Created by abgupta on 3/19/17.
 */
public class C_652_A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h1 = in.nextInt();
        int h2 = in.nextInt();

        int a = in.nextInt();
        int b = in.nextInt();
        int dh = h2-h1;

        if (a<=b) {
            if (8*a<dh) {
                System.out.println(-1);

            } else {
                System.out.println(0);
            }

            return;

        }

        int lo=0,hi= (int) 1e5;

        while(lo<hi) {
            int mid = lo + (hi-lo)/2;
            if (p(mid, dh, a ,b)) hi=mid; else lo=mid+1;
        }
        System.out.println(lo);
    }

    private static boolean p(int mid, int dh, int a, int b) {
        long l = 1l*(mid)*(a-b)*12 + 8*a;
        return l >= dh;
    }
}


 import java.util.*;

public class BruteForce{

    public static Scanner in=new Scanner(System.in);
    public static void main(String[]args){
        long n=in.nextLong();
        long ans=1+(6*n)+((n*(n-1))/2)*6;
        System.out.println(ans);
    }

}


import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.*;
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);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }
    static class Solver {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            long start = System.currentTimeMillis();
            long end = start + 1000; // 1000 ms/sec
            long tmp = 1;
            while (System.currentTimeMillis() < end) {
                ++tmp;
            }
            for (int t : a) {
                out.print(t + " ");
            }
        }
        static String reverse(String s) {
            String rev = "";
            for (int i = 0; i < s.length(); ++i) {
                rev += s.charAt(s.length() - i - 1);
            }
            return rev;
        }
    } // wubba lubba dub dub
    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.hasMoreElements()) {
                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());
        }
    }
}


import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.io.InputStream;

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

class TaskC {
    private int[] computer;
    private boolean[] v;
    private int[] allowed;
    private int[] Gin;
    private boolean[][] edge;
    private int N;
    private ArrayList<Integer>[] graph;

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        N = in.nextInt();
        v = new boolean[N + 1];
        allowed = new int[N + 1];
        Gin = new int[N + 1];
        computer = new int[N + 1];
        edge = new boolean[N + 1][N + 1];
        for(int i = 1; i <= N; i++)
            computer[i] = in.nextInt();
        graph = new ArrayList[N + 1];
        for(int i = 1; i <= N; i++)
            graph[i] = new ArrayList<Integer>();
        int completed = 0;
        int k, t, start = 0;
        for(int i = 1; i <= N; i++) {
            k = in.nextInt();
            for(int j = 0; j < k; j++) {
                t = in.nextInt();
                if(!edge[t][i]) {
                    graph[t].add(i);
                    Gin[i]++;
                }
                edge[t][i] = true;
            }
        }

        int r1 = go(1);
        int r2 = go(2);
        int r3 = go(3);

        int res = Math.min(r1, Math.min(r2, r3));

        out.print(res);
	}

    private int go(int start) {
        int comp = start;
        int completed = 0;
        int time = 0;
        boolean reset = false;
        int[] need = new int[N + 1];
        System.arraycopy(Gin, 0, need, 0, N + 1);

        while(completed < N) {
            for(int i = 1; i <= N; i++)
                if(need[i] == 0 && computer[i] == comp) {
                    need[i] = -1;
                    time++;
                    completed++;

                    for(int j = 0; j < graph[i].size(); j++) {
                        need[graph[i].get(j)]--;
                        if(need[graph[i].get(j)] == 0 && computer[graph[i].get(j)] == comp)
                            reset = true;
                    }

                    if(reset)
                        i = 0;
                }

            time++;
            comp = comp % 3 + 1;
        }

        return time - 1;
    }

}


//*******************************************************************
// Welcome to CompileJava!
// If you experience any issues, please contact us ('More Info')  -->
//*******************************************************************

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

public class CF328B {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));

String line = br.readLine();
int[] createCount = new int[10];
for (int i = 0; i < line.length(); i++) {
createCount[line.charAt(i) - '0']++;
}
createCount[2] += createCount[5];
createCount[6] += createCount[9];
createCount[5] = 0;
createCount[9] = 0;

int[] count = new int[10];
line = br.readLine();
for (int i = 0; i < line.length(); i++) {
count[line.charAt(i) - '0']++;
}
count[2] += count[5];
count[6] += count[9];
count[5] = 0;
count[9] = 0;

int min = Integer.MAX_VALUE;
for (int i = 0; i < 10; i++) {
if (createCount[i] == 0) continue;
min = Math.min(min, count[i] / createCount[i]);
}

pw.println(min);
pw.close();
}
}

/*
import java.lang.Math; // headers MUST be above the first class

// one class needs to have a main() method
public ss HelloWorld
{
  // arguments are passed using the text field below this editor
  public static void main(String[] args)
  {
    OtherClass myObject = new OtherClass("Hello World!");
    System.out.print(myObject);
  }
}

// you cn add other public classes to this editor in any order
public ass OtherClass
{
  private String message;
  private boolean answer = false;
  public OtherClass(String input)
  {
    message = "Why, " + input + " Isn't this something?";
  }
  public String toString()
  {
    return message;
  }
}
*/


//created by Whiplash99
import java.io.*;
import java.util.*;
public class A
{
    private static ArrayList<Long> list, subsets;
    private static void allSubsets(int i, long sum)
    {
        if(i==list.size())
        {
            subsets.add(sum);
            return;
        }

        allSubsets(i+1,sum+list.get(i));
        allSubsets(i+1,sum);
    }
    private static boolean check(long M, long W, long x)
    {
        if(x==M) return true;

        boolean flag=true;
        x+=M;
        while (x>0)
        {
            if(x%W>1)
            {
                flag=false;
                break;
            }
            x/=W;
        }

        return flag;
    }
    public static void main(String[] args) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        String[] s=br.readLine().trim().split(" ");
        long W=Long.parseLong(s[0]);
        long M=Long.parseLong(s[1]);

        if(W==2)
        {
            System.out.println("YES");
            System.exit(0);
        }

        list=new ArrayList<>();
        list.add(1L); list.add(W);

        long cur=W;
        final long MAX=(long)(1e10);

        while (true)
        {
            cur*=W;
            if(cur<0||cur>MAX) break;

            list.add(cur);
        }

        subsets = new ArrayList<>();
        allSubsets(0,0);

        boolean flag=false;
        for(long x: subsets)
        {
            flag |= check(M, W, x);
            if(flag) break;
        }

        System.out.println(flag?"YES":"NO");
    }
}


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

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

/**
 *
 * @author Ivan
 */
public class secondProblem {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        long players=Reader.nextInt();
        long teams=Reader.nextInt();
        long max,min;
       // long[] maxTeams=new long[teams];
        max=(players-teams+1)*(players-teams)/2;
       // int[] minTeams=new int[teams];
        long mem=players/teams;
        long temp=teams;
        players-=mem*teams;
        min=0;
        if(players!=0)
            min+=players*(mem+1)*mem/2;
        min+=(temp-players)*mem*(mem-1)/2;
       // for(int i=0;i<teams;i++)
         //   System.out.println(minTeams[i]);
       // max=maxTeams[0]*(maxTeams[0]-1)/2;

        System.out.println(min+" "+max);
    }

}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

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


import java.util.Scanner;
/*
 20.12.68 20.12.50
 20.12.68 21.12.50
 20.12.68 19.12.50
 */
public class b30 {
	static int[][] days;
	static int[] comp, birth;
	static boolean[] used;
	static int[] attempt;

	public static void main(String[] args) {
		comp= new int[3];
		birth = new int[3];
		used = new boolean[3];
		attempt = new int[3];
		days = new int[][] {
				{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
				{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } };
		Scanner in = new Scanner(System.in);
		int i = 0;
		for (String string : in.next().split("\\.")) {
			comp[i++] = Integer.parseInt(string);
		}
		i = 0;
		for (String string : in.next().split("\\.")) {
			birth[i++] = Integer.parseInt(string);
		}
		in.close();

		System.out.println(recurse(2) ? "YES" : "NO");
	}

	private static boolean recurse(int i) {
		if (i == -1) {
			int ydiff = comp[2] - attempt[2];

			if (comp[1] < attempt [1] || (comp[1] == attempt[1] && comp[0] < attempt[0]))
					ydiff--;
//			System.out.printf("%d:%d:%d - %d\n", attempt[0], attempt[1], attempt[2], ydiff);
			return ydiff >= 18;
		} else {
			boolean works = false;
			for (int j = 0; j < 3; j++) {
				if (!used[j]) {
					if (i == 0) {
						int arr = attempt[2] % 4 == 0 ? 1 : 0;
						if (birth[j] > days[arr][attempt[1]-1])
							continue;
					}
					if (i == 1 && birth[j] > 12)
						continue;
					used[j] = true;
					attempt[i] = birth[j];
					works |= recurse(i - 1);
					used[j] = false;
				}
			}
			return works;
		}
	}
}