import java.io.*;
import java.util.*;
import java.math.*;
public
class TaskA{
    //static variable
    static final int mod = (int) 1e9 + 7;
    static final double eps = 1e-6;
    static final double pi = Math.PI;
    static final long inf = Long.MAX_VALUE / 2;

    BufferedReader br;
    void main1() throws IOException {
        br=new BufferedReader(new InputStreamReader(System.in));
        int t=ii();
        int[] aa=new int[t];
        for (int i = 0; i <t ; i++) {
            aa[i]=ii();
        }
        int flag=0;
        int a=1,b=2;
        for (int i = 0; i <t ; i++) {
            if(aa[i]==a)
                b=6-(a+b);
            else if(aa[i]==b)
                a=6-(a+b);
            else {
                flag = 1;
                break;
            }

        }

        if(flag==1)
            System.out.println("NO");
        else
            System.out.println("YES");

    }

    //Main Method............................................................................................................
    public static void main(String[] args) throws IOException {new TaskA().main1();}
    //.......................................................................................................................

    //static class
    static class Pair{
        int key,value;
        Pair(int key,int value){
            this.key=key;
            this.value=value;
        }
        int Key(){
            return key;
        }
        int Value(){
            return value;
        }
    }
    //input method
    int[] iint() throws IOException{
        String line[]=br.readLine().split(" ");
        int[] a=new int[line.length];
        for (int i=0;i<line.length ;i++ ) {
            a[i]=Integer.parseInt(line[i]);
        }
        return a;
    }
    long[] ilong() throws IOException{
        String line[]=br.readLine().split(" ");
        long[] a=new long[line.length];
        for (int i=0;i<line.length ;i++ ) {
            a[i]=Long.parseLong(line[i]);
        }
        return a;
    }
    double[] idouble() throws IOException{
        String line[]=br.readLine().split(" ");
        double[] a=new double[line.length];
        for (int i=0;i<line.length ;i++ ) {
            a[i]=Long.parseLong(line[i]);
        }
        return a;
    }
    long li() throws IOException{

        return Long.parseLong(br.readLine());
    }
    int ii() throws IOException{

        return Integer.parseInt(br.readLine());
    }
    double di() throws IOException{
        return Double.parseDouble(br.readLine());
    }
    char ci() throws IOException{
        return (char)br.read();
    }
    String si() throws IOException{
        return br.readLine();
    }
    String[] isa() throws IOException{
        String at =si();
        return at.split(" ");
    }

    double[][] idm(int n, int m) throws IOException{
        double a[][] = new double[n][m];
        for (int i = 0; i < n; i++) {
            double[] temp=idouble();
            for (int j = 0; j < m; j++) a[i][j] = temp[j];
        }
        return a;
    }

    int[][] iim(int n, int m) throws IOException{
        int a[][] = new int[n][m];
        for (int i = 0; i < n; i++) {
            int[] temp=iint();
            for (int j = 0; j < m; j++) a[i][j] =temp[j];
        }
        return a;
    }
    long[][] ilm(int n, int m) throws IOException{
        long a[][] = new long[n][m];
        for (int i = 0; i < n; i++) {
            long[] temp=ilong();
            for (int j = 0; j < m; j++) a[i][j] =temp[j];
        }
        return a;
    }

}


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

public class IlyaandBankAccount {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		long num=0;
		try {
			num = Long.parseLong(br.readLine());
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		long aux=num;
		if(num<0){
			num*=-1;
			int d1=(int) (num%10);
			num=num/10;
			int d2=(int) (num%10);
			num=num/10;
			if(d1>d2){
				System.out.println(aux/10);
				return;
			}
			if(d1<d2){
				num=num*10;
				num=num+d1;
				System.out.println(num*-1);
				return;
			}else{
				System.out.println(aux/10);
			}

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

}


import java.util.*;

public class Sleep
{
    public static void main(String[] args)
    {
        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Enter first time");
        String s = sc.next();
        // System.out.println("Enter second time");
        String t = sc.next();

        int shours = Integer.valueOf(s.substring(0,2));
        int thours = Integer.valueOf(t.substring(0,2));

        int smins = Integer.valueOf(s.substring(3));
        int tmins = Integer.valueOf(t.substring(3));

        int answerhours = shours - thours;
        if (answerhours < 0)
            answerhours += 24;

        int answermins = smins - tmins;
        if (answermins < 0)
        {
            answermins += 60;
            answerhours--;
            if (answerhours < 0)
                answerhours = 23;
        }

        String stringhours = Integer.toString(answerhours);
        String stringmins = Integer.toString(answermins);

        if (stringhours.length() == 1)
        {
            stringhours = "0"+stringhours;
        }
        if (stringmins.length() == 1)
        {
            stringmins = "0" + stringmins;
        }
        System.out.println(stringhours + ":" + stringmins);
    }
}


import java.util.*;
import java.io.*;
public class Solution {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    static void sort(int a[]){ // int -> long
        ArrayList<Integer> arr=new ArrayList<>(); // Integer -> Long
        for(int i=0;i<a.length;i++)
        arr.add(a[i]);
        Collections.sort(arr);
        for(int i=0;i<a.length;i++)
        a[i]=arr.get(i);

    }
    private static long gcd(long a, long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }
    private static long pow(long x,long y){
        if(y==0)return 1;
        long temp = pow(x, y/2);
        if(y%2==1){
            return x*temp*temp;
        }
        else{
            return temp*temp;
        }
    }
    static int log(long n){
        int res = 0;
        while(n>0){
            res++;
            n/=2;
        }
        return res;
    }

    static int mod = (int)1e9+7;
    static PrintWriter out;
    static FastReader sc ;
    public static void main(String[] args) throws IOException {
        sc = new FastReader();
        out = new PrintWriter(System.out);
        // primes();
        // ================================ //
        long n= sc.nextLong();
        long m= sc.nextLong();
        solver(n, m);
        // ================================ //
        out.flush();
    }

    public static void solver(long n, long m) {
        if(m==n){
            out.println("YES");
            return;
        }
        // if(m%2==0){
        //     out.println("NO");
        //     return;
        // }
        String s = Long.toBinaryString(n);

        int t = log(m)-log(n);
        String ss = rev(s);
        if(m==Long.parseLong(ss, 2)){
            out.println("YES");
            return;
        }
        for(int k = 1;k<=t;k++){
            // normal
            for(int i=0;i<k;i++){
                if(m==Long.parseLong("1".repeat(i)+s+"1".repeat(k-i), 2)){
                    out.println("YES");
                    return;
                }
                if(m==Long.parseLong("1".repeat(k-i)+ss+"1".repeat(i),2)){
                    out.println("YES");
                    return;
                }
            }
        }
        s = rev2(s);
        ss = rev(s);
        if(m==Long.parseLong(ss, 2) || m==Long.parseLong(s,2)){
            out.println("YES");
            return;
        }
        t = log(m)-log(Math.min(Long.parseLong(s,2), Long.parseLong(ss,2)));
        for(int k = 1;k<=t;k++){
            // normal
            for(int i=0;i<=k;i++){
                if(m==Long.parseLong("1".repeat(i)+s+"1".repeat(k-i), 2)){
                    out.println("YES");
                    return;
                }
                if(m==Long.parseLong("1".repeat(k-i)+ss+"1".repeat(i),2)){
                    out.println("YES");
                    return;
                }
                // System.out.println("__"+  "1".repeat(i)+s+"1".repeat(k-i)  );
                // System.out.println("__"+  "1".repeat(i)+ss+"1".repeat(k-i)  );
            }
        }
        out.println("NO");
    }
    static String rev2(String s){
        StringBuilder str = new StringBuilder(s);
        str = str.reverse();
        while(str.charAt(0)=='0')str.deleteCharAt(0);
        return str.toString();
    }
    static String rev(String s){
        StringBuilder str = new StringBuilder(s);
        str = str.reverse();
        // while(str.charAt(0)=='0')str.deleteCharAt(0);
        return str.toString();
    }
}


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

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

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int digCount = digCount(n - 1) + digCount(m - 1);
            if (digCount > 7) {
                out.println(0);
                return;
            }
            Debug debug = new Debug(out);
            int answer = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    String s = Integer.toString(i, 7) + Integer.toString(j, 7);
                    while (s.length() < digCount) {
                        s += "0";
                    }
                    int[] ct = new int[8];
                    for (int k = 0; k < s.length(); ++k) {
                        ++ct[s.charAt(k) - '0'];
                    }
                    boolean flag = true;
                    for (int k = 0; k < ct.length; ++k) {
                        flag &= ct[k] <= 1;
                    }
                    if (flag) {
                        debug.tr(s);
                        ++answer;
                    }
                }
            }
            out.println(answer);
        }

        private int digCount(int val) {
            if (val < 7) return 1;
            return 1 + digCount(val / 7);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

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

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

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

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

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

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

        }

    }

    static class Debug {
        PrintWriter out;
        boolean oj;

        public Debug(PrintWriter out) {
            oj = System.getProperty("ONLINE_JUDGE") != null;
            this.out = out;
        }

        public void tr(Object... objects) {
            if (objects.length > 0 && !oj) {
                out.println(Arrays.deepToString(objects));
            }
        }

    }
}


import java.util.*;
public class CodeForces_474A{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    String arr="qwertyuiop";
    String brr="asdfghjkl;";
    String crr="zxcvbnm,./";
    String a=sc.next();
    String b=sc.next();
    String[]x=b.split("");
    if(a.equals("R")){
      for(int i=0;i<b.length();i++){
        if(arr.contains(x[i])){
          int y=arr.indexOf(x[i]);
          System.out.print(arr.charAt(y-1));
        }
        else if(brr.contains(x[i])){
          int y=brr.indexOf(x[i]);
          System.out.print(brr.charAt(y-1));
        }
        if(crr.contains(x[i])){
          int y=crr.indexOf(x[i]);
          System.out.print(crr.charAt(y-1));
        }
      }
    }
       else{
         for(int i=0;i<b.length();i++){
        if(arr.contains(x[i])){
          int y=arr.indexOf(x[i]);
          System.out.print(arr.charAt(y+1));
        }
        else if(brr.contains(x[i])){
          int y=brr.indexOf(x[i]);
          System.out.print(brr.charAt(y+1));
        }
        if(crr.contains(x[i])){
          int y=crr.indexOf(x[i]);
          System.out.print(crr.charAt(y+1));
        }
      }
       }

  }
}


import java.util.Calendar;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.Scanner;

public class Main {

    public static int[][]map;

    public static boolean [][]visited;
    public static int max=0;
    public static int m;
    public static int n;
    public static void main(String[]args)
    {
        Calendar c = new GregorianCalendar();
        Scanner x =new Scanner (System.in);
        int year = c.get(Calendar.YEAR);

        while(x.hasNext())
        {
            String a=x.nextLine();
            String []y=a.split(" ");
            if(y[2].equals("week"))
            {
                int week=Integer.parseInt(y[0]);
                if(week<=4||week==7)
                {
                    System.out.println(52);
                }
                else if(week==5||week==6)
                {
                    System.out.println(53);

                }

            }
            else
            {

                int month=Integer.parseInt(y[0]);

                if(month<=29)
                {
                    System.out.println(12);
                }
                else if(month==30)
                {
                    System.out.println(11);
                }
                else
                {
                    System.out.println(7);
                }

            }

    }

        }

}


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

public class B {

	public static void main(String[] args)  {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		long a = scan.nextLong(), b = scan.nextLong();
		if(b-a >= 10) out.println(0);
		else {
			long res = 1;
			for(long i = a+1; i <= b; i++) res = res*i%10;
			out.println(res);
		}
		out.close();
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e){e.printStackTrace();}
		}

		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}

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

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

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

		public String nextLine() {
			String line = "";
			if(st.hasMoreTokens()) line = st.nextToken();
			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
			while(st.hasMoreTokens()) line += " "+st.nextToken();
			return line;
		}

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

		public long[] nextLongArray(int n){
			long[] a = new long[n];
			for(int i = 0; i < n; i++) a[i] = nextLong();
			return a;
		}

		public double[] nextDoubleArray(int n){
			double[] a = new double[n];
			for(int i = 0; i < n; i++) a[i] = nextDouble();
			return a;
		}

		public char[][] nextGrid(int n, int m){
			char[][] grid = new char[n][m];
			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
			return grid;
		}
	}

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int n=sc.nextInt();
			int l=sc.nextInt();
			int r=sc.nextInt();
			int sumshu=2;
			int shu=2;
			if(l==1){
			System.out.print(n+" ");
			}else {
			for (int i = 1; i < l-1; i++) {
				shu*=2;
				sumshu+=shu;
			}
					int min=((n-l)+1)+sumshu;
					System.out.print(min+" ");
			}
					sumshu=1;
					shu=1;
					for (int i = 1; i < r; i++) {
						shu*=2;
						sumshu+=shu;
					}
					System.out.println(sumshu+(n-r)*shu);
		}
	}

}


import java.math.BigInteger;
import java.util.*;
public class Main {
    static final int MOD = 1000000007;
    public static int count(int h , int w) {
        int totaldp = 0;
        boolean[][]
        myf = new boolean[h][w];
        int[][][][] dp = new int[2][2][w][w];
        for (int row = 0; row < h; ++row) {
            int[][][][] newdp = new int[2][2][w][w];
            for (int fd = 0; fd < 2; ++fd)
                for (int ld = 0; ld < 2; ++ld)
                    for (int fc = 0; fc < w; ++fc)
                        for (int lc = fc; lc < w; ++lc) {
                            int cur = dp[fd][ld][fc][lc];
                            if (cur == 0) continue;
                            for (int newfd = fd; newfd < 2; ++newfd)
                                for (int newld = ld; newld < 2; ++newld) {
                                    int newfc; if (newfd == 0) newfc = fc;
                                    else if (fd == 0) newfc = fc + 1;
                                    else newfc = fc;
                                    int newlc;
                                    if (newld == 0) newlc = lc;
                                    else if (ld == 0) newlc = lc - 1;
                                    else newlc = lc;
                                    if (newfc > newlc) continue;
                                    int[] arr = newdp[newfd][newld][newfc];
                                    arr[newlc] += cur;
                                    if (arr[newlc] >= MOD) arr[newlc] -= MOD;
                                }
                        }
            for (int fd = 0; fd < 2; ++fd)
                for (int ld = 0; ld < 2; ++ld) {
                    int[][] arr = newdp[fd][ld];
                    if (fd == 0 && ld == 1) {
                        int lastDelta = ld == 0 ? 1 : -1;
                        int lastMin = lastDelta == 1 ? 0 : w - 1;
                        int lastMax = lastDelta == 1 ? w : -1;
                        for (int lc = lastMin; lc != lastMax; lc += lastDelta) {
                            for (int fc = 0; fc <= lc; ++fc) {
                                int cur = arr[fc][lc];
                                if (cur == 0) continue;
                                int newlc = lc + lastDelta;
                                if (newlc >= fc && newlc < w) {
                                    arr[fc][newlc] += cur;
                                    if (arr[fc][newlc] >= MOD) arr[fc][newlc] -= MOD;
                                }
                            }
                        }
                        int firstDelta = fd == 0 ? -1 : 1;
                        int firstMin = firstDelta == 1 ? 0 : w - 1;
                        int firstMax = firstDelta == 1 ? w : -1;
                        for (int fc = firstMin; fc != firstMax; fc += firstDelta) {
                            for (int lc = fc; lc < w; ++lc) {
                                int cur = arr[fc][lc];
                                if (cur == 0) continue;
                                int newfc = fc + firstDelta;
                                if (newfc >= 0 && newfc <= lc) {
                                    arr[newfc][lc] += cur;
                                    if (arr[newfc][lc] >= MOD) arr[newfc][lc] -= MOD;
                                }
                            }
                        }
                    } else {
                        int firstDelta = fd == 0 ? -1 : 1;
                        int firstMin = firstDelta == 1 ? 0 : w - 1;
                        int firstMax = firstDelta == 1 ? w : -1;
                        for (int fc = firstMin; fc != firstMax; fc += firstDelta) {
                            for (int lc = fc; lc < w; ++lc) {
                                int cur = arr[fc][lc];
                                if (cur == 0) continue;
                                int newfc = fc + firstDelta;
                                if (newfc >= 0 && newfc <= lc) {
                                    arr[newfc][lc] += cur;
                                    if (arr[newfc][lc] >= MOD) arr[newfc][lc] -= MOD;
                                }
                            }
                        }
                        int lastDelta = ld == 0 ? 1 : -1;
                        int lastMin = lastDelta == 1 ? 0 : w - 1;
                        int lastMax = lastDelta == 1 ? w : -1;
                        for (int lc = lastMin; lc != lastMax; lc += lastDelta) {
                            for (int fc = 0; fc <= lc; ++fc) {
                                int cur = arr[fc][lc];
                                if (cur == 0) continue;
                                int newlc = lc + lastDelta;
                                if (newlc >= fc && newlc < w) {
                                    arr[fc][newlc] += cur;
                                    if (arr[fc][newlc] >= MOD) arr[fc][newlc] -= MOD;
                                }
                            }
                        }
                    }
                }
            for (int fc = 0; fc < w; ++fc) {
                boolean ok = true;
                for (int lc = fc; lc < w; ++lc) {
                    if (myf[row][lc])
                        ok = false;
                    if (!ok) {
                        for (int fd = 0; fd < 2; ++fd)
                            for (int ld = 0; ld < 2; ++ld)
                                newdp[fd][ld][fc][lc] = 0;
                   } else {
                        newdp[0][0][fc][lc] += 1;
                        if (newdp[0][0][fc][lc] >= MOD) newdp[0][0][fc][lc] -= MOD;
                    }
                }
            }
            dp = newdp;
            for (int fd = 0; fd < 2; ++fd)
                for (int ld = 0; ld < 2; ++ld)
                    for (int fc = 0; fc < w; ++fc)
                        for (int lc = fc; lc < w; ++lc) {
                            totaldp += dp[fd][ld][fc][lc];
                            if (totaldp >= MOD) totaldp -= MOD;
                        }
        }
        return totaldp;
    }
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt(), m = cin.nextInt();
        System.out.println(count(n, m));
    }
}


import java.util.Scanner;

public class ProblemA {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int luke = scan.nextInt();
		int wall1 = scan.nextInt();
		int v1 = scan.nextInt();
		int v2 = scan.nextInt();
		double time = (double)(wall1-luke)/(v1+v2);
		System.out.println(time);
	}

}


import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

public class Main {

	static class TreeNode{
		int val;
		TreeNode left;
		TreeNode right;
		public TreeNode(int val) {
			this.val=val;
		}
	}

	static int gcd(int m,int n) {
		int c;
		while(n>0) {
			c=m%n;
			m=n;
			n=c;
		}
		return m;
	}

    public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);
    	int a=sc.nextInt();
    	int b=sc.nextInt();
    	int cnt=0;
    	if(a>b) {
    		System.out.println(-1);
    		return;
    	}
    	if(a==b) {
    		System.out.println(0);
    		return;
    	}
    	if(b%a!=0) {
    		System.out.println(-1);
    		return;
    	}
    	int q=b/a;
    	while(q!=1) {
    		if(q%3==0)q/=3;
    		else if(q%2==0) q/=2;
    		else break;
    		cnt++;
    	}
    	if(q!=1||cnt==0)
    		System.out.println(-1);
    	else
    		System.out.println(cnt);
    }
}


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

public class Problem {

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

		new Problem().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;
	Random rnd = new Random();
	static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	Problem() throws FileNotFoundException{

		if (ONLINE_JUDGE) {
			in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}
		tok = new StringTokenizer("");
	}

	// ======================================================

	class Dsu{
		int[] parents;
		int countUnions;
		Dsu(int size){
			this.parents = new int[size];
			this.countUnions = size;
			for(int i=0;i<size;++i){
				parents[i] = i;
			}
		}
		int get(int v){
			if(v == parents[v]){
				return v;
			}
			return parents[v] = get(parents[v]);
		}
		boolean union(int a, int b){
			if(parents[a]==parents[b]) return false;
			if(rnd.nextBoolean()){
				parents[a] = b;
			}else{
				parents[b] = a;
			}
			countUnions--;
			return true;
		}
	}
	int INF = 1000*1000*1000+7;
	void solve() throws IOException {
		int x1 = rI();
		int y1 = rI();
		int x2 = rI();
		int y2 = rI();
		int x = rI();
		int y = rI();

		if(Math.abs(x1-x2)%x==0&&(Math.abs(y1-y2)%y==0)&&(Math.abs(x1-x2)/x-(Math.abs(y1-y2))/y)%2==0){
			out.println("YES");
		}else{
			out.println("NO");
		}

	}

	// ======================================================
	void run() throws IOException {
		solve();
		out.close();
	}

	char[] reverseCharArray(char[] arr){
		char[] ans = new char[arr.length];
		for(int i=0;i<arr.length;++i){
			ans[i] = arr[arr.length-i-1];
		}
		return ans;
	}
	int sqrt(double m){
		int l = 0;
		int r = 1000000000+9;
		int i=1000;
		while(r-l>1){
			int mid = (r+l)/2;
			if(mid*mid>m){
				r = mid;
			}else{
				l = mid;
			}
		}
		return l;
	}
	int countPow(int m,int n){
		int ans = 0;
		while(m%n==0&&m>0){
			ans++;
			m/=n;
		}
		return ans;
	}
	long binPow(long a, long b){
		if(b == 0){
			return 1;
		}
		if(b%2==1){
			return a*binPow(a,b-1);
		}else{
			long c = binPow(a,b/2);
			return c*c;
		}

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

	long pow(long x, long k){
		long ans=1;
		for(int i=0;i<k;++i){
			ans*=x;
		}
		return ans;
	}
	//////////////////////////////////////////////////////////////////////

	String delimiter = " ";
	String readLine() throws IOException {
		return in.readLine();
	}
	String rS() throws IOException {
		while (!tok.hasMoreTokens()) {
			String nextLine = readLine();
			if (null == nextLine)
				return null;

			tok = new StringTokenizer(nextLine);
		}

		return tok.nextToken(delimiter);
	}
	int rI() throws IOException {
		return Integer.parseInt(rS());
	}

	long rL() throws IOException {
		return Long.parseLong(rS());
	}
	int[] rA(int b) {
		int a[] = new int[b];
		for (int i = 0; i < b; i++) {
			try {
				a[i] = rI();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return a;
	}

	int[] readSortedIntArray(int size) throws IOException {
	        Integer[] array = new Integer[size];

	        for (int index = 0; index < size; ++index) {
	            array[index] = rI();
	        }
	        Arrays.sort(array);

	        int[] sortedArray = new int[size];
	        for (int index = 0; index < size; ++index) {
	            sortedArray[index] = array[index];
	        }

	        return sortedArray;
	    }
//
}


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

public class Game {
  public static void main(String[] args) throws IOException {
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String[] input = bf.readLine().split(" ");
    String answer = "";
    long a, b, mod, ans;
    boolean oneWin = false;
    a = Integer.parseInt(input[0]);
    b = Integer.parseInt(input[1]);
    mod = Integer.parseInt(input[2]);
    long limit = Math.min(a, mod);
    long res = 0;

    for (ans = 1; ans <= limit; ans++) {
      res = (((ans % mod) * (1000000000 % mod)) % mod);
      if ((mod - res)% mod > b) {
          oneWin = true;
          break;
      }
    }

    if (oneWin) {
      String temp = String.valueOf(ans);
      int digits = temp.length();
      for (int i = 0;i < 9 - digits; i++) {
        answer += "0";
      }
      answer += String.valueOf(ans);
      System.out.println("1 " + answer);
    } else {
      System.out.println(2);
    }
  }
}


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 {
        private final int MOD = (int) 1e9 + 7;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();

            long ans = 0;
            for (int i = 0; i <= n; ++i) {
                for (int j = 0; j <= m; ++j) {
                    int eveni = n % 2 == 1 ? (n + 1) / 2 : n / 2 + (i + 1) % 2;
                    int evenj = m % 2 == 1 ? (m + 1) / 2 : m / 2 + (j + 1) % 2;

                    int oddi = n - eveni + 1;
                    int oddj = m - evenj + 1;

                    int odd = oddi * oddj;
                    int all = (n + 1) * (m + 1);
                    int even = all - odd;

                    ans += (long) even * even % MOD;
                    ans += (long) odd * odd % MOD;
                    ans %= MOD;
                }
            }

            int[] dp;
            dp = new int[n + 1];
            for (int i = 1; i <= n; ++i) {
                dp[i] = dp[i - 1] + i;
                ans = (ans - 6L * (m + 1) * dp[i]) % MOD;
            }
            dp = new int[m + 1];
            for (int i = 1; i <= m; ++i) {
                dp[i] = dp[i - 1] + i;
                ans = (ans - 6L * (n + 1) * dp[i]) % MOD;
            }

            dp = new int[m + 1];
            int[] ndp = new int[m + 1];

            int[][] gcd = new int[n + 1][m + 1];

            for (int i = 1; i <= n; ++i) {
                //ndp[0] = dp[0] + i;
                //ans = (ans - 6L * ndp[0]) % MOD;
                for (int j = 1; j <= m; ++j) {
                    if (gcd[i][j] == 0) {
                        gcd[i][j] = 1;
                        for (int p = 2; i * p <= n && p * j <= m; ++p)
                            gcd[i * p][j * p] = p;
                    }
                    ndp[j] = (dp[j] + ndp[j - 1]) % MOD;
                    ndp[j] = (ndp[j] - dp[j - 1]) % MOD;
                    ndp[j] = (ndp[j] + gcd[i][j]) % MOD;
                    ans = (ans - 12L * ndp[j]) % MOD;

                    //int sub = (i + 1) * (j + 1) - 1;
                    //ans = (ans - 6L * sub) % MOD;
                }
                int[] aux = dp;
                dp = ndp;
                ndp = aux;
            }

            ans -= (n + 1) * (m + 1);
            ans %= MOD;
            if (ans < 0) ans += MOD;

            out.println(ans);
        }

    }

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

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

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

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

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

            return res.toString();
        }

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

    }
}


import java.util.*;
 public class Main{
  public static void main(String args[]){
  Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int count=1;

  int temp=0;
  int tempp=0;
  int ans=0;
  temp=Math.min(a,b);
  ans+=temp;
  count=2;
  while(count != n&&n!=1)
  {
      if(temp==a){tempp=a;
        temp=Math.min(a,c);
        count++;
        ans+=temp;
      }
      else{
        if(temp==b)
        {tempp=b;
          temp=Math.min(b,c);
          count++;ans+=temp;
        }
        else
        {
          if(tempp==b){
          temp=Math.min(c,b);count++;ans+=temp;}
          else
          {
             temp=Math.min(c,a);
            // System.out.println(ans);
             count++;
             ans+=temp;
          }
        }

      }
  }
  if(n==1) System.out.println(0);
  else System.out.println(ans);
}}


//package que_a;

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

public class utkarsh {

    InputStream is;
    PrintWriter out;

    long mod = (long) (1e9 + 7), inf = (long) (3e18);

    class pair {
        int W, C, N;
        pair(int w, int c, int n) {
            W = w;  C = c;  N = n;
        }
    }

    void solve() {
        int W = ni(), n = ni();
        pair p[] = new pair[n+1];
        p[0] = new pair(ni(), ni(), 10101);
        for(int i = 1; i <= n; i++) {
            int N = ni() / ni();
            p[i] = new pair(ni(), ni(), N);
        }
        int dp[][] = new int[n+1][W+1];
        for(int i = p[0].W; i <= W; i++) {
            dp[0][i] = (i / p[0].W) * p[0].C;
        }
        for(int i = 1; i <= n; i++) {
            for(int j = 0; j <= W; j++) dp[i][j] = dp[i-1][j];
            int w = 0, c = 0;
            for(int k = 1; k <= p[i].N; k++) {
                w += p[i].W;    c += p[i].C;
                for(int j = w; j <= W; j++) {
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][j - w] + c);
                }
            }
        }
        out.println(dp[n][W]);
    }

    long mp(long b, long e) {
        long r = 1;
        while(e > 0) {
            if((e&1) == 1)  r = (r * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return r;
    }

    //---------- I/O Template ----------

    public static void main(String[] args) { new utkarsh().run(); }
    void run() {
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte() {
        if(ptr >= len) { ptr = 0;
            try { len = is.read(input); }
            catch(IOException e) { throw new InputMismatchException(); }
            if(len <= 0) { return -1; }
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() {
        int b = readByte();
        while(b != -1 && isSpaceChar(b)) { b = readByte(); }
        return b;
    }

    char nc() { return (char)skip(); }
    String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    String nLine() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    int ni() {
        int n = 0, b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        if(b == -1) { return -1; }  //no input
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }
    long nl() {
        long n = 0L;    int b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) {
        int a[] = new int[n];
        for(int i = 0; i < n; i++) { a[i] = ni(); }
        return a;
    }
    char[] ns(int n) {
        char c[] = new char[n];
        int i, b = skip();
        for(i = 0; i < n; i++) {
            if(isSpaceChar(b)) { break; }
            c[i] = (char)b; b = readByte();
        } return i == n ? c : Arrays.copyOf(c,i);
    }
}


import java.util.*;
import java.io.*;
public class Solution
{
    public static void main(String []ks) throws Exception
    {
       BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        long n=Long.parseLong(bf.readLine());
        long a=2,b=3;
        long res=0;
        for(int i=3;i<=n;i++)
        {
            res+=(a*b);
            a++;
            b++;
        }
        System.out.println(res);
  }
}


import java.util.Scanner;

/**
 * Created by Gantushig on 2/18/2016.
 */

public class A {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        System.out.println("25");
    }

}


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

public class Main{

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

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

        String s = b.readLine().trim();
        String tmp = s.substring(1);
        tmp = tmp.replaceFirst("at", "@");

        s = s.charAt(0) + tmp;

        if( s.length() > 1){

          tmp = s.substring(1, s.length() - 1);

         tmp = tmp.replaceAll("dot", ".");

         s = s.charAt(0) + tmp + s.charAt(s.length() - 1);
        }
        System.out.println(s);

    }
}


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

public class MakeThemEqual implements Closeable {

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

  public void solve() {
    int n = in.ni();
    int[] x = new int[n];
    for (int i = 0; i < n; i++) {
      x[i] = in.ni();
    }
    Arrays.sort(x);
    int d = (x[n - 1] - x[0]) % 2 == 0 ? (x[n - 1] - x[0]) / 2 : (x[n - 1] - x[0]);
    for (int i = 1; i < n - 1; i++) {
      if (!(x[i] == x[0] || x[i] == x[n - 1] || x[i] == x[0] + d || x[i] == x[n - 1] - d)) {
        out.println(-1);
        return;
      }
    }
    out.println(d);
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

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

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

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (MakeThemEqual instance = new MakeThemEqual()) {
      instance.solve();
    }
  }
}


import java.util.*;

public class Solution
{
	public static void main (String[] args)
	{
		int count = 1;
		Scanner inp = new Scanner(System.in);
		String str = inp.next();
		char ch[] = str.toCharArray();
		for(int i=0;i<ch.length-1;i++) {
			char temp=ch[i];
			ch[i]=ch[i+1];
			ch[i+1]=temp;
		}
		while(String.valueOf(ch).equals(str)==false) {
			count=count+1;
		        for(int i=0;i<ch.length-1;i++) {
                        	char temp=ch[i];
                        	ch[i]=ch[i+1];
                        	ch[i+1]=temp;
                	}
		}
		System.out.println(count);
	}
}


/* author : SansakrxRawat
 */

import java.util.Scanner;

public class BeautifulDivisor {
    public static void main(String[] args) {
        int[] arr={1,6,28,120,496,2016,8128,32640};
        Scanner in=new Scanner (System.in);
        int n=in.nextInt();
        int ans=0;
        for (int j : arr) {
            if (n % j == 0 && j > ans) {
                ans = j;

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


import java.util.*;

public class Solution
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int m=n,ans=0,i=1,w=0;
		while(ans-n!=k)
		{
			ans+=i;
			i++;
			n--;
			w++;
		}
		System.out.println(m-w);
	}
}


/*
 * Code Author: Jayesh Udhani
 * Institute  : DA-IICT
 * 3rd year BTech ICT Student
 */

import java.io.*;
import java.util.*;
public class CFEDU15D
{
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		/*------------------------------My Code starts here------------------------------*/
		long d,k,a,b,t;
		d=in.nextLong();
		k=in.nextLong();
		a=in.nextLong();
		b=in.nextLong();
		t=in.nextLong();
		if(d<=k)
		{
			System.out.println(a*d);
		}
		else
		{
			long ans=0;
			boolean z=false;
			ans+=a*k;
			d=d-k;
			long temp=d%k,times=(d-temp)/k;
			if(t+a*k<b*k)
			{
				ans+=times*(a*k+t);
			}
			else
			{
				z=true;
				ans+=times*(b*k);
			}
			if(t+a*temp<b*temp && !z)
			{
				ans+=(a*temp+t);
			}
			else
			{
				ans+=(b*temp);
			}
			System.out.println(ans);
			out.close();
			/*------------------------------The End------------------------------------------*/
		}
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


import java.util.Scanner;

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

        int N = r.nextInt();

        boolean[] v = new boolean[N];
        int p = 0;
        v[p] = true;

        for(int d = 1; d < N; d++){
            p = (p+d)%N;
            v[p] = true;
        }

        boolean yes = true;
        for(int i = 0; i < N; i++)
            if(!v[i])yes = false;

        if(yes)System.out.println("YES");
        else System.out.println("NO");
    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	static ArrayList<Integer> adj[];
	static PrintWriter out = new PrintWriter(System.out);
	public static long mod;

	static int [][]notmemo;
	static int k;
	static int a[];
	static int b[];
	static int m;
	static char c[];

	static class Pair implements Comparable<Pair>{
    	int x;
    	int y;
    	public Pair(int a,int b) {
		x=a;
		y=b;

    	}
		@Override
		public int compareTo(Pair o) {
			if(x!=o.x)
			return x-o.x;
			return y-o.y;
		}

    }
    static Pair s1[];
    static int s[];
	private static HashSet<Integer> set1;
	public static void main(String args[]) throws IOException {
		Scanner sc = new Scanner(System.in);
		 n=sc.nextInt();
	 a=new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i]=sc.nextInt();
		}
		notmemo=new int[n][2];
		for(int x[]:notmemo)
		Arrays.fill(x, -1);
		System.out.println(dp(0,0));
	out.flush();

	}

    static int dp(int idx,int state) {
      if(idx==n) {
    	  return 0;
      }
      if(notmemo[idx][state]!=-1) {
    	  return notmemo[idx][state];
      }
     int take=0; int leave=0;int leaveall=0;
      if(a[idx]==1&&(state==1||state==0)) {
    	take=1+dp(idx+1,1);
      }
      if(a[idx]==0&&state==0) {
    	 leave=1+dp(idx+1,state);
      }
      leaveall=dp(idx+1,state);

      return notmemo[idx][state]=Math.max(take,Math.max(leaveall,leave));
    }
        static void sieve(int N)	// O(N log log N)
	{
		isComposite = new int[N+1];
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();

		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				if(1l * i * i <= N)
					for (int j = i * i; j <= N; j += i)	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;
			}
	}
    static TreeSet<Integer> factors;
    static ArrayList<Integer> primeFactors(int N)		// O(sqrt(N) / ln sqrt(N))
	{
		ArrayList<Integer> factors = new ArrayList<Integer>();		//take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while(1l*p * p <= N)
		{
			while(N % p == 0) { factors.add(p); N /= p; }
			p = primes.get(++idx);
		}

		if(N != 1)						// last prime factor may be > sqrt(N)
			factors.add(N);				// for integers whose largest prime factor has a power of 1
		return factors;
	}

    static String y;
    	static int nomnom[];
	static long fac[];

	static class book implements Comparable<book> {
		int idx;
		long score;

		public book(int i, long s) {
			idx = i;
			score = s;
		}

		public int compareTo(book o) {
			return (int) (o.score - score);
		}
	}

	static class library implements Comparable<library> {
		int numofbooks;
		int signup;
		int shiprate;
		int idx;

		public library(int a, int b, int c, int idx) {
			numofbooks = a;
			signup = b;
			shiprate = c;
			this.idx = idx;
		}

		@Override
		public int compareTo(library o) {
		if(signup==o.signup) {
			  return o.numofbooks-numofbooks;
		}
		return signup - o.signup;

		}
	}

	static boolean isOn(int S, int j) {
		return (S & 1 << j) != 0;
	}

	static boolean f = true;

	static class SegmentTree { // 1-based DS, OOP

		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy;

		SegmentTree(int[] in) {
			array = in;
			N = in.length - 1;
			sTree = new int[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N << 1];
			//build(1, 1, N);
		}

		void build(int node, int b, int e) // O(n)
		{
			if (b == e)
				sTree[node] = array[b];
			else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
			}
		}

		void update_point(int index, int val) // O(log n)
		{
			index += N - 1;
			sTree[index] = val;
			while(index>1)
			{
				index >>= 1;
				sTree[index] = Math.max(sTree[index<<1] ,sTree[index<<1|1]);
			}
		}

		void update_range(int i, int j, int val) // O(log n)
		{
			update_range(1, 1, N, i, j, val);
		}

		void update_range(int node, int b, int e, int i, int j, int val) {
			if (i > e || j < b)
				return;
			if (b >= i && e <= j) {
				sTree[node] += (e - b + 1) * val;
				lazy[node] += val;
			} else {
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node << 1, b, mid, i, j, val);
				update_range(node << 1 | 1, mid + 1, e, i, j, val);
				sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
			}

		}

		void propagate(int node, int b, int mid, int e) {
			lazy[node << 1] += lazy[node];
			lazy[node << 1 | 1] += lazy[node];
			sTree[node << 1] += (mid - b + 1) * lazy[node];
			sTree[node << 1 | 1] += (e - mid) * lazy[node];
			lazy[node] = 0;
		}

		int query(int i, int j) {
			return query(1, 1, N, i, j);
		}

		int query(int node, int b, int e, int i, int j) // O(log n)
		{
			if (i > e || j < b)
				return 0;
			if (b >= i && e <= j)
				return sTree[node];
			int mid = b + e >> 1;
			// propagate(node, b, mid, e);
			int q1 = query(node << 1, b, mid, i, j);
			int q2 = query(node << 1 | 1, mid + 1, e, i, j);
			return Math.max(q1,q2);

		}
	}

	static int memo[];

	static class UnionFind {
		int[] p, rank, setSize;
		int numSets;
		int max[];

		public UnionFind(int N) {
			p = new int[numSets = N];
			rank = new int[N];
			setSize = new int[N];
			for (int i = 0; i < N; i++) {
				p[i] = i;
				setSize[i] = 1;
			}
		}

		public int findSet(int i) {
			return p[i] == i ? i : (p[i] = findSet(p[i]));
		}

		public boolean isSameSet(int i, int j) {
			return findSet(i) == findSet(j);
		}

		public void unionSet(int i, int j) {
			if (isSameSet(i, j))
				return;
			numSets--;
			int x = findSet(i), y = findSet(j);
			if (rank[x] > rank[y]) {
				p[y] = x;
				setSize[x] += setSize[y];

			} else {
				p[x] = y;
				setSize[y] += setSize[x];
				if (rank[x] == rank[y])
					rank[y]++;

			}
		}

		public int numDisjointSets() {
			return numSets;
		}

		public int sizeOfSet(int i) {
			return setSize[findSet(i)];
		}
	}

	/**
	 * private static void trace(int i, int time) { if(i==n) return;
	 *
	 *
	 * long ans=dp(i,time);
	 * if(time+a[i].t<a[i].burn&&(ans==dp(i+1,time+a[i].t)+a[i].cost)) {
	 *
	 * trace(i+1, time+a[i].t);
	 *
	 * l1.add(a[i].idx); return; } trace(i+1,time);
	 *
	 * }
	 **/

	static class incpair implements Comparable<incpair> {
		int a;
		long b;
		int idx;

		incpair(int a, long dirg, int i) {
			this.a = a;
			b = dirg;
			idx = i;
		}

		public int compareTo(incpair e) {
			return (int) (b - e.b);
		}
	}

	static class decpair implements Comparable<decpair> {
		int a;
		long b;
		int idx;

		decpair(int a, long dirg, int i) {
			this.a = a;
			b = dirg;
			idx = i;
		}

		public int compareTo(decpair e) {
			return (int) (e.b - b);
		}
	}

	static long allpowers[];

	static class Quad implements Comparable<Quad> {
		int u;
		int v;
		char state;
		int turns;

		public Quad(int i, int j, char c, int k) {
			u = i;
			v = j;
			state = c;
			turns = k;
		}

		public int compareTo(Quad e) {
			return (int) (turns - e.turns);
		}

	}

	static long dirg[][];
	static Edge[] driver;

	static int n;

	static class Edge implements Comparable<Edge> {
		int node;
		long cost;

		Edge(int a, long dirg) {
			node = a;
			cost = dirg;
		}

		public int compareTo(Edge e) {
			return (int) (cost - e.cost);
		}
	}

	static long manhatandistance(long x, long x2, long y, long y2) {
		return Math.abs(x - x2) + Math.abs(y - y2);
	}

	static long fib[];

	static long fib(int n) {
		if (n == 1 || n == 0) {
			return 1;
		}
		if (fib[n] != -1) {
			return fib[n];
		} else
			return fib[n] = ((fib(n - 2) % mod + fib(n - 1) % mod) % mod);
	}

	static class Point  implements Comparable<Point>{
		long x, y;

		Point(long counth, long counts) {
			x = counth;
			y = counts;
		}

		@Override
		public int compareTo(Point p )
		{
			return Long.compare(p.y*1l*x, p.x*1l*y);
		}

	}

	static long[][] comb;

	static class Triple implements Comparable<Triple> {

		int l;
		int r;
		long cost;
		int idx;

		public Triple(int a, int b, long l1, int l2) {
			l = a;
			r = b;
			cost = l1;
			idx = l2;
		}

		public int compareTo(Triple x) {
			if (l != x.l || idx == x.idx)
				return l - x.l;
			return -idx;
		}

	}

	static TreeSet<Long> primeFactors(long N) // O(sqrt(N) / ln sqrt(N))
	{
		TreeSet<Long> factors = new TreeSet<Long>(); // take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while (p * p <= N) {
			while (N % p == 0) {
				factors.add((long) p);
				N /= p;
			}
			if (primes.size() > idx + 1)
				p = primes.get(++idx);
			else
				break;
		}

		if (N != 1) // last prime factor may be > sqrt(N)
			factors.add(N); // for integers whose largest prime factor has a power of 1
		return factors;
	}

	static boolean visited[];

	/**
	 * static int bfs(int s) { Queue<Integer> q = new LinkedList<Integer>();
	 * q.add(s); int count=0; int maxcost=0; int dist[]=new int[n]; dist[s]=0;
	 * while(!q.isEmpty()) {
	 *
	 * int u = q.remove(); if(dist[u]==k) { break; } for(Pair v: adj[u]) {
	 * maxcost=Math.max(maxcost, v.cost);
	 *
	 *
	 *
	 * if(!visited[v.v]) {
	 *
	 * visited[v.v]=true; q.add(v.v); dist[v.v]=dist[u]+1; maxcost=Math.max(maxcost,
	 * v.cost); } }
	 *
	 * } return maxcost; }
	 **/
	public static boolean FindAllElements(int n, int k) {
		int sum = k;
		int[] A = new int[k];
		Arrays.fill(A, 0, k, 1);

		for (int i = k - 1; i >= 0; --i) {

			while (sum + A[i] <= n) {

				sum += A[i];
				A[i] *= 2;
			}
		}
		if (sum == n) {
			return true;
		} else
			return false;
	}

	static boolean[] vis2;

	static boolean f2 = false;

	static long[][] matMul(long[][] a2, long[][] b, int p, int q, int r) // C(p x r) = A(p x q) x (q x r) -- O(p x q x
																			// r)
	{
		long[][] C = new long[p][r];
		for (int i = 0; i < p; ++i) {
			for (int j = 0; j < r; ++j) {
				for (int k = 0; k < q; ++k) {
					C[i][j] = (C[i][j] + (a2[i][k] % mod * b[k][j] % mod)) % mod;
					C[i][j] %= mod;
				}

			}
		}
		return C;
	}

	static int memo1[];

	static boolean vis[];
	static TreeSet<Integer> set = new TreeSet<Integer>();

	static long modPow(long ways, long count, long mod) // O(log e)
	{
		ways %= mod;
		long res = 1;
		while (count > 0) {
			if ((count & 1) == 1)
				res = (res * ways) % mod;
			ways = (ways * ways) % mod;
			count >>= 1;
		}
		return res % mod;
	}

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

	static int[] isComposite;
	static int[] valid;

	static ArrayList<Integer> primes;
	static ArrayList<Integer> l1;

	static TreeSet<Integer> primus = new TreeSet<Integer>();

	static void sieveLinear(int N)
	{
		int[] lp = new int[N + 1];								//lp[i] = least prime divisor of i
		for(int i = 2; i <= N; ++i)
		{
			if(lp[i] == 0)
			{
				primus.add(i);
				lp[i] = i;
			}
			int curLP = lp[i];
			for(int p: primus)
				if(p > curLP || p * i > N)
					break;
				else
					lp[p * i] = i;
		}
	}

	public static int[] schuffle(int[] p) {
		for (int i = 0; i < p.length; i++) {
			int x = (int) (Math.random() * p.length);
			int temp = p[x];
			p[x] = p[i];
			p[i] = temp;
		}
		return p;
	}

	static int V;
	static long INF = (long) 1E16;

	static class Edge2 {
		int node;
		long cost;
		long next;

		Edge2(int a, int c, Long long1) {
			node = a;
			cost = long1;
			next = c;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

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

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

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

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}

		public int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}
	}
}


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

// SHIVAM GUPTA :
//NSIT
//decoder_1671

// STOP NOT TILL IT IS DONE OR U DIE .

// U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................

// ASCII = 48 + i ;// 2^28 = 268,435,456  > 2* 10^8 // log 10 base 2 = 3.3219

// odd:: (x^2+1)/2 , (x^2-1)/2 ; x>=3// even:: (x^2/4)+1 ,(x^2/4)-1  x >=4

// FOR ANY ODD NO N : N,N-1,N-2
//ALL ARE PAIRWISE COPRIME
//THEIR COMBINED LCM IS PRODUCT OF ALL THESE NOS

// two consecutive odds are always coprime to each other
// two consecutive even have always gcd  = 2 ;

public class Main
{
     // static int[] arr = new int[100002] ; // static int[] dp = new int[100002] ;

     static PrintWriter out;

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

////////////////////////////////////////////////////////////////////////////////////
 public static int countDigit(long n)
    {
        return (int)Math.floor(Math.log10(n) + 1);
    }

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

 public static int sumOfDigits(long n)
 {

  if( n< 0)return -1 ;

  int sum = 0;

  while( n > 0)
  {
      sum = sum + (int)( n %10) ;

      n /= 10 ;
  }

  return sum ;

 }

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

public static long arraySum(int[] arr , int start , int end)
{
    long ans = 0 ;

    for(int i = start ; i <= end  ; i++)ans += arr[i] ;

    return ans  ;
}

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

public static int mod(int x)
{
      if(x <0)return -1*x ;
      else return x ;
}
public static long mod(long x)
{
      if(x <0)return -1*x ;
      else return x ;
}

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

public static void swapArray(int[] arr , int start , int end)
{
    while(start < end)
    {
        int temp = arr[start] ;
        arr[start] = arr[end];
        arr[end] = temp;
        start++ ;end-- ;
    }
}

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

public static int[][] rotate(int[][] input){

int n =input.length;
int m = input[0].length ;
int[][] output = new int [m][n];

for (int i=0; i<n; i++)
	for (int j=0;j<m; j++)
		output [j][n-1-i] = input[i][j];
return output;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////

public static int countBits(long n)
    {
        int count = 0;
        while (n != 0)
        {
            count++;
            n = (n) >> (1L) ;
        }

        return count;

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

public static boolean isPowerOfTwo(long n)
{
    if(n==0)
    return false;

if(((n ) & (n-1)) == 0 ) return true ;
else return false  ;

}

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

public static int  min(int a ,int b , int c, int d)
{
     int[] arr = new int[4] ;
      arr[0] = a;arr[1] = b ;arr[2] = c;arr[3] = d;Arrays.sort(arr) ;

      return arr[0];
}
 /////////////////////////////////////////////////////////////////////////////
public static int  max(int a ,int b , int c, int d)
{
     int[] arr = new int[4] ;
      arr[0] = a;arr[1] = b ;arr[2] = c;arr[3] = d;Arrays.sort(arr) ;

      return arr[3];
}

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

public static String reverse(String input)
{
  StringBuilder str  = new StringBuilder("") ;

    for(int i =input.length()-1 ; i >= 0  ; i-- )
    {
        str.append(input.charAt(i));
    }

return str.toString() ;
}
///////////////////////////////////////////////////////////////////////////////////////////

public static boolean sameParity(long a  ,long b )
{
     long x = a% 2L; long y = b%2L ;
     if(x==y)return true  ;
     else return false  ;
}

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

////////////////////////////////////////////////////////////////////////////////////////////
static long xnor(long num1, long num2) {
		if (num1 < num2) {
			long temp = num1;
			num1 = num2;
			num2 = temp;
		}
		num1 = togglebit(num1);
		return num1 ^ num2;
	}

	static long togglebit(long n) {
		if (n == 0)
			return 1;
		long i = n;
		n |= n >> 1;
		n |= n >> 2;
		n |= n >> 4;
		n |= n >> 8;
		n |= n >> 16;
		return i ^ n;
	}

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

public static int xorOfFirstN(int n)
{

 if( n % 4 ==0)return n ;

 else if( n % 4 == 1)return 1 ;

 else if( n % 4 == 2)return n+1 ;

 else return 0 ;

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

public static int gcd(int a, int b )
{

if(b==0)return a ;

else return gcd(b,a%b) ;

}

public static long gcd(long a, long b )
{

if(b==0)return a ;

else return gcd(b,a%b) ;

}

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

public static int lcm(int a, int b ,int c , int d )
{

int temp = lcm(a,b , c) ;

 int ans = lcm(temp ,d ) ;

return ans  ;

}

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

public static int lcm(int a, int b ,int c )
{

int temp = lcm(a,b) ;

int ans =  lcm(temp ,c) ;

return ans  ;

}

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

public static int lcm(int a , int b )
{

int gc = gcd(a,b);

return (a*b)/gc ;
}

public static long lcm(long a , long b )
{

long gc = gcd(a,b);

return (a*b)/gc ;
}

///////////////////////////////////////////////////////////////////////////////////////////
static boolean isPrime(long n)
{
      if(n==1)
      {
            return false  ;
      }

      boolean ans =  true  ;

      for(long i = 2L; i*i <= n ;i++)
      {
            if(n% i ==0)
            {
                  ans = false  ;break ;
            }
      }

      return ans  ;
}
///////////////////////////////////////////////////////////////////////////

static int sieve =  1000000 ;

static boolean[] prime =  new boolean[sieve + 1] ;

public static void sieveOfEratosthenes()
    {
        // FALSE == prime

        // TRUE ==  COMPOSITE

        // FALSE== 1

        // time complexity = 0(NlogLogN)== o(N)

        // gives prime nos bw 1 to N

        for(int i = 4; i<= sieve ; i++)
        {
            prime[i] = true  ;
            i++ ;
        }

        for(int p = 3; p*p <= sieve; p++)
        {

            if(prime[p] == false)
            {

                for(int i = p*p; i <= sieve; i += p)
                    prime[i] = true;
            }

            p++ ;
        }

    }

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

public static void sortD(int[] arr , int s  , int e)
{
      sort(arr ,s , e) ;

      int i =s ; int j = e  ;

      while( i < j)
      {
            int temp = arr[i] ;
            arr[i] =arr[j] ;
            arr[j] = temp ;
            i++ ; j-- ;
      }

      return ;
}

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

public static long countSubarraysSumToK(long[] arr ,long sum )
    {
      HashMap<Long,Long> map = new HashMap<>() ;

      int n = arr.length ;

      long prefixsum = 0 ;

      long count = 0L ;
      for(int i  = 0; i < n ; i++)
      {
          prefixsum  = prefixsum +  arr[i] ;

          if(sum == prefixsum)count = count+1 ;

          if(map.containsKey(prefixsum -sum))
          {
              count = count + map.get(prefixsum -sum) ;
          }

          if(map.containsKey(prefixsum ))
          {
              map.put(prefixsum , map.get(prefixsum) +1 );
          }

          else{
              map.put(prefixsum , 1L );
          }

      }

      return count  ;

    }

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

// KMP ALGORITHM : TIME COMPL:O(N+M)
// FINDS THE OCCURENCES OF PATTERN AS A  SUBSTRING IN STRING
//RETURN THE ARRAYLIST OF INDEXES
// IF SIZE OF LIST IS ZERO MEANS PATTERN IS NOT PRESENT IN STRING

public static ArrayList<Integer> kmpAlgorithm(String str , String pat)
     {
        ArrayList<Integer> list =new ArrayList<>();

        int n = str.length() ;
        int m = pat.length() ;

        String q = pat + "#" + str ;

        int[] lps  =new int[n+m+1] ;

         longestPefixSuffix(lps, q,(n+m+1)) ;

         for(int i =m+1 ; i < (n+m+1) ; i++ )
         {
             if(lps[i] == m)
             {
                 list.add(i-2*m) ;
             }
         }

        return list ;

    }

public static void longestPefixSuffix(int[] lps ,String str , int n)
    {
        lps[0] =  0 ;

        for(int i = 1  ; i<= n-1; i++)
        {
          int l = lps[i-1] ;

          while( l > 0 && str.charAt(i) != str.charAt(l))
          {
              l = lps[l-1] ;
          }

          if(str.charAt(i) == str.charAt(l))
          {
              l++ ;
          }

          lps[i] = l ;
        }

    }

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

 // CALCULATE TOTIENT Fn FOR ALL VALUES FROM 1 TO n
    // TOTIENT(N) = count of nos less than n and grater than 1 whose gcd with n is 1
    // or n and the no  will be coprime in nature
    //time : O(n*(log(logn)))

    public static void eulerTotientFunction(int[] arr ,int n )
    {

      for(int i = 1; i <= n  ;i++)arr[i] =i  ;

      for(int i= 2 ; i<= n ;i++)
      {
          if(arr[i] == i)
          {
              arr[i] =i-1 ;

              for(int j =2*i ; j<= n  ; j+= i )
              {
                  arr[j] = (arr[j]*(i-1))/i ;
              }

          }
      }

      return  ;

    }

/////////////////////////////////////////////////////////////////////////////////////////////
public static long nCr(int n,int k)
{
    long ans=1L;
    k=k>n-k?n-k:k;
    int j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}

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

public static ArrayList<Integer> allFactors(int n)
{
      ArrayList<Integer> list = new ArrayList<>() ;

    for(int i = 1; i*i <= n ;i++)
    {
          if( n % i == 0)
          {
              if(i*i == n)
              {
                    list.add(i) ;
              }
              else{
                    list.add(i) ;
                    list.add(n/i) ;

              }
          }
    }

     return list ;

}

public static ArrayList<Long> allFactors(long n)
{
      ArrayList<Long> list = new ArrayList<>() ;

    for(long i = 1L; i*i <= n ;i++)
    {
          if( n % i == 0)
          {
              if(i*i == n)
              {
                    list.add(i) ;
              }
              else{
                    list.add(i) ;
                    list.add(n/i) ;

              }
          }
    }

     return list ;

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

  static final int MAXN = 10000001;

    static int spf[] = new int[MAXN];

    static void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)

            spf[i] = i;

        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {

            if (spf[i] == i)
            {

                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }

// The above code works well for n upto the order of 10^7.
// Beyond this we will face memory issues.

// Time Complexity: The precomputation for smallest prime factor is done in O(n log log n)
// using sieve.
// Where as in the calculation step we are dividing the number every time by
// the smallest prime number till it becomes 1.
// So, let’s consider a worst case in which every time the SPF is 2 .
// Therefore will have log n division steps.

// Hence, We can say that our Time Complexity will be O(log n) in worst case.

    static Vector<Integer> getFactorization(int x)
    {
        Vector<Integer> ret = new Vector<>();
        while (x != 1)
        {
            ret.add(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }

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

public static void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int[n1];
        int R[] = new int[n2];

      //Copy data to temp arrays
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
  public static void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

public static void sort(long arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

public static void merge(long arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long[n1];
        long R[] = new long[n2];

        //Copy data to temp arrays
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

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

	public static long knapsack(int[] weight,long value[],int maxWeight){

        int n=  value.length ;

	//dp[i] stores the profit with KnapSack capacity "i"
  long []dp = new long[maxWeight+1];

    //initially profit with 0 to W KnapSack capacity is 0
    Arrays.fill(dp, 0);

    // iterate through all items
    for(int i=0; i < n; i++)

        //traverse dp array from right to left
        for(int j = maxWeight; j >= weight[i]; j--)
            dp[j] = Math.max(dp[j] , value[i] + dp[j - weight[i]]);

    /*above line finds out maximum of dp[j](excluding ith element value)
    and val[i] + dp[j-wt[i]] (including ith element value and the
    profit with "KnapSack capacity - ith element weight") */
    return dp[maxWeight];
	}

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

// to return max sum of any subarray in given array
public static long kadanesAlgorithm(long[] arr)
{
      long[] dp = new long[arr.length] ;

      dp[0] = arr[0] ;
      long max =  dp[0] ;

      for(int i = 1; i <  arr.length ; i++)
      {
            if(dp[i-1] > 0)
            {
                  dp[i] = dp[i-1] + arr[i] ;
            }
            else{
                  dp[i] = arr[i] ;
            }

            if(dp[i] >  max)max = dp[i] ;

      }

      return max  ;

}
/////////////////////////////////////////////////////////////////////////////////////////////
public static long kadanesAlgorithm(int[] arr)
{
      long[] dp = new long[arr.length] ;

      dp[0] = arr[0] ;
      long max =  dp[0] ;

      for(int i = 1; i <  arr.length ; i++)
      {
            if(dp[i-1] > 0)
            {
                  dp[i] = dp[i-1] + arr[i] ;
            }
            else{
                  dp[i] = arr[i] ;
            }

            if(dp[i] >  max)max = dp[i] ;

      }

      return max  ;

}

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

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

public static long binarySerachGreater(int[] arr , int start , int end , int val)
{

      // fing total no of elements strictly grater than val in sorted array arr

      if(start >  end)return  0 ; //Base case

      int mid = (start + end)/2  ;

      if(arr[mid] <=val)
      {
          return binarySerachGreater(arr,mid+1, end ,val) ;

      }
      else{

         return binarySerachGreater(arr,start , mid -1,val) + end-mid+1 ;

      }

}

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

//TO GENERATE ALL(DUPLICATE ALSO EXIST) PERMUTATIONS OF A STRING

// JUST CALL generatePermutation( str,  start,  end) start :inclusive ,end : exclusive

//Function for swapping the characters at position I with character at position j
    public static String swapString(String a, int i, int j) {
        char[] b =a.toCharArray();
        char ch;
        ch = b[i];
        b[i] = b[j];
        b[j] = ch;
        return String.valueOf(b);
    }

//Function for generating different permutations of the string
    public static void generatePermutation(String str, int start, int end)
    {
        //Prints the permutations
        if (start == end-1)
            System.out.println(str);
        else
        {
            for (int i = start; i < end; i++)
            {
                //Swapping the string by fixing a character
                str = swapString(str,start,i);
                //Recursively calling function generatePermutation() for rest of the characters
                generatePermutation(str,start+1,end);
                //Backtracking and swapping the characters again.
                str = swapString(str,start,i);
            }
        }
    }

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

public static long factMod(long n, long mod) {
    if (n <= 1) return 1;
    long ans = 1;
    for (int i = 1; i <= n; i++) {
      ans = (ans * i) % mod;
    }
    return ans;
  }

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

public static long power(long x  ,long n)
    {
        //time comp : o(logn)

        if(n==0)return 1L ;
        if(n==1)return x;

        long ans =1L  ;

      while(n>0)
      {
          if(n % 2 ==1)
          {
              ans = ans *x ;
          }

          n /= 2 ;

          x =  x*x ;

      }

      return ans ;
    }

////////////////////////////////////////////////////////////////////////////////////////////////////
public static long powerMod(long x, long n, long mod) {
    //time comp : o(logn)

    if(n==0)return 1L ;
        if(n==1)return x;

    long ans = 1;
    while (n > 0) {
      if (n % 2 == 1) ans = (ans * x) % mod;
      x = (x * x) % mod;
      n /= 2;
    }
    return ans;
  }

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

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

/*
lowerBound - finds largest element equal or less than value paased
upperBound - finds smallest element equal or more than value passed

if not present return -1;

*/

public static long lowerBound(long[] arr,long k)
	{
		long ans=-1;

		int start=0;
		int end=arr.length-1;

		while(start<=end)
		{
			int mid=(start+end)/2;

			if(arr[mid]<=k)
			{
				ans=arr[mid];
				start=mid+1;
			}
			else
			{
				end=mid-1;
			}

		}

		return ans;

	}

	public static int lowerBound(int[] arr,int k)
	{
		int ans=-1;

		int start=0;
		int end=arr.length-1;

		while(start<=end)
		{
			int mid=(start+end)/2;

			if(arr[mid]<=k)
			{
				ans=arr[mid];
				start=mid+1;
			}
			else
			{
				end=mid-1;
			}

		}

		return ans;

	}

	public static long upperBound(long[] arr,long k)
	{
		long ans=-1;

		int start=0;
		int end=arr.length-1;

		while(start<=end)
		{
			int mid=(start+end)/2;

			if(arr[mid]>=k)
			{
				ans=arr[mid];
				end=mid-1;
			}
			else
			{
				start=mid+1;
			}

		}

		return ans;
	}

	public static int upperBound(int[] arr,int k)
	{
		int ans=-1;

		int start=0;
		int end=arr.length-1;

		while(start<=end)
		{
			int mid=(start+end)/2;

			if(arr[mid]>=k)
			{
				ans=arr[mid];
				end=mid-1;
			}
			else
			{
				start=mid+1;
			}

		}

		return ans;
	}

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

public static void printArray(int[] arr , int si ,int ei)
{
    for(int i = si  ; i  <= ei ; i++)
    {
        out.print(arr[i] +" ") ;
    }

}

public static void printArrayln(int[] arr , int si ,int ei)
{
    for(int i = si  ; i  <= ei ; i++)
    {
        out.print(arr[i] +" ") ;
    }
    out.println() ;
}

public static void printLArray(long[] arr , int si , int ei)
{
    for(int i = si ; i  <= ei ; i++)
    {
        out.print(arr[i] +" ") ;
    }

}

public static void printLArrayln(long[] arr , int si , int ei)
{
    for(int i = si ; i  <= ei ; i++)
    {
        out.print(arr[i] +" ") ;
    }
    out.println() ;

}

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

}

  static long modPow(long a, long x, long p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

  static long modInverse(long a, long p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}

static long modBinomial(long n, long k, long p) {
// calculates C(n,k) mod p (assuming p is prime).

    long numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    long denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

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

 static ArrayList<Integer>[] tree ;
// static long[] child;
// static int mod= 1000000007 ;
// static int[][] pre  = new int[3001][3001];
// static int[][] suf = new int[3001][3001] ;

//program to calculate noof nodes in subtree for every vertex including itself

 public static void countNoOfNodesInsubtree(int child ,int par , int[] dp)
 {
     int count = 1 ;

     for(int x : tree[child])
     {

         if(x== par)continue  ;

         countNoOfNodesInsubtree(x,child,dp) ;

         count= count +  dp[x]   ;
     }

     dp[child] = count ;

 }

public static void depth(int child ,int par , int[] dp , int d )
 {
    dp[child] =d ;

     for(int x : tree[child])
     {

         if(x== par)continue  ;

         depth(x,child,dp,d+1) ;

     }

 }

public static void dfs(int sv , boolean[] vis)
{
    vis[sv] = true  ;

    for(int x : tree[sv])
    {
        if( !vis[x])
        {
            dfs(x ,vis) ;
        }
    }

}

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

public static void solve()
{
FastReader scn = new FastReader() ;

//Scanner scn = new Scanner(System.in);
//int[] store = {2 ,3, 5 , 7  ,11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 } ;

// product of first 11 prime nos is greater than 10 ^ 12;

//ArrayList<Integer> arr[] = new ArrayList[n] ;
ArrayList<Integer> list = new ArrayList<>() ;
ArrayList<Long> listl = new ArrayList<>() ;
ArrayList<Integer> lista = new ArrayList<>() ;
ArrayList<Integer> listb = new ArrayList<>() ;
//ArrayList<String> lists = new ArrayList<>() ;

HashMap<Integer,Integer> map = new HashMap<>() ;
//HashMap<Long,Long> map = new HashMap<>() ;
HashMap<Integer,Integer> map1  = new HashMap<>() ;
HashMap<Integer,Integer> map2  = new HashMap<>() ;
//HashMap<String,Integer> maps = new HashMap<>() ;
//HashMap<Integer,Boolean> mapb = new HashMap<>() ;
//HashMap<Point,Integer> point = new HashMap<>() ;

 Set<Integer> set = new HashSet<>() ;
 Set<Integer> setx = new HashSet<>() ;
 Set<Integer> sety = new HashSet<>() ;

StringBuilder sb =new StringBuilder("") ;

//Collections.sort(list);

//if(map.containsKey(arr[i]))map.put(arr[i] , map.get(arr[i]) +1 ) ;
//else map.put(arr[i],1) ;

// if(map.containsKey(temp))map.put(temp , map.get(temp) +1 ) ;
// else map.put(temp,1) ;

//int bit  =Integer.bitCount(n);
// gives total no of set bits in n;

// Arrays.sort(arr, new Comparator<Pair>() {
// 			@Override
// 			public int compare(Pair a, Pair b) {
// 				if (a.first != b.first) {
// 					return a.first - b.first; // for increasing order of first
// 				}
// 				return a.second - b.second ; //if first is same then sort on second basis
// 			}
// 		});

int testcases = 1;
 //testcases = scn.nextInt() ;
for(int testcase =1  ; testcase <= testcases ;testcase++)
{

 //if(map.containsKey(arr[i]))map.put(arr[i],map.get(arr[i])+1) ;else map.put(arr[i],1) ;
 //if(map.containsKey(temp))map.put(temp,map.get(temp)+1) ;else map.put(temp,1) ;

//  int n = scn.nextInt() ;int m = scn.nextInt() ;
// tree = new ArrayList[n] ;
// for(int i = 0; i< n; i++)
// {
//     tree[i] = new ArrayList<Integer>();
// }

//  for(int i = 0 ;  i <= m-1 ; i++)
// {
//     int fv = scn.nextInt()-1 ; int sv = scn.nextInt()-1 ;
//     tree[fv].add(sv) ;
//     tree[sv].add(fv) ;
// }
// boolean[] visited = new boolean[n] ;
// int ans = 0 ;
// for(int i = 0 ; i < n ; i++)
// {
//     if(!visited[i])
//     {
//         dfs(i , visited ) ;
//         ans++ ;
//     }
// }

long n = scn.nextLong() ;

long a1 = scn.nextLong() ;long a2 = scn.nextLong() ;long a3 = scn.nextLong() ;
long b1 = scn.nextLong() ;long b2 = scn.nextLong() ;long b3 = scn.nextLong() ;

long min = 0L ;

if(b1 >= a1+a2)
{
    min = a3-b2-b3 ;
}

else if(b2 >= a3+a2)
{
    min = a1-b1-b3 ;
}

else if(b3 >= a1+a3)
{
    min =a2-b2-b1 ;
}

else{
    min = 0 ;
}

long max = Math.min(a1,b2) + Math.min(a2,b3) +Math.min(a3,b1) ;

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

sb.delete(0 , sb.length()) ;
list.clear() ;listb.clear() ;
map.clear() ;
map1.clear() ;
map2.clear() ;
set.clear() ;sety.clear() ;

} // test case  end loop

out.flush() ;
} // solve fn ends

public static void main (String[] args) throws java.lang.Exception
{

solve() ;

}

}

 class Pair
{
  int first ;

  int second  ;

@Override
	public String toString() {

	String ans = "" ;
	ans  += this.first ;
	ans += " ";
	ans += this.second ;

	return ans  ;
	}

}


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

public class stock
{

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

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

        int[] by = new int[n];
        int[] sell = new int[m];

        for (int i = 0; i < by.length; i++)
        {
            by[i] = in.nextInt();
        }
        for (int i = 0; i < sell.length; i++)
        {
            sell[i] = in.nextInt();
        }
        Arrays.sort(by);
        Arrays.sort(sell);

        if (by[0] < sell[sell.length-1])
        {
            int bought = 0;
            while ((r - by[0]) >= 0)
            {
                r -= by[0];
                bought++;
            }
            while (bought > 0)
            {
                r += sell[sell.length-1];
                bought--;
            }
        }
        System.out.println(r);
    }

}


import java.util.Scanner;

public class Lottery {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int count = 0;
        int n=sc.nextInt();
        while (n > 0) {
            if (n % 100 == 0) {
                n = n - 100;
                count++;
                continue;
            }
            if (n % 20 == 0) {
                n = n - 20;
                count++;
                continue;
            }
            if (n % 10 == 0) {
                n = n - 10;
                count++;
                continue;
            }
            if (n % 5 == 0) {
                n = n - 5;
                count++;
                continue;
            }
            if(n%1==0){
                n=n-1;
                count++;
                continue;
            }
        }

        System.out.println(count);

    }
}


import java.util.*;

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

    TaskB() {
    }

    public void solve() {
        Scanner in = new Scanner(System.in);
        Long[] x = new Long[3];
        for (int i = 0; i < 3; ++i) x[i] = in.nextLong();
        long ans = x[0] / 3 + x[1] / 3 + x[2] / 3 +
                Math.min(x[0] % 3, Math.min(x[1] % 3, x[2] % 3));
        Arrays.sort(x, new Comparator<Long>() {
            @Override
            public int compare(Long o1, Long o2) {
                return o1 % 3 < o2 % 3 ? -1 : 1;
            }
        });
        if (x[0] / 3 >= 1 && x[0] % 3 == 0 && x[1] % 3 == 2 && x[2] % 3 == 2) {
            ans += 1;
        }
        System.out.println(ans);
    }
}


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

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

	 public static void solve(InputReader in, PrintWriter out)
	 {
		 long n = in.nextInt();
		 long k = in.nextInt();
		 out.println(magic(n, k));

	 }

	 private static long magic(long n, long k) {
		if(k==1)
		{
			return 1;
		}
		if(k>n)
		{
			return 0;
		}
		if(k==2)
		{
			return 1 + n*(n-1)/2;
		}
		if(k==3)
		{
			return 1 + n*(n-1)/2 + n*(n-1)*(n-2)/3;
		}
		if(k==4)
		{
			return 1 + n*(n-1)/2 + n*(n-1)*(n-2)/3 + n*(n-1)*(n-2)*(n-3)/24*9;
		}
		return 0;

	}

	static class InputReader {
	        public BufferedReader reader;
	        public StringTokenizer tokenizer;

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

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

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

	    }
}


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

public class CF {

	int MAX = 110;
	boolean[][] f = new boolean[MAX * 2][MAX * 2];
	String move = "UDLR";
	int[] dx = { 0, 0, -1, 1 };
	int[] dy = { 1, -1, 0, 0 };

	void realSolve() {
		String s = in.next();
		int x = MAX, y = MAX;
		f[x][y] = true;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			int id = move.indexOf(c);
			x += dx[id];
			y += dy[id];
			f[x][y] = true;
		}
		int[][] len = new int[MAX * 2][MAX * 2];
		for (int i = 0; i < len.length; i++)
			Arrays.fill(len[i], Integer.MAX_VALUE / 2);
		len[MAX][MAX] = 0;
		int it = 0;
		ArrayList<Integer> qx = new ArrayList<>();
		ArrayList<Integer> qy = new ArrayList<>();
		qx.add(MAX);
		qy.add(MAX);
		while (it < qx.size()) {
			int cx = qx.get(it);
			int cy = qy.get(it++);
			for (int i = 0; i < 4; i++) {
				int nx = cx + dx[i];
				int ny = cy + dy[i];
				if (f[nx][ny] && len[nx][ny] == Integer.MAX_VALUE / 2) {
					qx.add(nx);
					qy.add(ny);
					len[nx][ny] = len[cx][cy] + 1;
				}
			}
		}
		out.println(len[x][y] == s.length() ? "OK" : "BUG");
	}

	private class InputReader {
		StringTokenizer st;
		BufferedReader br;

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

		public InputReader(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

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

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

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

		boolean hasMoreElements() {
			while (st == null || !st.hasMoreElements()) {
				String s;
				try {
					s = br.readLine();
				} catch (IOException e) {
					return false;
				}
				st = new StringTokenizer(s);
			}
			return st.hasMoreElements();
		}

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

	InputReader in;
	PrintWriter out;

	void solve() {
		in = new InputReader(new File("object.in"));
		try {
			out = new PrintWriter(new File("object.out"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		realSolve();

		out.close();
	}

	void solveIO() {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);

		realSolve();

		out.close();

	}

	public static void main(String[] args) {
		new CF().solveIO();
	}
}


import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int plate = in.nextInt();
			int table = in.nextInt();
			int pRad = in.nextInt();

			if(plate==1)
			{
				if(table>=pRad)
					System.out.println("YES");
				else
					System.out.println("NO");
			}
			else
			{
				double theta1 = Math.toRadians(180.0/plate);

				double ans = pRad/Math.sin(theta1) + pRad;
				//System.out.println("TEST: " + ans);
				if(table>ans || Math.abs(ans-table)<0.0000001)
					System.out.println("YES");
				else
					System.out.println("NO");
			}
		}
	}
}