//package codeforces.practice.div2c;

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

public class CF1105C {
    private static int UNVISITED = 0;
    private static int VISITING = -1;
    private static int VISITED = 1;

    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));

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

            solve(1, in, out);

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

    private static void solve(int q, FastScanner in, PrintWriter out) {
        for (int qq = 0; qq < q; qq++) {
            int n = in.nextInt(), l = in.nextInt(), r = in.nextInt();
            int mod = (int)1e9 + 7;
            long[] cnt = new long[3];
            while(l % 3 != 0 && l <= r) {
                cnt[l % 3]++;
                l++;
            }
            while(r % 3 != 2 && l <= r) {
                cnt[r % 3]++;
                r--;
            }
            for(int i = 0; i < 3; i++) {
                cnt[i] += (r - l + 1) / 3;
            }

            long[][] dp = new long[n + 1][3];   //dp[i][j]: the number of ways to get an array of length i whose sum is j after % 3
            //dp[i][0] = number of ways to pick 0 * dp[i - 1][0] + number of ways to pick 1 * dp[i - 1][2] + numbers of ways to
            //pick 2 * dp[i - 1][1]

            dp[1][0] = cnt[0];
            dp[1][1] = cnt[1];
            dp[1][2] = cnt[2];

            for(int i = 2; i <= n; i++) {
                dp[i][0] = (dp[i - 1][0] * cnt[0] + dp[i - 1][1] * cnt[2] + dp[i - 1][2] * cnt[1]) % mod;
                dp[i][1] = (dp[i - 1][0] * cnt[1] + dp[i - 1][1] * cnt[0] + dp[i - 1][2] * cnt[2]) % mod;
                dp[i][2] = (dp[i - 1][0] * cnt[2] + dp[i - 1][1] * cnt[1] + dp[i - 1][2] * cnt[0]) % mod;
            }

            out.println(dp[n][0]);
        }
        out.close();
    }

    private static long modularAdd(long a, long b, int mod) {
        long sum = a + b;
        if (sum >= mod) {
            sum -= mod;
        }
        return sum;
    }

    private static long modularSubtract(long a, long b, int mod) {
        long diff = a - b;
        if (diff < 0) {
            diff += mod;
        }
        return diff;
    }

    private static Stack<Integer> topologicalSort(Set<Integer>[] g) {
        Stack<Integer> stack = new Stack<>();
        int[] state = new int[g.length];

        for (int node = 0; node < g.length; node++) {
            if (!topoSortHelper(g, stack, state, node)) {
                return null;
            }
        }
        return stack;
    }

    private static boolean topoSortHelper(Set<Integer>[] g, Stack<Integer> stack, int[] state, int currNode) {
        if (state[currNode] == VISITED) {
            return true;
        } else if (state[currNode] == VISITING) {
            return false;
        }
        state[currNode] = VISITING;
        for (int neighbor : g[currNode]) {
            if (!topoSortHelper(g, stack, state, neighbor)) {
                return false;
            }
        }
        state[currNode] = VISITED;
        stack.push(currNode);
        return true;
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

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

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

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

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

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


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

public class A {

    //public static PrintWriter pw;
    public static PrintWriter pw = new PrintWriter(System.out);

    public static void solve() throws IOException {
//	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
        FastReader sc = new FastReader();
        int n=sc.I();
        int a[]=new int[n+1];
        int dp[]=new int[n+1];
        int ans=0;
        for(int i=1;i<=n;i++){
            a[i]=sc.I();
            dp[i]=1;
            for(int j=1;j<i;j++){
                if(a[j]<=a[i]) dp[i]=Math.max(dp[i],1+dp[j]);
            }
            ans=Math.max(ans,dp[i]);
        }
        pw.println(ans);

        pw.close();

    }

    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                try {

                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();

    }

    static BufferedReader br;
    static long M = (long) 1e9 + 7;

    static class FastReader {

        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));
            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 I() {
            return Integer.parseInt(next());
        }

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

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

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

        public boolean hasNext() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return false;
                }
                st = new StringTokenizer(s);
            }
            return true;
        }

    }
}


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

public class Main {

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

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws IOException {

        int t = 1;
        while (t > 0) {
            solve();
            //out.println();
            t--;
        }

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

    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.000000001;

    int n;
    int m;

    //ArrayList<Integer>[] g = new ArrayList[200010];

    void solve() throws IOException {

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

        Pair[] cands = new Pair[n];
        for (int i = 0; i < n; i++)
            cands[i] = new Pair(0, i);
        for (int i = 0; i < a; i++) {
            int x = in.nextInt()-1;
            cands[x].a++;
            cands[x].t = i;
        }

        Arrays.sort(cands);
        int[] pos = new int[n];
        for (int i = 0; i < n; i++)
            pos[cands[i].b] = i;

        int[] same = new int[n];
        int[] sum = new int[n];
        sum[0] = cands[0].a;
        for (int i = 1; i < n; i++) {
            if (cands[i].a == cands[i - 1].a) {
                same[i] = same[i - 1] + 1;
            }
            sum[i] += sum[i-1] + cands[i].a;
        }

        m -= a;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int p = pos[i];
            boolean ok = false;
            int x = k - (n-p) + 1;
            if (p >= n - k && !(cands[p].a == 0 && n > 1)) {
                if (p - x < 0) {
                    if (m > 0 || cands[p].a > 0) {
                        ok = true;
                        ans[i] = 1;
                    }
                }
                else {
                    int r = p - 1;
                    int l = p - x;
                    int need = x * (cands[p].a + 1);
                    need -= sum[r];
                    if (l > 0)
                        need += sum[l-1];

                    //System.err.println(need+" "+i);

                    if (need > m) {
                        ok = true;
                        ans[i] = 1;
                    }
                }
            }

            if (!ok) {

                int v = cands[n-k].a;
                if (cands[p].a + m > v) {
                    ans[i] = 2;
                }
                else {
                    ans[i] = 3;
                }
            }
        }

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

    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;
        int t = 0;
        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a) return 1;
            if (a < p.a) return -1;
            if (t > p.t) return -1;
            if (t < p.t) return 1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

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

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

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }

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

    }

}


import java.util.Scanner;

public class Pipeline {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		Long n = sc.nextLong(), k = sc.nextLong();
		sc.close();

		k--;
		n--;

		Long limit = (k * (k + 1)) / 2 ;

		if (n > limit) {
			System.out.println(-1);

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

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

		} else {

			Long count = 0L;
			Long end = k;

			Long sk = BS(end,n); //findMaxRange(n,end);

			count += end - sk + 1 ;

			Long cur = ( end * (end+1) / 2 ) -  ( sk * (sk-1) / 2 ) ;

			n = n - cur ;

			if ( n != 0 ) {
				count++;
			}

			System.out.println(count);
		}

		// erke

	}

	public static Boolean valid(Long mid,Long e,Long n){

		Long cur = ( e * (e+1) / 2 ) -  ( mid * (mid-1) / 2 ) ;

		if (cur <= n )
			return true;
		return false;
	}

	public static Long BS(Long x, Long n){
		Long s=1L,e=x,m=0L;
		while(s<e){
			m=(s+e+1)/2-1;
			if(!valid(m,x,n))
				s=m+1;
			else
				e=m;
		}
		return s;
	}

}


import java.util.Scanner;
public class Hexagons
{
public static void main(String []args)
{
Scanner s = new Scanner(System.in);
int a = s.nextInt();
int b = s.nextInt();
int c  = s.nextInt();
System.out.println(a * b + b * c + c * a - a - b  - c + 1);
}
}


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

		/*
		 *
		 * daiict
		 *
		 *
		 *
		 */

		public class Main {
			FastScanner in;
			PrintWriter out;

			static ArrayList[] adj;

			static int n;
			static int m;
			static int visited[][];
			static int[][] arr;
			static int[][] brr;
			static int[][] ans;
			static int array[];
			static int pref[];
			static int sum = 0;
		//for dfs do not delete
			static int dir[][] ={{1,0},{0,1},{0,-1}};

			static long an = 0;
			static long bn = 0;
			static int p = 0;
			static int ta = -1;
			static int tb = -1;
			static Stack<Integer> st;
			static int k;
			static long mod = (long)1e9 + 7;
			static long[] seg;

			static class Pair implements Comparable<Pair>
		    {
				int x;
				boolean y;
				String s = "";
				String val;
		        Pair(int l, boolean b, String p,String q) {

		        	this.x = l;
		            this.y = b;
		           this.s = p;
		           this.val = q;
		        }
		        @Override
		        public int compareTo(Pair p) {

		        	String arr[] = val.split(" ");
		        	String brr[] = p.val.split(" ");

		        	if(s.equals("numeric")){
		        		int aa = Integer.parseInt(arr[x]);
						int bb = Integer.parseInt(brr[x]);

						if(aa>bb && this.y){
							return 1;
						}else if(this.y){
							return -1;
						}else if(aa >= bb && ! this.y){
							return -1;
						}else{
							return 1;
						}
		        	}else{
		        		if(this.y){
		        			return arr[x].compareTo(brr[x]);
		        		}else{
		        			return brr[x].compareTo(arr[x]);
		        		}
		        	}

		        }

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

		        public boolean equals(Object o){
		        	if(o instanceof Pair){
		        		Pair a = (Pair)o;

		        		return this.x == a.x;
		        	}

		        	return false;
		        }

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

		    }

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

			void build(int n) {  // build the tree
				  for (int i = n - 1; i > 0; --i) seg[i] = Math.min(seg[i<<1],seg[i<<1|1]);
				}

			public static void modify(int p, long val,int n) {  // set value at position p
				  for (seg[p += n] = val; p > 1; p >>= 1) seg[p>>1] = Math.min(seg[p],seg[p^1]);
				}

				long query(int l, int r,int n) {  // sum on interval [l, r)
				  long res = Long.MAX_VALUE;
				  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
				    if ((l&1) == 1) res = (long) Math.min(res,seg[l++]);
				    if ((r&1) == 1) res = (long)Math.min(res,seg[--r]);
				  }
				  return res;
				}

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

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

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

				    return C[n][k];
				    }

		    void solve() throws NumberFormatException, IOException {

		    	Scanner in = new Scanner(System.in);

		    	//HashSet<Long> set = new HashSet();
		    	long a = in.nextLong();
		    	long b = in.nextLong();
		    	long c = in.nextLong();
		    	long k = 0;

		    	while(k<=1000000){
		    		a *=10;
		    		k++;

		    		if(a/b == c){
		    			out.println(k);
		    			return;
		    		}
		    		a%=b;
		    	}

		    	out.println(-1);
		    }

		    public static void dfs(int i,int j,int d){

		    	System.out.println(i + " " + j + " " +d);

		    	if(d <= ans[i][j]){
		    		return;
		    	}

		    	if(i == n-1 && j == m-1){
		    		p = Math.max(p,d);
		    		ans[i][j] = p;
		    		arr = brr;
		    		return;
		    	}

		    	ans[i][j] = d;
		    	int temp = arr[i][j];
		    	arr[i][j] = 0;

		    	for(int p= 0;p<3;p++){
		    		int x = i + dir[p][0];
		    		int y = j + dir[p][1];

		    		if(x < 0 || x >=n || y < 0 || y >=m){
		    			continue;
		    		}else{

		    			dfs(x,y,d+arr[x][y]);

		    		}
		    	}
		    	//arr[i][j] = temp;

		    }

		    public static int Floor(int[] dp, int low, int high, long x)
		    {
		        // If low and high cross each other
		        if (low > high)
		            return -1;

		        // If last element is smaller than x
		        if (x >= dp[high])
		            return high;

		        // Find the middle point
		        int mid = (low+high)/2;

		        // If middle point is floor.
		        if (dp[mid] == x)
		            return mid;

		        // If x lies between mid-1 and mid
		        if (mid > 0 && dp[mid-1] <= x && x < dp[mid])
		            return mid-1;

		        // If x is smaller than mid, floor must be in
		        // left half.
		        if (x < dp[mid])
		            return Floor(dp, low, mid-1, x);

		        // If mid-1 is not floor and x is greater than
		        // arr[mid],
		        return Floor(dp, mid+1, high, x);
		    }

		    public static String[] reverse(String arr[]){

		    	for(int i = 0;i<arr.length/2;i++){
		    		String temp = arr[i];
		    		arr[i] = arr[arr.length-i-1];
		    		arr[arr.length-1-i] = temp;
		    	}

		    	return arr;

		    }

		    static long inv(long x , long mod)
			{
				long r,y;
				for(r=1,y=mod-2;y!=0;x=x*x%mod,y>>=1)
				{
					if((y&1)==1)
						r=r*x%mod;

				}
				return r;
			}

		    public static long sum(long x){
		    	return x<10?x:x%10 + sum(x/10);
		    }

			public static long gcd(long x, long y) {
				if (x == 0)
					return y;
				else
					return gcd( y % x,x);
			}

			public static long pow(long x,long y,long n){
				if(y==0)
					return 1%n;
				if(y%2==0){
					long z=pow(x,y/2,n);
					return (z*z)%n;
				}
				return ((x%n)*pow(x,y-1,n))%n;
			}

			public static boolean isPrime(int n) {
				// Corner cases
				if (n <= 1)
					return false;
				if (n <= 3)
					return true;

				// This is checked so that we can skip
				// middle five numbers in below loop
				if (n % 2 == 0 || n % 3 == 0)
					return false;

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

				return true;
			}

			void run() throws NumberFormatException, IOException {
				in = new FastScanner();
				out = new PrintWriter(System.out);

				solve();

				out.close();
			}

			class FastScanner {
				BufferedReader br;
				StringTokenizer st;

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

				String next() {
					while (st == null || !st.hasMoreTokens()) {
						try {
							st = new StringTokenizer(in.br.readLine());
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
					return st.nextToken();
				}

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

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

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

			class Tri{

				Tri[] arr;

				public Tri(){
					arr = new Tri[27];
				}

			}

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

		class Node{
			int a;
			int b;

		}

		class MyComp implements Comparator<String>{

			int c = 0;

			MyComp(int d){
				c = d;
			}

			@Override
			public int compare(String a,String b) {

				// < == -1

				String arr[] = a.split(" ");
				String brr[] = b.split(" ");

				return arr[c].compareTo(brr[c]);

			}

		}

		class MyComp2 implements Comparator<String>{

			int c = 0;

			MyComp2(int d){
				c = d;
			}

			@Override
			public int compare(String a,String b) {

				// < == -1

				String arr[] = a.split(" ");
				String brr[] = b.split(" ");

				int aa = Integer.parseInt(arr[c]);
				int bb = Integer.parseInt(brr[c]);

				if(aa>bb){
					return 1;
				}else{
					return -1;
				}

			}

		}


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

public class A723 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] array = new int[3];
        for (int i = 0; i < array.length; i++)
            array[i] = in.nextInt();
        Arrays.sort(array);
        int length1 = Math.abs(array[1] - array[0]);
        int length2 = Math.abs(array[1] - array[2]);
        System.out.println(length1 + length2);

    }
}


import java.util.Scanner;

public class FirstProg {

    public static void main(String[] args)
    {
        Scanner b = new Scanner(System.in);
        String a=b.nextLine();
        for(int i=0;i<a.length();i++)
        {
            if(a.charAt(i)=='H'|| a.charAt(i)=='Q'|| a.charAt(i)=='9')
            {
                System.out.println("YES") ;break;
            }
            else
                if(i==a.length()-1)
     System.out.println("NO");
    }

    }
}


    import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
    public class main2 {
    	static ArrayList<pair> factors;
    	static boolean isComposite[];
    	static ArrayList<Integer> primes;
    	public static boolean isprime(long n){
    		if(n<=10001){
    			return !isComposite[(int)n];
    		}
    		for(int i=0;i<primes.size();i++){
    			if(primes.get(i)*primes.get(i)*1l>n){
    				break;
    			}
    			if(n%primes.get(i)==0){
    				return false;
    			}

    		}
    		return true;
    	}
    	static int[] res;

    	public static void sieve(int n){
    		isComposite=new boolean[n+1];
    		primes =new ArrayList<Integer>();
    		isComposite[0]=true;
    		isComposite[1]=true;
    		for(int i=2;i<=n;i++){
    			if(!isComposite[i]){
    				for(int j=2*i;j<=n;j=j+i){
    					isComposite[j]=true;
    				}
    			}
    			primes.add(i);
    		}

    	}
    	public static void primefactors(long n){
    		 factors=new ArrayList<pair>();
    		for(int x:primes){
    			if(x*x*1l>n){
    				break;
    			}

    			if(n%x==0){

    					pair p=new pair(x,0);
    					 factors.add(p);
    				while(n%x==0){
    				n/=x;
    				p.y++;}

    			}
    		}
    		if(n!=1){
    			factors.add(new pair((int)n,1));
    		}

    	}
    	public static long powfact(long n,long p){
    		int res=0;
    		for(long i=p;i*1l<=n;i=i*p*1l){
    			res+=(n/i);
    		}
    		return res;
    	}

    	public static long GCD(long i, long j){
    	if (i==0){
    		return j;
    	}
    	return GCD(j%i,i);
    	}
    	public static long LCM(long i, long j){
    		return(i*j)/GCD(i,j);
    	}

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

long  n=sc.nextLong();
long ra=sc.nextLong();
long sa=sc.nextLong();
long pa=sc.nextLong();
long rb=sc.nextLong();
long sb=sc.nextLong();
long pb=sc.nextLong();
long ra1=ra;
long sa1=sa;
long pa1=pa;
long rb1=rb;
long sb1=sb;
long pb1=pb;
long min=0;
long max=0;

ra=pb-ra;
ra+=rb;
if(ra<0){

	min+=(-ra);
}
sa=rb-sa;
sa+=sb;
if(sa<0){
	min+=(-sa);
}
pa=sb-pa;
pa+=pb;
	if(pa<0){
		min+=(-pa);
}

if(sb>=ra1){
	max+=ra1;

}
else{
	max+=(sb);
}
if(pb>=sa1){
	max+=sa1;
}
else{
	max+=(pb);
}
if(rb>=pa1){
	max+=pa1;

}
else{
	max+=(rb);
}
System.out.println(min+" "+max);
}

    	static class matrix{
    		int a, b,c, d;
    		public matrix(int x,int y, int z,int w){
    			a=x;
    			b=y;
    			c=z;
    			d=w;
    		}

    		public boolean issSem(){
    			return b==c ;
    		}
    	}
    	public static int p(long x){
    		int t=0;
    		while(x>1){
    			t++;
    			x=x/2;
    		}
    		return t;
    	}
     static long[] fact;
     public static long fact(int x){
long y=(int)Math.pow(2,x)-1;
return((y+1)*(y/2)+(y/2+1));
}

    	static ArrayList<Integer > [] adjlist;
    	static int [] leaves;
    	static PriorityQueue<pair> centroid;

    	public static void dfs1(int u,int p){
    		leaves[u]=1;
    		if(adjlist[u].size()==1&&u!=0){

    			return;
    		}
    		for( int x:adjlist[u]){
    			if(x!=p){
    				dfs1(x,u);
    				leaves[u]+=leaves[x];
    			}
    		}
    	}

    	static class pair implements Comparable<pair>{
    		int x;
    		int y;
    		public pair(int x, int y){
    			this.x=x;
    					this.y=y;
    		}
			@Override
			public int compareTo(pair o) {
				// TODO Auto-generated method stub
				return x-o.x;
			}
    	}

    	  	 	static class SegmentTree{
    	   	 		int[] arr , sTree;
    	   	 	static	int N;
    	   	 		public SegmentTree(int[] in){
    	   	 			arr=in;
    	   	 		N=arr.length-1;
    	   	 			sTree=new int[2*N];

    	   	 			build(1,1,N);
    	   	 		}
    	   	 		public void build(int node, int l, int r){
    	   	 			if(l==r){
    	   	 				sTree[node]=arr[l];
    	   	 			}
    	   	 			else{
    	   	 				int leftchild=node*2;
    	   	 				int rightchild=node*2+1;
    	   	 				int mid =(l+r)/2;
    	   	 				build(leftchild,l,mid);
    	   	 				build(rightchild,mid+1,r);
    	   	 				sTree[node]=Math.min(sTree[leftchild],sTree[rightchild]);
    	   	 			}
    	   	 		}
    	   	 		public  void update(int i, int val){
    	   	 			int node =i+N-1;
    	   	 			arr[i]=val;
    	   	 			sTree[node]=val;
    	   	 			node=node/2;
    	   	 			while(node>0){
    	   	 			int leftchild=node *2;
       	 				int rightchild=node*2+1;
       	 			sTree[node]=sTree[leftchild]&sTree[rightchild];
       	 			node=node/2;
    	   	 			}
    	   	 			return;

    	   	 		}
    	   	 		public int query(int i, int j){
    	   	 			 return query(1,1, N,  i, j);
    	   	 		}
    	   	 		public int query(int node,int l, int r, int i , int j){
    	   	 			if(i>r||j<l){
    	   	 				return Integer.MAX_VALUE;
    	   	 			}
    	   	 			if(i<=l&&r<=j){
    	   	 				return sTree[node];
    	   	 			}
    	   	 		int leftchild=node*2;
    	 				int rightchild=node*2+1;
    	 				int mid =(l+r)/2;

    	 			return	Math.min(query(leftchild,l,mid,i,j),query(rightchild,mid+1,r,i,j));

    	   	 		}
    	   	 	}

    	static class Scanner {
    		StringTokenizer st;
    		BufferedReader br;

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

    		public boolean hasNext() {
    			// TODO Auto-generated method stub
    			return false;
    		}

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

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

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

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

    		public double nextDouble() throws IOException {
    			String x = next();
    			StringBuilder sb = new StringBuilder("0");
    			double res = 0, f = 1;
    			boolean dec = false, neg = false;
    			int start = 0;
    			if (x.charAt(0) == '-') {
    				neg = true;
    				start++;
    			}
    			for (int i = start; i < x.length(); i++)
    				if (x.charAt(i) == '.') {
    					res = Long.parseLong(sb.toString());
    					sb = new StringBuilder("0");
    					dec = true;
    				} else {
    					sb.append(x.charAt(i));
    					if (dec)
    						f *= 10;
    				}
    			res += Long.parseLong(sb.toString()) / f;
    			return res * (neg ? -1 : 1);
    		}

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

    	}}


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

public class GuessTheTree {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	boolean solve() throws IOException {
		int n = nextInt();
		int initN = n;
		List<Integer> szList = new ArrayList<>();
		int leaves = 0;

		for (int i = 0; i < n; i++) {
			int x = nextInt();
			if (x == 1) {
				leaves++;
			} else {
				szList.add(x);
			}
		}

		n = szList.size();

		if (leaves <= n) {
			return false;
		}

		if (n == 0) {
			return true;
		}

		Collections.sort(szList);
		Collections.reverse(szList);

		int[] sz = new int[n];
		for (int i = 0; i < sz.length; i++) {
			sz[i] = szList.get(i);
		}

		if (sz[0] != initN) {
			return false;
		}

		int[] maskCnt = new int[1 << n];
		int[] maskSum = new int[1 << n];
		for (int i = 0; i < n; i++) {
			maskCnt[1 << i] = 1;
			maskSum[1 << i] = sz[i];
		}

		for (int mask = 1; mask < (1 << n); mask++) {
			int low = Integer.lowestOneBit(mask);
			maskCnt[mask] = maskCnt[low] + maskCnt[mask ^ low];
			maskSum[mask] = maskSum[low] + maskSum[mask ^ low];
		}

		boolean[][][] dp = new boolean[n + 1][leaves + 1][1 << n];
		// current node, unassigned leaves, unassigned nodes

		final int ALL = (1 << n) - 1;

		dp[0][leaves][ALL ^ 1] = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= leaves; j++) {
				for (int mask = 0; mask < (1 << n); mask++) {
					if (!dp[i][j][mask] || test(mask, i)) {
						continue;
					}
					for (int sub = mask; ; sub = (sub - 1) & mask) {
						int leavesHere = sz[i] - 1 - maskSum[sub];
						if (leavesHere >= 0 && leavesHere <= j
								&& leavesHere + maskCnt[sub] >= 2) {
							dp[i + 1][j - leavesHere][mask ^ sub] = true;
						}
						if (sub == 0) {
							break;
						}
					}
				}
			}
		}

		return dp[n][0][0];

	}

	static boolean test(int mask, int i) {
		return ((mask >> i) & 1) == 1;
	}

	void inp() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		out.println(solve() ? "YES" : "NO");
		out.close();
	}

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

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

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


import java.util.Scanner;

public class E {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        if (k > n) {
            System.out.println(0);
            System.exit(0);
        }
        long[][] F = new long[n + 1][n + 1];
        long[][] G = new long[n + 1][n + 1];
        long[][] C = new long[n + 1][n + 1];
        int mod = (int) 1e9 + 7;
        for (int i = 0; i <= n; i++)
            for (int j = 0; j <= i; j++)
                if (i == j || j == 0)
                    C[i][j] = 1;
                else
                    C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
        F[0][0] = 1;
        G[0][0] = G[1][0] = 1;
        for (int i = 2; i <= n; i++)
            for (int j = 0; j <= n; j++)
                for (int left = 1; left < i; left++) {
                    int right = i - left - 1;
                    long mul = (C[i - 2][left - 1] * left * Math.max(right, 1))
                            % mod;
                    // Need root
                    for (int kLeft = 0; kLeft < j; kLeft++) {
                        int kRight = j - kLeft - 1;
                        long notLeft = (G[left][kLeft] * (right == 0
                                && kRight == 0 ? 1
                                    : (F[right][kRight] + G[right][kRight])))
                                % mod;
                        long notRight = right == 0 ? 0
                                : (F[left][kLeft] * G[right][j - kLeft - 1])
                                        % mod;
                        F[i][j] = (F[i][j] + mul * (notLeft + notRight)) % mod;
                    }
                    // No need root
                    for (int kLeft = 0; kLeft <= j; kLeft++)
                        G[i][j] = (G[i][j] + mul
                                * ((F[left][kLeft] * F[right][j - kLeft]) % mod))
                                % mod;
                }
        System.out.println((G[n][k] + F[n][k]) % mod);
    }
}


// practice with rainboy
import java.io.*;
import java.util.*;

public class CF884F extends PrintWriter {
	CF884F() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF884F o = new CF884F(); o.main(); o.flush();
	}

	static final int A = 26, INF = 0x3f3f3f3f;
	int[] oo, oh; int __ = 1;
	int link(int o, int h) {
		oo[__] = o; oh[__] = h;
		return __++;
	}
	int[] ii, jj, cc, cost, cost_; int m_;
	int[] ae, pi, dd, ff; int n_;
	int[] pq, iq; int cnt;
	void init() {
		oo = new int[1 + m_ * 2]; oh = new int[1 + m_ * 2];
		ii = new int[m_]; jj = new int[m_]; cc = new int[m_ << 1];
		cost = new int[m_]; cost_ = new int[m_];
		pi = new int[n_]; dd = new int[n_]; ff = new int[n_];
		ae = new int[n_];
		pq = new int[1 + n_]; iq = new int[n_];
		m_ = 0;
	}
	void link_(int i, int j, int c, int co) {
		int h = m_++;
		ii[h] = i; jj[h] = j; cc[h << 1] = c;
		cost[h] = co;
		ae[i] = link(ae[i], h << 1);
		ae[j] = link(ae[j], h << 1 | 1);
	}
	boolean less(int u, int v) {
		return pi[u] < pi[v] || pi[u] == pi[v] && dd[u] < dd[v];
	}
	int i2(int i) {
		return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
	}
	void pq_up(int u) {
		int i, j, v;
		for (i = iq[u]; (j = i / 2) > 0 && less(u, v = pq[j]); i = j)
			pq[iq[v] = i] = v;
		pq[iq[u] = i] = u;
	}
	void pq_dn(int u) {
		int i, j, v;
		for (i = iq[u]; (j = i2(i)) > 0 && less(v = pq[j], u); i = j)
			pq[iq[v] = i] = v;
		pq[iq[u] = i] = u;
	}
	void pq_add_last(int u) {
		pq[iq[u] = ++cnt] = u;
	}
	int pq_remove_first() {
		int u = pq[1], v = pq[cnt--];
		if (v != u) {
			iq[v] = 1; pq_dn(v);
		}
		iq[u] = 0;
		return u;
	}
	boolean dijkstra(int s, int t) {
		Arrays.fill(pi, INF);
		pi[s] = 0; pq_add_last(s);
		while (cnt > 0) {
			int i = pq_remove_first();
			int d = dd[i] + 1;
			for (int o = ae[i]; o != 0; o = oo[o]) {
				int h_ = oh[o];
				if (cc[h_] > 0) {
					int h = h_ >> 1;
					int j = i ^ ii[h] ^ jj[h];
					int p = pi[i] + ((h_ & 1) == 0 ? cost_[h] : -cost_[h]);
					if (pi[j] > p || pi[j] == p && dd[j] > d) {
						if (pi[j] == INF)
							pq_add_last(j);
						pi[j] = p; dd[j] = d; ff[j] = h_;
						pq_up(j);
					}
				}
			}
		}
		return pi[t] != INF;
	}
	int trace(int s, int t) {
		while (t != s) {
			int h_ = ff[t], h = h_ >> 1;
			cc[h_]--; cc[h_ ^ 1]++;
			t ^= ii[h] ^ jj[h];
		}
		return 1;
	}
	int edmonds_karp(int s, int t) {
		for (int h = 0; h < m_; h++) {
			int i = ii[h], j = jj[h];
			pi[j] = Math.min(pi[j], pi[i] + cost[h]);
		}
		for (int h = 0; h < m_; h++) {
			int i = ii[h], j = jj[h];
			cost_[h] = cost[h] + pi[i] - pi[j];
		}
		int f = 0;
		while (dijkstra(s, t)) {
			f += trace(s, t);
			for (int h = 0; h < m_; h++) {
				int i = ii[h], j = jj[h];
				if (pi[i] != INF && pi[j] != INF) {
					// pi[j] <= pi[i] + cost_[h]
					// cost_[h] + pi[i] - pi[j] >= 0
					cost_[h] += pi[i] - pi[j];
				}
			}
		}
		int ans = 0;
		for (int h = 0; h < m_; h++)
			ans += cc[h << 1 | 1] * cost[h];
		return ans;
	}
	void main() {
		int n = sc.nextInt() / 2;
		n_ = 1 + n + A + 1;
		m_ = n + n * A + A;
		init();
		byte[] cc = sc.next().getBytes();
		int[] bb = new int[n * 2];
		for (int i = 0; i < n * 2; i++)
			bb[i] = sc.nextInt();
		for (int i = 0; i < n; i++)
			link_(0, 1 + i, 2, 0);
		for (int i = 0; i < n; i++) {
			int j = n * 2 - 1 - i;
			int ai = cc[i] - 'a';
			int aj = cc[j] - 'a';
			for (int a = 0; a < A; a++) {
				int b;
				if (a == ai && a == aj)
					b = Math.max(bb[i], bb[j]);
				else if (a == ai)
					b = bb[i];
				else if (a == aj)
					b = bb[j];
				else
					b = 0;
				link_(1 + i, 1 + n + a, 1, -b);
			}
		}
		int[] kk = new int[A];
		for (int i = 0; i < n * 2; i++) {
			int a = cc[i] - 'a';
			kk[a]++;
		}
		for (int a = 0; a < A; a++)
			link_(1 + n + a, n_ - 1, kk[a], 0);
		println(-edmonds_karp(0, n_ - 1));
	}
}


import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong();
        String stx=x+"";
        long y=sc.nextLong();

        int sumx=0;

        for(int i=0;i<stx.length();i++){
        sumx+=Integer.parseInt(stx.charAt(i)+"");
        }

   sumx=Math.max(sumx, ((Integer.parseInt(stx.charAt(0)+"")-1)+(9*(stx.length()-1))));

      int count=0;

    if(x<y){System.out.println("0");}
      else{
         for(long i =y;i<=x;i++){
         String st_temp=i+"";
     int sub_temp=0;
     for(int j=0;j<st_temp.length();j++){
        sub_temp+=Integer.parseInt(st_temp.charAt(j)+"");
        }
     if((i-sub_temp)<y){count++;}
     else{break;}

     }
        System.out.println(x-(count+y)+1);
    }

   }

}


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

public class Main {

    public static void main(String[] args) {

        Scanner input=new Scanner(System.in);

        long n=input.nextLong();

        boolean f;
        long p=n;
        while(p>1){

            f=false;
            for(long i=2;(i*i)<=p && !f;i++){
                if(p%(i*i)==0){
                    p=p/i;
                    //System.out.println(i);
                    f=true;
                }
            }

            if(!f)
                break;
        }

        System.out.println(p);
    }
}


import java.util.Scanner;

/**
 *
 * @author Pc
 */
public class TEST {

    public static String reverse(String s) {
        String reverse = "";
        for (int i = s.length() - 1; i >= 0; i--) {
            reverse += s.charAt(i);
        }
        return reverse;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        String s1, s2;

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

            if (n % i == 0) {
                s1 = s.substring(0, i);
                s2 = s.substring(i);
                s1 = reverse(s1);
                s = s1 + s2;

            }
        }
         s = reverse(s);
        System.out.println(s);
    }
}


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

public class towerhanoi {
  private static Reader in;
  private static PrintWriter out;
  public static int[][] cost = new int[3][3];

  public static void main(String[] args) throws IOException {
    in = new Reader();
    out = new PrintWriter(System.out, true);
    for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++)
      cost[i][j] = in.nextInt();
    int N = in.nextInt();
    dp = new long[N+1][3][3];
    for (int i = 0; i <= N; i++)
      for (int j = 0; j < 3; j++)
        for (int k = 0; k < 3; k++)
          dp[i][j][k] = -1;
    out.println(solve(N, 0, 2));
  }

  public static long[][][] dp;
  public static long solve (int disks, int from, int to) {
    if (disks == 0) return 0;
    if (dp[disks][from][to] != -1) return dp[disks][from][to];
    int other = 3 - from - to;
    return dp[disks][from][to] = Math.min(
        solve(disks-1, from, other) + cost[from][to] + solve(disks-1, other, to),
        solve(disks-1, from, to) + cost[from][other] + solve(disks-1, to, from)
        + cost[other][to] + solve(disks-1, from, to));
  }

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

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

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

    public String readLine() throws IOException {
      byte[] buf = new byte[1024];
      int cnt = 0;
      byte c = read();
      while (c <= ' ')
        c = read();
      do {
        buf[cnt++] = c;
      } while ((c = read()) != '\n');
      return new String(buf, 0, cnt);
    }

    public String next() throws IOException {
      byte[] buf = new byte[1024];
      int cnt = 0;
      byte c = read();
      while (c <= ' ')
        c = read();
      do {
        buf[cnt++] = c;
      } while ((c = read()) > ' ');
      return new String(buf, 0, cnt);
    }

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

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

    public double nextDouble() throws IOException {
      double ret = 0, div = 1;
      byte c = read();
      while (c <= ' ')
        c = read();
      boolean neg = (c == '-');
      if (neg)
        c = read();
      do {
        ret = ret * 10 + c - '0';
      } while ((c = read()) >= '0' && c <= '9');
      if (c == '.')
        while ((c = read()) >= '0' && c <= '9')
          ret += (c - '0') / (div *= 10);
      if (neg)
        return -ret;
      return ret;
    }

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

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

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

}


import java.util.Scanner;
public class prob59A{
    public static void main (String[] args){
      Scanner s=new Scanner(System.in);
      //System.out.println("enter word?");
      String x = s.next();
      toupperorlower(x);
    }
    public static void toupperorlower(String word) {
        char ch[] = new char[word.length()];
        String z = word.toLowerCase();
        char x[] = new char[word.length()];
        for (int i = 0; i < ch.length; i++) {
            ch[i] = word.charAt(i);
        }
        for (int i = 0; i < ch.length; i++) {
            x[i] = z.charAt(i);
        }
        int lower = 0;
        int upper = 0;
        for (int i = 0; i < ch.length; i++) {
            if (x[i] == ch[i]) {
                lower++;
            }
            if (x[i] != ch[i]) {
                upper++;
            }

        }
        if (upper > lower) {
            System.out.println(word.toUpperCase());
        }
        if (lower >= upper) {
            System.out.println(word.toLowerCase());
        }

    }
}


import java.util.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.text.DecimalFormat;
import java.lang.ArrayIndexOutOfBoundsException;
import java.lang.Exception;
import java.lang.ArithmeticException;
import java.lang.InterruptedException;
import java.lang.NullPointerException;
public class Test{
	 static Scanner s = new Scanner(System.in);
	 static int _I(){int x=s.nextInt(); return x;}
	 static long _ll(){long l=s.nextLong(); return l;}
	 static double _d(){double x=s.nextDouble(); return x;}
	 static String _S(){String str=s.nextLine(); return str;}
	 static int gcd(int x,int y){return y==0 ? x:gcd(y,x%y);}
	 static int lcm(int x,int y){return x*y;}
	 long ar[]=new long[100000];

	public static void solve(){
		DecimalFormat d= new DecimalFormat("00");
		String str=Test._S();
		int t=Test._I();
		String ss[]=str.split(":");
		Integer hh=Integer.parseInt(ss[0]);
		Integer mm=Integer.parseInt(ss[1]);
		mm=mm+t;
		if(mm>=60){
			hh=hh+mm/60;
			mm=mm%60;
			if(hh>23){
				hh=hh%24;
			}
		}
		System.out.println(d.format(hh)+":"+d.format(mm));
	}
	public static void main_field(){

		Test.solve();
	}
	public static void main(String[] args){
		Test t = new Test();
		Test.main_field();

	}
}


import java.util.Scanner;

public class Main {

    static long  xo=0,yo=0, GCD=0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long  n = sc.nextLong();
        long  p = sc.nextLong();
        long  w = sc.nextLong();
        long  d = sc.nextLong();
        long  x, y,z;

        long  g = GCD(w,d);

        if(p%g!=0){
            System.out.println("-1");
            return;
        }

        if(n*w<p){
            // this is when he won all matches but
            // points are not equal to p
            System.out.println("-1");
            return;
        }

        p/=g;
        w/=g;
        d/=g;

        y = ((p%w) * inverseModulo(d,w))%w;
        x = (p-y*d)/w;
        if(x+y>n){
            //if number of wins and  draw is greater than total number of matches
            System.out.println("-1");
            return;
        }

        if(x<0){
            System.out.println("-1");
            return;
        }

        z = n-(x+y);
        System.out.println(x+" "+y+" "+z);

    }

    private static long inverseModulo(long a, long  m) {
        if(m==1)return 0;
        long  m0 =m,x =1,y=0;

        while(a>1){
            long  q = a/m , t =m;
            m = a%m; a=t;
            t =y;
            y = x - q * y;
            x =t;

        }

        if(x<0) x+=m0;
        return x;

    }

    private static void ExtendedEuclid(long  a, long  b){
        //base case

        if (b == 0) {

            xo =1;
            yo=0;
            GCD = a;
            return;
        }

        ExtendedEuclid(b,a%b);

        long  cX = yo;
        long  cy = xo - (a/b)*yo;

        xo = cX;
        yo = cy;
    }

    private static  long GCD(long  a, long b){
        return b==0 ? a: GCD(b,a%b);
    }
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int doors = sc.nextInt();
		int floors = sc.nextInt();
		int flats = sc.nextInt();
		int from =  sc.nextInt();
		int to =  sc.nextInt();

		int from_flat = (from - 1)% flats;
		int from_floor =
				((from - from_flat - 1)% (floors*flats))/flats ;

		int from_door = (from - from_floor * flats -from_flat - 1) /
				(floors*flats);

		int to_flat = (to - 1)% flats;
		int to_floor =
				((to - to_flat - 1)% (floors*flats))/flats ;

		int to_door = (to - to_floor * flats - to_flat - 1) /
				(floors*flats);

		int time = 0;
		if(to_door == from_door){
			time += Math.min(Math.abs(to_floor - from_floor) * 5,
					10 +  Math.abs(to_floor - from_floor));
			//System.out.println(time);
		} else {
			time += Math.min(Math.abs(from_floor - 0) * 5,
					10 +  Math.abs(from_floor - 0));
			//System.out.println(time);
			time += 15 * Math.min(doors - Math.abs(to_door - from_door),
					Math.abs(to_door - from_door));
			//System.out.println(time);
			time += Math.min(Math.abs(to_floor - 0) * 5,
					10 +  Math.abs(to_floor - 0));
			//System.out.println(time);
		}
		System.out.println(time);
	}
}


import java.util.*;

public class CODE {

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

    public static void main(String[] args) {
        int n = sc.nextInt();
        int arr[] = new int[2 * n];
        int count = 0;
        HashSet<Integer> set = new HashSet<>();

        for (int i = 0; i < 2 * n; i++) {
            arr[i] = sc.nextInt();
            set.add(arr[i]);
        }

        for (int i = 0; i < 2 * n; i++) {
            for (int j = i; j < 2 * n; j++) {
                if (set.contains(arr[i] ^ arr[j])) {
                    count++;
                    if (arr[i] != arr[j]) {
                        count++;
                    }
                }
            }
        }

        System.out.println(count % 2 == 0 ? "Karen" : "Koyomi");
    }
}


import java.io.*;
import java.util.*;
import java.util.regex.*;
public class vk18
{
    public static void main(String[]stp) throws Exception
    {
    	Scanner scan=new Scanner(System.in);
    	PrintWriter pw = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        long n=Long.parseLong(st.nextToken()),m=0;
        st=new StringTokenizer(br.readLine());
        long k=Long.parseLong(st.nextToken());
        st=new StringTokenizer(br.readLine());
        long a=Long.parseLong(st.nextToken());
        st=new StringTokenizer(br.readLine());
        long b=Long.parseLong(st.nextToken());
		long ans=0;
		if(k==1) { ans+=(n-1)*a; n=1; }
		while(n>1)
		{
			if(n%k==0)
			{
				m=n%k;
				ans+=Math.min(b,(n-n/k)*a);
				n/=k;
			}
			else
			{
				m=(n%k);
				if(n == m) { ans+=(n-1)*a; break; }
				ans+=(m)*a;
				n-=(n%k);

			}
		}
		pw.print(ans);
        pw.flush();
    }

}


/**
 * Created with IntelliJ IDEA.
 * User: Sergey Epifanov
 * Date: 5/19/12
 */
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

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

    private Scanner in;
    private PrintWriter out;

    private void run() throws IOException {
        boolean online = System.getProperty("ONLINE_JUDGE") != null;
        in = online ? new Scanner(System.in) :
                new Scanner(new FileReader("input.txt"));
        out = online ? new PrintWriter(System.out) :
                new PrintWriter(new FileWriter("output.txt"));
        solve();
        out.flush();
        out.close();
    }

    private void solve() throws IOException {

        // input
        long w = in.nextInt();
        long h = in.nextInt();
        long w2 = w/2 * (w - w/2);
        long h2 = h/2 * (h - h/2);
        long res = w2 * h2;
        out.println(res);
    }
}


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

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

	public static long MOD = 1000000007;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		final int[] data = new int[n];
		final TreeSet<Integer> set = new TreeSet();

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

			data[i] = in.nextInt();

		}
		long result = 0;
		boolean[] check = new boolean[n];

		LinkedList<Integer> tmp = new LinkedList();
		boolean[] inS = new boolean[n];
		for (int i = 1; i + 1 < n; i++) {
			if (!check[i]) {
				inS[i] = true;
				tmp.add(i);
				while (!tmp.isEmpty()) {
					int v = tmp.poll();
					inS[v] = false;
					if (check[v]) {
						continue;
					}
					Integer a = set.lower(v);
					Integer b = set.higher(v);
					if (a != null && b != null && data[a] >= data[v]
							&& data[v] <= data[b]) {
						check[v] = true;
						set.remove(v);

						result += (long) Math.min(data[a], data[b]);
						if (!inS[a])
							tmp.add(a);
						if (!inS[b])
							tmp.add(b);
						// System.out.println(set + " " + v + " " + result + " "
						// + a + " " + b);
					}

				}
			}
		}
		TreeSet<Integer> list = new TreeSet(new Comparator<Integer>() {

			@Override
			public int compare(Integer o1, Integer o2) {
				int a = set.lower(o1);
				int b = set.higher(o1);
				int c = set.lower(o2);
				int d = set.higher(o2);
				a = Math.min(data[a], data[b]);
				c = Math.min(data[c], data[d]);
				return a - c;
			}
		});
		for (int i = 1; i + 1 < n; i++) {
			if (!check[i]) {
				list.add(i);
			}
		}
		while(!list.isEmpty()){
			int v = list.pollLast();
			set.remove(v);
			int a = set.lower(v);
			int b = set.higher(v);
			int c = Math.min(data[a], data[b]);
			result += c;
			if(a != 0){
				list.remove(a);
				list.add(a);
			}
			if(b != n -1){
				list.remove(b);
				list.add(b);
			}
			//System.out.println(list);

		}
		out.println(result);

		out.close();
	}

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

	}

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

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

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

	}

	public static class Point implements Comparable<Point> {

		int x, y;

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

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

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

		@Override
		public int compareTo(Point o) {
			return y - o.y;
		}
	}

	public static class FT {

		long[] data;

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

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

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

		}
	}

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

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

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

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

		public String next() {

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

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

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

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

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

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


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

public class B {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static long H,W;
    static BitSet bs;
    static long mod = 1000000007;
      // All possible moves of a knight
    static   int X[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
    static int Y[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
    static int [] dr   = {-1,0,0,1};
    static int [] dc = {0,1,-1,0};
    static int [][] grid = new int[3][3];
    static int R1 =0;
    static int R2 = 0;
    static int R3=0;
    static int C1 = 0;
    static int C2 = 0;
    static int C3 = 0;
    static int D1 = 0;
    static int D2 = 0;

    public static void main(String args[]) throws IOException {
    /**
1.What is the unknown:
2.What are the data: an array of tlen ght  the value is 10^9
3.What is the condition:
4. understand the problem:
5. What are the cases edges in the problem:
6.What what max:
7. Are you using a data stcuture. And which one:
8.Is there reursion what is the base case. For example COINS:
*/
            for(int i=0;i<3;i++)
                for(int j=0;j<3;j++)
                    grid[i][j] = in.nextInt();
        boolean stop = false;
        for(int i=1;i<=1000000&&!stop;i++){
            //set a[0][0] = 1
            grid[0][0] = i;
            if(firstCol()==firstRow()){
                int newVal = firstCol()-secondRow();
                grid[1][1] = newVal;
                if(secondRow()==secondCol()&&secondRow()==firstCol()&&newVal >0){
                    int val = firstCol()-thirdCol();
                    grid[2][2] = val;
                    if(secondRow()==secondCol()&&secondRow()==firstCol()&&thirdCol()==thirdRow()&&val>0&&topLeftAndButtomRight()==bottumLeftAdnTopRight()){
                        printTwoDArray();
                        stop  = true;
                    }
                    grid[2][2] = 0;
                }
                grid[1][1] = 0;
            }
            grid[0][0] = 0;

        }

            out.flush();
    }
    private static int topLeftAndButtomRight (){
        int sum=0;
        for(int i=0;i<3;i++)
            sum+=grid[i][i];
        return sum;
    }
    private static int bottumLeftAdnTopRight (){
        int sum=0;
        for(int i=2;i>=0;i--)
            sum+=grid[i][2-i];
        return sum;
    }
    private static void printTwoDArray() {
        for(int i=0;i<grid.length;i++){
            for(int j=0;j<grid[i].length;j++){
                out.print(grid[i][j]+" ");
            }
            out.print("\n");
        }
    }

    public static int firstRow() {
        int sum=0;
        for(int i=0;i<3;i++)
            sum+=grid[0][i];
        return sum;
    }
    public static int secondRow(){
        int sum=0;
        for(int i=0;i<3;i++)
            sum+=grid[1][i];
        return sum;
    }  public static int thirdRow(){
        int sum=0;
        for(int i=0;i<3;i++)
            sum+=grid[2][i];
        return sum;
    }
    public static int thirdCol(){
        int sum=0;
        for(int i=0;i<3;i++)
            sum+=grid[i][2];
        return sum;
    }
    public static int secondCol(){
        int sum=0;
        for(int i=0;i<3;i++)
            sum+=grid[i][1];
        return sum;
    }
    public static int firstCol (){
        int sum=0;
        for(int i=0;i<3;i++)
            sum+=grid[i][0];
        return sum;
    }
    public static boolean subseqeunce(String s, String t){
        for(int i=0,j=0;i<s.length();i++){
            if(j<t.length()&&s.charAt(i)==t.charAt(j)){
                j++;
            }
            if(j==t.length()) return true;
        }
        return false;
    }

    private static int lowrBound(int[] a, int lo, int hi, int element) {
        while(lo<hi){
            int mid = lo+(hi-lo)/2;
            if(element>a[mid]){
                lo = mid+1;
            }else{
                hi  = mid;
            }
        }
        if(lo<a.length&&a[lo]==element){
            return lo+1;
        }
        return lo;
    }

    static long lcm(int a, int b) {
        return (a*b)/gcd(a, b);
    }
    static boolean isVowel(char c) {
        if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y'){
            return true;
        }
        return false ;
    }
    static class IP implements Comparable<IP>{
        public int first,second;
        IP(int first, int second){
            this.first = first;
            this.second = second;
        }
        public int compareTo(IP ip){
            if(first==ip.first)
                return second-ip.second;
            return first-ip.first;
        }
        @Override
        public String toString() {
            return first+" "+second;
        }

    }

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

        static boolean isEven(long a) {
            return (a&1)==0;
        }

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

     }
}


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

public class P1599C {
    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        double p = scanner.nextDouble();

        int lo = 0, hi = n, ans = n;
        while (lo <= hi) {
            int m = (lo + hi) / 2;
            if (chance(n, m) >= p) {
                hi = m - 1;
                ans = m;
            } else {
                lo = m + 1;
            }
        }
        writer.println(ans);

        writer.flush();
    }

    private static double chance(int n, int m) {
        double p = 0.0;

        if (m >= 3) {
            p += comb(m, 3);
        }
        if (m >= 2 && n - m >= 1) {
            p += comb(m, 2) * comb(n - m, 1);
        }
        if (m >= 1 && n - m >= 2) {
            p += comb(m, 1) * comb(n - m, 2) / 2.0;
        }

        return p / comb(n, 3);
    }

    private static long comb(int from, int pick) {
        long ans = 1;
        for (int i = 0; i < pick; i++) {
            ans *= from - i;
        }
        for (int i = 2; i <= pick; i++) {
            ans /= i;
        }

        return (int)ans;
    }

    private static class MyScanner {
        private BufferedReader reader;
        private StringTokenizer st;

        public MyScanner(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

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

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


import java.util.Scanner;

public class CF236_1 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int v = in.nextInt();

        if (k > b) {
        int i;
        for (i = 0; a > 0; i++) {

            if (b > 0) {
            for (int j = 0; b >= 0; b--) {
                a = a - v;
            }
            }else {
                a = a - v;
            }
        }
        System.out.println(i);
        } else {
    //
            int i;
            for (i = 0; a > 0; i++) {
                if (b>=0){
                for (int j = 0; (b >= 0)&(j < k) ; j++) {
                        a = a - v;
                        b--;
                    }
                b = b+1;
                }else a = a - v;

            }
            System.out.println(i);
            }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;

public class C {
	public static long [] fac;
	public static long [][] comb;
	public static long mod= 998244353;
	public static void main(String[] args) throws IOException {
		FastScanner in= new FastScanner(System.in);
		PrintWriter out= new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();

		comb= new long[5001][5001];
		fac= new long[5001];
		fac[0]=1;
		for (long i = 1; i < fac.length; i++) {
			fac[(int)i]= (fac[(int) (i-1)]*i)%mod;
		}
		comb[0][0]= 1;
		for (int i=1;i<=5000;i++) {
			comb[i][0]=1;
			for (int j=1;j<=i;j++)
				comb[i][j]= (comb[i-1][j-1]+comb[i-1][j])%mod;
		}
		long res=1;
		res= (res*go(a,b))%mod;
		res= (res*go(b,c))%mod;
		res= (res*go(a,c))%mod;

		System.out.println(res);

	}
	public static long go(int a, int b) {
		long res=0;
		for (int i = 0; i <=a && i<=b; i++) {
			long cur= fac[i];
			cur= (cur*comb[a][i])%mod;
			cur= (cur*comb[b][i])%mod;
			res= (res+cur)%mod;
		}
		return res;
	}
	static class p implements Comparable<p>{
		int x;
		int y;
		public p(int a, int b) {
			x=a;
			y=b;
		}
		public int compareTo(p o) {
			return this.x-o.x;
		}
	}
	static class FenwickTree {
		long[] ft;
		public FenwickTree(int n) {
			ft = new long[n + 1];
		}

		int rsq(int b) {
			int sum = 0;
			for (; b > 0; b -= (b & (-b)))
				sum += ft[b];
			return sum;
		}

		int rsq(int a, int b) {
			return rsq(b) - (a == 1 ? 0 : rsq(a - 1));
		}

		void update(int k, int v) {
			for (; k < ft.length; k += (k & (-k)))
				ft[k] += v;
		}
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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);
        TaskH solver = new TaskH();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskH {
        long[] lens;
        Description[] cache;
        int m;
        int[] b;
        int[] gen;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int d = in.nextInt();
            m = in.nextInt();
            gen = new int[d];
            for (int i = 0; i < d; ++i) gen[i] = in.nextInt();
            int blen = in.nextInt();
            b = new int[blen];
            for (int i = 0; i < blen; ++i) {
                b[i] = in.nextInt();
            }
            long left = in.nextLong();
            long right = in.nextLong();
            lens = new long[100];
            long len = 1;
            int layer = 0;
            lens[layer] = len;
            while (true) {
                ++layer;
                if (len < (right + d - 1) / d) {
                    len *= d;
                    lens[layer] = len;
                } else {
                    lens[layer] = right + 1;
                    break;
                }
            }
            cache = new Description[layer + 1];
            Description d1 = describe(layer, right);
            Description d2 = describe(layer, left + b.length - 2);
            long res = d1.matchesInside[0] - d2.matchesInside[0];
            out.println(res);
        }

        private Description describe(int layer, long upto) {
            if (upto > lens[layer]) throw new RuntimeException();
            if (upto == lens[layer]) {
                if (cache[layer] != null) return cache[layer];
            }
            Description res = null;
            if (upto <= 0) {
                res = new Description(upto);
                return res;
            }
            if (layer == 0) {
                res = new Description(upto);
                for (int shift = 0; shift < m; ++shift) {
                    if (b.length > 1 && b[0] >= shift) {
                        res.matchesPrefix[shift] = BigInteger.ONE;
                    } else {
                        res.matchesPrefix[shift] = BigInteger.ZERO;
                    }
                    if (b.length > 1 && b[b.length - 1] >= shift) {
                        res.matchesSuffix[shift] = BigInteger.ONE.shiftLeft(b.length - 1);
                    } else {
                        res.matchesSuffix[shift] = BigInteger.ZERO;
                    }
                    if (b.length == 1 && b[0] >= shift) {
                        ++res.matchesInside[shift];
                    }
                    byte[] bits = new byte[(b.length + 7) >> 3];
                    for (int i = 0; i < b.length; ++i) {
                        if (b[i] >= shift) {
                            bits[bits.length - 1 - (i >> 3)] |= (1 << (i & 7));
                        }
                    }
                    res.coveredIfStartsFrom[shift] = new BigInteger(1, bits);
                }
            } else {
                long togo = upto;
                for (int i = 0; i < gen.length && togo > 0; ++i) {
                    long by = Math.min(togo, lens[layer - 1]);
                    Description d = describe(layer - 1, by);
                    res = combine(res, d, gen[i]);
                    togo -= by;
                }
            }
            if (res == null) throw new RuntimeException();
            if (upto == lens[layer]) {
                cache[layer] = res;
            }
            return res;
        }

        private Description combine(Description a, Description b, int delta) {
            if (a == null) {
                if (delta != 0) throw new RuntimeException();
                return b;
            }
            Description res = new Description(a.len + b.len);
            for (int shift = 0; shift < m; ++shift) {
                int ashift = shift;
                int bshift = (shift + delta) % m;
                res.matchesInside[shift] = a.matchesInside[ashift] + b.matchesInside[bshift];
                res.matchesInside[shift] += a.matchesPrefix[ashift].and(b.matchesSuffix[bshift].shiftRight(1)).bitCount();
                res.matchesPrefix[shift] = b.matchesPrefix[bshift];
                if (b.len < this.b.length) {
                    res.matchesPrefix[shift] = res.matchesPrefix[shift].or(a.matchesPrefix[ashift].and(b.coveredIfStartsFrom[bshift].shiftRight(1)).shiftLeft((int) b.len));
                }
                res.matchesSuffix[shift] = a.matchesSuffix[ashift];
                if (a.len < this.b.length) {
                    res.matchesSuffix[shift] = res.matchesSuffix[shift].or(b.matchesSuffix[bshift].shiftRight((int) a.len).and(a.coveredIfStartsFrom[ashift]));
                }
                if (a.len < this.b.length) {
                    res.coveredIfStartsFrom[shift] = a.coveredIfStartsFrom[ashift].and(b.coveredIfStartsFrom[bshift].shiftRight((int) a.len));
                } else {
                    res.coveredIfStartsFrom[shift] = BigInteger.ZERO;
                }
            }
            return res;
        }

        class Description {
            long len;
            long[] matchesInside = new long[m];
            BigInteger[] matchesPrefix = new BigInteger[m];
            BigInteger[] matchesSuffix = new BigInteger[m];
            BigInteger[] coveredIfStartsFrom = new BigInteger[m];

            public Description(long len) {
                this.len = len;
            }

        }

    }

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

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

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

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

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

    }
}


import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Conversion {

	private static long converted=-1;

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		long base=s.nextLong();
		String baseAsString=base+"";
		s.nextLine();
		StringBuilder unconverted=new StringBuilder(s.nextLine());
		Queue<Long> pieces=new LinkedList<Long>();
		while (unconverted.length()!=0) {
			for (int length=baseAsString.length(); length>0; length--) {
				if (canRemove(unconverted, base-1, unconverted.length()-length,length)) {
					pieces.add(converted);
					remove(unconverted, length);
					break;
				}
			}
		}
		for (Long l:pieces) {
			//System.out.println(l);
		}
		long total=0;
		long power=0;
		while (!pieces.isEmpty()) {
			long exponent=1;
			for (int i=0; i<power; i++) {
				exponent*=base;
			}
			total+=pieces.remove()*exponent;
			power++;
		}
		System.out.println(total);
	}

	private static boolean canRemove(StringBuilder unconverted, long maxValue, int index, int length) {
		String substring=unconverted.substring(Math.max(0, index), Math.min(index+length, unconverted.length()));
		if (substring.startsWith("0")&&length!=1) {
			return false;
		}
		converted=Long.parseLong(substring);
		return converted<=maxValue;
	}

	private static void remove(StringBuilder unconverted, int length) {
		for (int i=0; i<length&&unconverted.length()!=0; i++) {
			unconverted.deleteCharAt(unconverted.length()-1);
		}
	}

}


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

public class Main {

	public static void main(String[] args) throws Exception {
		long time = System.nanoTime();

		int n = next();

		int[] x1 = new int[n];
		int[] x2 = new int[n];
		int[] y1 = new int[n];
		int[] y2 = new int[n];

		for (int i = 0; i < n; i++) {
			x1[i] = next();
			y1[i] = next();
			x2[i] = next();
			y2[i] = next();
		}

		TreeSet<Integer> setx = new TreeSet<Integer>();
		TreeSet<Integer> sety = new TreeSet<Integer>();

		for (int x : x1) setx.add(x);
		for (int x : x2) setx.add(x);
		for (int y : y1) sety.add(y);
		for (int y : y2) sety.add(y);

		int kx = setx.size();
		int ky = sety.size();

		int[] x = new int[kx];
		int[] y = new int[ky];

		int ind = 0;
		for (int xx : setx) x[ind++] = xx;
		ind = 0;
		for (int yy : sety) y[ind++] = yy;

/*		for (int i = 0; i < kx; i++) out.print(x[i] + " ");
		out.println();
		for (int i = 0; i < ky; i++) out.print(y[i] + " ");
		out.println();*/

		boolean flag = true;
		for (int i = 0; i < kx - 1; i++)
			for (int j = 0; j < ky - 1; j++) {
				boolean cont = false;
				for (int t = 0; t < n; t++) {
					if ((x1[t] - x[i])*(x2[t] - x[i]) <= 0 && (x1[t] - x[i + 1])*(x2[t] - x[i + 1]) <= 0 &&
						(y1[t] - y[j])*(y2[t] - y[j]) <= 0 && (y1[t] - y[j + 1])*(y2[t] - y[j + 1]) <= 0) cont = true;
				}

				if (!cont) flag = false;
			}

	   	flag &= x[kx - 1] - x[0] == y[ky - 1] - y[0];

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

//		System.out.println((System.nanoTime() - time)* 1e-9);
		out.close();
	}
	static PrintWriter out = new PrintWriter(System.out);

	static BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer in = new StringTokenizer("");

	static String nextToken() throws Exception {
		if (!in.hasMoreTokens()) in = new StringTokenizer(bufferedreader.readLine());
		return in.nextToken();
	}

	static int next()  throws Exception {return Integer.parseInt(nextToken());};
	static int[] next(int n) throws Exception {
		int[] x = new int[n];
		for (int i = 0; i < n; i++) x[i] = next();
		return x;
	}
	static int[][] next(int n, int m) throws Exception {
		int[][] x = new int[n][];
		for (int i = 0; i < n; i++) x[i] = next(m);
		return x;
	}

	static long nextl() throws Exception {return Long.parseLong(nextToken());};
	static long[] nextl(int n) throws Exception {
		long[] x = new long[n];
		for (int i = 0; i < n; i++) x[i] = nextl();
		return x;
	}
	static long[][] nextl(int n, int m) throws Exception {
		long[][] x = new long[n][];
		for (int i = 0; i < n; i++) x[i] = nextl(m);
		return x;
	}

	static double nextd() throws Exception {return Double.parseDouble(nextToken());};
	static double[] nextd(int n) throws Exception {
		double[] x = new double[n];
		for (int i = 0; i < n; i++) x[i] = nextd();
		return x;
	}
	static double[][] nextd(int n, int m) throws Exception {
		double[][] x = new double[n][];
		for (int i = 0; i < n; i++) x[i] = nextd(m);
		return x;
	}

	static String nextline() throws Exception {
		in = new StringTokenizer("");
		return bufferedreader.readLine();
	}

}


import java.math.BigInteger;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner SC =  new Scanner(System.in);
        BigInteger a, b, x, y, xynwd;
        a=new BigInteger(SC.next());
        b=new BigInteger(SC.next());
        x=new BigInteger(SC.next());
        y=new BigInteger(SC.next());
        xynwd=x.gcd(y);
        x=x.divide(xynwd);
        y=y.divide(xynwd);
        a=a.divide(x);
        b=b.divide(y);
        System.out.println(a.compareTo(b)>0 ? b : a);
    }
}


import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.*;
import java.util.regex.Pattern;

public class CF1156G {
    public static void main(String[] args) throws Exception {
        boolean local = System.getProperty("ONLINE_JUDGE") == null;
        boolean async = false;

        Charset charset = Charset.forName("ascii");

        FastIO io = local ? new FastIO(new FileInputStream("D:\\DATABASE\\TESTCASE\\Code.in"), System.out, charset) : new FastIO(System.in, System.out, charset);
        Task task = new Task(io, new Debug(local));

        if (async) {
            Thread t = new Thread(null, task, "dalt", 1 << 27);
            t.setPriority(Thread.MAX_PRIORITY);
            t.start();
            t.join();
        } else {
            task.run();
        }

        if (local) {
            io.cache.append("\n\n--memory -- \n" + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20) + "M");
        }

        io.flush();
    }

    public static class Task implements Runnable {
        final FastIO io;
        final Debug debug;
        int inf = (int) 1e8;
        int mod = (int) 1e9 + 7;

        public int mod(int val) {
            val %= mod;
            if (val < 0) {
                val += mod;
            }
            return val;
        }

        public int mod(long val) {
            val %= mod;
            if (val < 0) {
                val += mod;
            }
            return (int) val;
        }

        public Task(FastIO io, Debug debug) {
            this.io = io;
            this.debug = debug;
        }

        @Override
        public void run() {
            solve();
        }

        Map<String, Var> context = new HashMap<>();
        HashSet<String> remainNames = new HashSet<>();
        Deque<String> useable = new ArrayDeque<>();

        public void solve() {
            int n = io.readInt();

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

            StringBuilder builder = new StringBuilder();
            for (int i = 'a'; i <= 'z'; i++) {
                for (int i2 = 'a'; i2 <= 'z'; i2++) {
                    for (int i3 = 'a'; i3 <= 'z'; i3++) {
                        for (int i4 = 'a'; i4 <= 'z'; i4++) {
                            builder.setLength(0);
                            builder.append((char) i).append((char) i2).append((char) i3).append((char) i4);
                            remainNames.add(builder.toString());
                        }
                    }
                }
            }

            remainNames.removeAll(context.keySet());
            useable.addAll(remainNames);

            String finalName = rebuild(getVar("res"));
            if (trace.isEmpty() && !finalName.equals("res")) {
                trace.add("res=" + finalName);
                finalName = "res";
            }
            if (!trace.isEmpty()) {
                trace.add(trace.remove(trace.size() - 1).replace(finalName, "res"));
            }
            io.cache.append(trace.size()).append('\n');
            for (String s : trace) {
                io.cache.append(s).append('\n');
            }
        }

        List<String> trace = new ArrayList<>();

        Random random = new Random(12345678);
        Map<String, String> exprToName = new HashMap<>();

        public String randomName() {
            return useable.removeFirst();
        }

        public String register(String expr, String name) {
            if (exprToName.containsKey(expr)) {
                return exprToName.get(expr);
            } else {
                trace.add(name + "=" + expr);
                exprToName.put(expr, name);
                return name;
            }
        }

        StringBuilder common = new StringBuilder(1024);

        public String concat(String... parts) {
            common.setLength(0);
            for (String part : parts) {
                common.append(part);
            }
            return common.toString();
        }

        Map<Var, String> cache = new IdentityHashMap<>();

        public String rebuild(Var var) {
            if (cache.containsKey(var)) {
                return cache.get(var);
            }
            String retName = null;
            if (var instanceof UnknownVar) {
                retName = ((UnknownVar) var).name;
            }
            if (var instanceof Reference) {
                retName = rebuild(var.arg1);
            }
            if (var instanceof Expr) {
                String name = randomName();
                String arg1 = rebuild(var.arg1);
                String arg2 = rebuild(((Expr) var).arg2);
                retName = register(concat(arg1, ((Expr) var).op, arg2), name);
            }
            cache.put(var, retName);
            return retName;
        }

        char[] line = new char[100];
        Lexer lexer = new Lexer();

        public Var getVar(String s) {
            if (!context.containsKey(s)) {
                UnknownVar var = new UnknownVar();
                var.name = s;
                context.put(s, var);
            }
            return context.get(s);
        }

        public void parseLine() {
            int len = io.readString(line, 0);
            lexer.reset(line, len);
            String variable = lexer.readName();
            lexer.readOp();
            String arg1 = lexer.readName();
            if (!lexer.hasMore()) {
                Reference reference = new Reference();
                reference.arg1 = getVar(arg1);
                context.put(variable, reference);
            } else {
                Expr expr = new Expr();
                expr.arg1 = getVar(arg1);
                expr.op = lexer.readOp();
                expr.arg2 = getVar(lexer.readName());
                Reference reference = new Reference();
                reference.arg1 = expr;
                context.put(variable, reference);
            }
        }
    }

    public static class Lexer {
        char[] data;
        int len;
        int rpos = 0;
        StringBuilder builder = new StringBuilder();

        public void reset(char[] data, int len) {
            this.data = data;
            this.len = len;
            rpos = 0;
        }

        public boolean hasMore() {
            return rpos != len;
        }

        public String readName() {
            builder.setLength(0);
            while (rpos < len && data[rpos] != '=' &&
                    data[rpos] != '$' && data[rpos] != '^' && data[rpos] != '#' && data[rpos] != '&') {
                builder.append(data[rpos++]);
            }
            return builder.toString();
        }

        public String readOp() {
            builder.setLength(0);
            builder.append(data[rpos++]);
            return builder.toString();
        }
    }

    public static class Var {
        Var arg1;
    }

    public static class Expr extends Var {
        String op;
        Var arg2;
    }

    public static class UnknownVar extends Var {
        String name;
    }

    public static class Reference extends Var {

    }

    public static class FastIO {
        public final StringBuilder cache = new StringBuilder();
        private final InputStream is;
        private final OutputStream os;
        private final Charset charset;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 8);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastIO(InputStream is, OutputStream os, Charset charset) {
            this.is = is;
            this.os = os;
            this.charset = charset;
        }

        public FastIO(InputStream is, OutputStream os) {
            this(is, os, Charset.forName("ascii"));
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public long readLong() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            long val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public double readDouble() {
            boolean sign = true;
            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+';
                next = read();
            }

            long val = 0;
            while (next >= '0' && next <= '9') {
                val = val * 10 + next - '0';
                next = read();
            }
            if (next != '.') {
                return sign ? val : -val;
            }
            next = read();
            long radix = 1;
            long point = 0;
            while (next >= '0' && next <= '9') {
                point = point * 10 + next - '0';
                radix = radix * 10;
                next = read();
            }
            double result = val + (double) point / radix;
            return sign ? result : -result;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

        public int readLine(char[] data, int offset) {
            int originalOffset = offset;
            while (next != -1 && next != '\n') {
                data[offset++] = (char) next;
                next = read();
            }
            return offset - originalOffset;
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public int readString(byte[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (byte) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public char readChar() {
            skipBlank();
            char c = (char) next;
            next = read();
            return c;
        }

        public void flush() {
            try {
                os.write(cache.toString().getBytes(charset));
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public boolean hasMore() {
            skipBlank();
            return next != -1;
        }
    }

    public static class Debug {
        private boolean allowDebug;

        public Debug(boolean allowDebug) {
            this.allowDebug = allowDebug;
        }

        public void assertTrue(boolean flag) {
            if (!allowDebug) {
                return;
            }
            if (!flag) {
                fail();
            }
        }

        public void fail() {
            throw new RuntimeException();
        }

        public void assertFalse(boolean flag) {
            if (!allowDebug) {
                return;
            }
            if (flag) {
                fail();
            }
        }

        private void outputName(String name) {
            System.out.print(name + " = ");
        }

        public void debug(String name, int x) {
            if (!allowDebug) {
                return;
            }

            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, long x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, double x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, int[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, long[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, double[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, Object x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, Object... x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.deepToString(x));
        }
    }
}


import java.util.Scanner;

public class MikeSeq
{
	public static void main(String[] args) {
		Scanner ishika = new Scanner (System.in);
		int n = ishika.nextInt();
		if(n >= 2600)
			System.out.print("3000");
		else if(n >= 2400)
			System.out.print("2600");
		else if(n >= 2300)
			System.out.print("2400");
		else if(n >= 2100)
			System.out.print("2300");
		else if(n >= 1900)
			System.out.print("2100");
		else if(n >= 1600)
			System.out.print("1600");
		else if(n >= 1400)
			System.out.print("1600");
		else if(n >= 1200)
			System.out.print("1400");
		else
			System.out.print("1200");
	}
}


import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static int b[];
    static String numbers;
    static String av;

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

        numbers = sc.nextLine();
        av = sc.nextLine();
        int n = av.length();
        b = new int[n];
        Arrays.fill(b, 1);
        int num = numbers.length();
        int totalCount = 0;

        while (find0(numbers.charAt(0))) {
            int m = 1;
            for (int i = 1; i < num; i++)
                if (find0(numbers.charAt(i))) {
                    m = m + 1;
                }
            if (num == m) {
                totalCount = totalCount + 1;
            } else break;
        }

        pw.println(totalCount);
        pw.close();
        sc.close();
    }

    static boolean find0(char c) {
        for (int i = 0; i < b.length; i++) {
            if (b[i] == 1 && check(c, av.charAt(i))) {
                b[i] = 0;
                return true;
            }
        }
        return false;
    }

    private static boolean check(char c, char c1) {
        if (c == c1) {
            return true;
        }
        if (c == '2' || c == '5' || c == '6' || c == '9' || c1 == '2' || c1 == '5' || c1 == '6' || c1 == '9') {
            //2 and 5
            if (c == '2' && c1 == '5') {
                return true;
            }
            if (c == '5' && c1 == '2') {
                return true;
            }
            if (c1 == '2' && c == '5') {
                return true;
            }
            if (c1 == '5' && c == '2') {
                return true;
            }
            //6 and 9
            if (c == '6' && c1 == '9') {
                return true;
            }
            if (c == '9' && c1 == '6') {
                return true;
            }
            if (c1 == '6' && c == '9') {
                return true;
            }
            if (c1 == '9' && c == '6') {
                return true;
            }
        }
        return false;
    }
}