import java.util.Scanner;
import java.util.Arrays;
public class A1095 {
	public static void main(String[] args) {
	    Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    String str = scan.nextString();
	    int i = 1;
	    while((i*(i+1))/2 != x){
	        i ++;

	    }
	    String s = "";
	    for(int j = 1; j < i; j ++){
	        s = s + x.charAt(j * (j + 1)/2);
	    }
	    System.out.println(s);

	}
}


import java.util.Scanner;

public class Music {

	public static void main(String[] args) {

		int t,s,q;
		Scanner sc = new Scanner(System.in);
		t = sc.nextInt();
		s = sc.nextInt();
		p = sc.nextInt();
		int p = 1, s = s*q;
		while(s < t){
			p++;
			s*=q;
		}
		System.out.println(p);
	}
}


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

public class D382 {

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

        solve(1, in, out);

        out.close();
    }

    private static void solve(int n, InputReader in, PrintWriter out) {
        while (n > 0) {
            solve(in, out);
            n--;
        }
    }

    private static void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int f[] = new int[n + 1];
        f[2] = 1;
        for (int i = 3; i <= n; i++) {
            int maxFactor = getMaxFactor(i);
            f[i] = maxFactor;
            int t = i-2;
            while (t > 1 && (i - t) > 1 && t>=(i-t)) {
                if (f[t] + f[i - t] < f[i]) {
                    f[i] = f[t] + f[i - t];
                }
                t--;
            }
        }
        System.out.println(f[n]);
    }

    private static int getMaxFactor(int n) {
        int t = n - 1;
        while (n % t != 0) {
            t--;
        }
        return t;
    }

    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 String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

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

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

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


package round122;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class E2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "9999999999999";

	void solve()
	{
		int M2 = 1<<13;
		int M5 = 5*5*5*5*5*5*5*5*5*5*5*5*5;

		long f = nl();
		int x2 = (int)(f % M2);
		int[] fa2 = new int[M2];
		int[] a2 = new int[1<<14];
		a2[0] = 0;
		a2[1] = 1;
		Arrays.fill(fa2, -1);
		fa2[0] = 0;
		fa2[1] = 1;
		for(int i = 2;i < 13000;i++){
			a2[i] = (a2[i-1] + a2[i-2]) % M2;
			if(fa2[a2[i]] == -1)fa2[a2[i]] = i;
		}
		if(fa2[x2] == -1){
			out.println(-1);
			return;
		}

		int f5 = (int)(f%5);
		List<Long> l = new ArrayList<Long>();
		{
			int[] a = new int[20];
			a[0] = 0;
			a[1] = 1;
			for(int i = 2;i < 4*5;i++){
				a[i] = (a[i-1] + a[i-2]) % 5;
			}
			for(int i = 0;i < 4*5;i++){
				if(a[i] == f5){
					l.add((long)i);
				}
			}
		}

		int[][] F = {
				{1, 1}, {1, 0}
		};
		for(long m = 25;m <= M5;m*=5){
			int fm = (int)(f % m);
			List<Long> nl = new ArrayList<Long>();
			for(long ll : l){
				for(int k = 0;k < 5;k++){
					long ne = ll+k*4*(m/5);
					long nf = 0;
					if(ne == 0){
						nf = 0;
					}else{
						nf = pow(F, new int[]{1, 0}, ne-1, (int)m)[0];
					}
					if(nf == fm){
						nl.add(ne);
					}
				}
			}
			l = nl;
		}

		long min = Long.MAX_VALUE;
		for(long ll : l){
			for(int u : a2){
				if(u == f % M2){
					long num = crtx(new long[]{M2*3/2, 4L*M5}, new long[]{u, ll}).longValue();
					if(num >= 0){
						min = Math.min(min, num);
					}
				}
			}
//			long num = crt(M2*3/2, fa2[x2], 4L*M5, ll);
		}
		if(min == Long.MAX_VALUE){
			out.println(-1);
		}else{
			out.println(min);
		}
	}

	public static long crt(long p, long m, long q, long n)
	{
		long[] apr = exGCD(p, q);
		if((n - m) % apr[0] != 0)return -1;
		long mod = p * q / apr[0];
		long a = (apr[1] * (n - m) / apr[0] * p + m) % mod;
		if(a < 0)a += mod;
		return a;
	}

	// int行列*ベクトル
	public static int[] mul(int[][] A, int[] v, int mod)
	{
		int m = A.length;
		int n = v.length;
		int[] w = new int[m];
		for(int i = 0;i < m;i++){
			long sum = 0;
			for(int k = 0;k < n;k++){
				sum += (long)A[i][k] * v[k];
				sum %= mod;
			}
			w[i] = (int)sum;
		}
		return w;
	}

	// int行列の2乗
	public static int[][] p2(int[][] A, int mod)
	{
		int n = A.length;
		int[][] C = new int[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				long sum = 0;
				for(int k = 0;k < n;k++){
					sum += (long)A[i][k] * A[k][j];
					sum %= mod;
				}
				C[i][j] = (int)sum;
			}
		}
		return C;
	}

	public static BigInteger[] exGCD(BigInteger a, BigInteger b)
	{
		BigInteger p = BigInteger.ONE, q = BigInteger.ZERO, r = BigInteger.ZERO, s = BigInteger.ONE;
		while(b.signum() > 0){
			BigInteger c = a.divide(b);
			BigInteger d;
			d = a; a = b; b = d.mod(b);
			d = p; p = q; q = d.subtract(c.multiply(q));
			d = r; r = s; s = d.subtract(c.multiply(s));
		}
		return new BigInteger[]{a, p, r};
	}

	public static BigInteger bi(long x){ return BigInteger.valueOf(x); }

	public static BigInteger crtx(long[] divs, long[] mods)
	{
		BigInteger div = bi(divs[0]), mod = bi(mods[0]);
		for(int i = 1;i < divs.length;i++){
			BigInteger[] apr = exGCD(div, bi(divs[i]));
			BigInteger mm = bi(mods[i]).subtract(mod);
			if(mm.mod(apr[0]).signum() != 0)return bi(-1);
			BigInteger da = div.divide(apr[0]);
			BigInteger ndiv = bi(divs[i]).multiply(da);
			BigInteger nmod = apr[1].multiply(mm).multiply(da).add(mod).mod(ndiv);
			if(nmod.signum() < 0)nmod = nmod.add(ndiv);
			div = ndiv;
			mod = nmod;
		}
		return mod;
	}

	// A^e*v
	public static int[] pow(int[][] A, int[] v, long e, int mod)
	{
		int[][] MUL = A;
		for(;e > 0;e>>>=1) {
			if((e&1)==1)v = mul(MUL, v, mod);
			MUL = p2(MUL, mod);
		}
		return v;
	}

	public static long[] exGCD(long a, long b)
	{
		long p = 1, q = 0, r = 0, s = 1;
		while(b > 0){
			long c = a / b;
			long d;
			d = a; a = b; b = d % b;
			d = p; p = q; q = d - c * q;
			d = r; r = s; s = d - c * s;
		}
		return new long[]{a, p, r};
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

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

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


package ACM;

import java.util.Scanner;

public class CF45F {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		sc.close();
		int ans=0;
		boolean f = false;
		if(n==1) {
			P(-1);
			return ;
		}
		if(n==2 && m==3||n==3 && m==5) {
			P(11);
			return ;
		}
		for(;;)
		{
			if(n>=m+m) {
				P(ans+1);
				return ;
			}
			else if(n>=m)
			{
				P(ans+(n==m?5:3));
				return ;
			}
			else if(!f) {
				m-=n-2;
				ans=4;
				f=true;
			}
			else
			{
				if(n/2==1)
				{
					P(-1);
					return ;
				}
				m-=n/2-1;
				ans+=2;
			}
		}
	}
	public static void P(int x)
	{
		System.out.println(x);
	}
}


//package school3;

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

public class F {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	int[] dec(int n, int m)
	{
		if(n <= m){
			return new int[]{n, 0};
		}else if(n <= 2 * m){
			return new int[]{n - m, n - m};
		}else{
			return new int[]{n - 2 * m - 1, m};
		}
	}

	int enc(int x, int y, int m)
	{
		if(y == 0){
			return x;
		}else if(x == y){
			return x + m;
		}else{
			return x + 2 * m + 1;
		}
	}

	void solve()
	{
		int m = ni();
		int n = ni();
		// (a, 0), (a, a), (a, m)
		BitSet visitedo = new BitSet();
		BitSet visitedh = new BitSet();
		BitSet q = new BitSet();
		q.set(0);
		boolean iso = true;
		int step = 0;

		outer:
		while(!q.isEmpty()){
//			tr(step, q);
			BitSet nq = new BitSet();
			if(iso){
				visitedh.or(q);
			}else{
				visitedo.or(q);
			}
			for(int cur = q.nextSetBit(0);cur != -1;cur = q.nextSetBit(cur+1)){
				if(!iso && cur == 2 * m)break outer;
				int[] co = dec(cur, m);
				if(iso){
					{
						if(co[1] == 0){
							int inf = co[0] + 1;
							int sup = Math.min(m, co[0] + n);
							if(inf <= sup){
								nq.set(enc(inf, 0, m), enc(sup, 0, m) + 1);
							}
						}
					}
					{
						int inf = Math.max(co[0], co[1]);
						if(co[0] == co[1])inf++;
						int sup = Math.min(m, (n + co[0] + co[1]) / 2);

						if(inf <= sup){
							nq.set(enc(inf, inf, m), enc(sup, sup, m) + 1);
						}
					}
					{
						int inf = co[0];
						if(co[1] == m)inf++;
						int sup = Math.min(m - 1, co[0] + n - m + co[1]);
						if(inf <= sup){
							nq.set(enc(inf, m, m), enc(sup, m, m) + 1);
						}
					}
				}else{
					{
						if(co[1] == m){
							int inf = co[0] - 1;
							int sup = Math.max(0, co[0] - n);
							if(sup <= inf){
								nq.set(enc(sup, m, m), enc(inf, m, m) + 1);
							}
						}
					}
					{
						int inf = Math.min(co[0], co[1]);
						if(co[0] == co[1])inf--;
						int sup = Math.max(0, (-n + co[0] + co[1]) / 2);

						if(sup == 0)sup++;
						if(sup <= inf){
							nq.set(enc(sup, sup, m), enc(inf, inf, m) + 1);
						}
					}
					{
						int inf = co[0];
						if(co[1] == 0)inf--;
						int sup = Math.max(0, co[0] - n + co[1]);
						if(sup <= inf){
							nq.set(enc(sup, 0, m), enc(inf, 0, m) + 1);
						}
					}
				}
			}
			if(iso){
				nq.andNot(visitedo);
			}else{
				nq.andNot(visitedh);
			}
			q = nq;
			step++;
			iso = !iso;
		}
		if(q.isEmpty()){
			out.println(-1);
		}else{
			out.println(step);
		}
	}

	void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

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

	int ni() { return Integer.parseInt(in.next()); }
	void tr(Object... o) { if(INPUT.length() != 0)System.out.println(o.length > 1 || o[0].getClass().isArray() ? Arrays.deepToString(o) : o[0]); }
}


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

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

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

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

    }

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

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

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

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

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


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

// 問題文を読んだら必ずサンプルでためせ ！
// あせってsubmitするな！！
// intあふれはないか！！
// コーナーケース(最小, 最大, 特殊なケース)で試したか！！
// 余りを求める問題で、マイナスになってはいないか！！
// 初期化をしているか！！
// すべての出力パターンをチェックしたか！！
public class E {
	Scanner in;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
	}

	void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

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

	int ni() { return Integer.parseInt(in.next()); }
	double nd() { return Double.parseDouble(in.next()); }
	void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.util.BitSet;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.TreeSet;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

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

class TaskE {
    // 2944730
    int[] primes;
    int[] candidates;
    int numCandidates;
    public void solve(int testNumber, MyScanner in, MyPrintWriter out) {
        int N = (int) 1e9;
        int L = in.nextInt(), R = in.nextInt();
        int p = in.nextInt();
        if(p<3){
            out.println(0);return;
        }
        primes = MathUtils.generatePrimes(p + 1);
        candidates = new int[2944730];
        Arrays.fill(candidates, Integer.MAX_VALUE);
        numCandidates = 0;
        gen(0, 1L, N);
        Arrays.sort(candidates);
        int[] dist = new int[numCandidates];
        Arrays.fill(dist, Integer.MAX_VALUE);
        dist[0] = 0;// 1
        boolean[] answer = new boolean[numCandidates];
        answer[0] = true;
        for(int n=2;n<=p;n++){
            int j = 0;
            for (int i = 0; i < dist.length; i++)if(dist[i] < p - n && candidates[i] <= N/n){
                while(candidates[j] < candidates[i] * n)j++;
                dist[j] = Math.min(dist[j], dist[i] + 1);
                if(dist[j] + n <= p)answer[j] = true;
            }
        }
        int res = 0;
        for (int i = 0; i < answer.length; i++)if(answer[i] && L <= candidates[i] && candidates[i] <= R)res++;
        out.println(res);
    }

    private void gen(int p, long number, int N) {
        if (p >= primes.length) {
            candidates[numCandidates++] = (int) number;
            return;
        }
        while (number <= N) {
            gen(p + 1, number, N);
            number *= primes[p];
        }
    }
}

class MyScanner {
    private final InputStream in;

    public MyScanner(InputStream in) {
        this.in = in;
    }

    int bufLen;
    int bufPtr;
    byte[] buf = new byte[1024];

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

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

    }

class MyPrintWriter {
    PrintWriter out;

    public MyPrintWriter(OutputStream outputStream) {
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public MyPrintWriter(Writer writer) {
        out = new PrintWriter(writer);
    }

    public void println(Object... os) {
        for (int i = 0; i < os.length - 1; i++) {
            out.print(os[i]);
            out.print(' ');
        }
        out.println(os[os.length - 1]);
    }

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

    }

class MathUtils {

    public static int[] generatePrimes(int upTo) {
        int N = upTo;
        boolean[] isPrime = generatePrimaryTable(N);
        int m = 0;
        for (boolean p : isPrime) if (p) m++;
        int[] res = new int[m];
        m = 0;
        for (int i = 0; i < isPrime.length; i++) {
            if (isPrime[i]) res[m++] = i;
        }
        return res;
    }

    public static boolean[] generatePrimaryTable(int n) {
        boolean[] isPrime = new boolean[n];
        Arrays.fill(isPrime, true);
        if (0 < n) isPrime[0] = false;
        if (1 < n) isPrime[1] = false;
        for (int i = 2; i * i < n; i++) {
            if (isPrime[i]) {
                for (int j = i * i; j < n; j += i)
                    isPrime[j] = false;
            }
        }
        return isPrime;
    }

    }


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

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            int n = scan.nextInt();
            int s = scan.nextInt();
            int ar[] = new int[n ];
            for (int i = 0; i < n; i++) {
                ar[i] = scan.nextInt();
            }
            Arrays.sort(ar);
            boolean flag = false;
            if (ar[1] > s)
                System.out.println("NO");
            else {
                for (int i = 2; i <= n; i++) {
                    if (ar[i] <= s - ar[1]) {
                        System.out.println("YES");
                        flag = true;
                        break;
                    }
                }
                if (flag == false)
                    System.out.println("NO");
            }
        }
    }
}


package test;

import java.util.Scanner;

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

       int val =sr.nextInt();
     sum += (int)Math.abs(val);
   }
   System.out.println(sum);

  }
}


import java.util.*;
public class A{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        String s = s.next();
        int b = 0;
        int k = 0;

        for(int i = 0; i<s.length();i++){
            if(s.charAt(i)==66&&s.charAt(i+1)==87){
                k++;
            }
        }
        k+=s.charAt(n-1)!=87?1:0;
        System.out.println(k);

        while(k-->0){
            int col = 1;
            for(int j = b; j < n-1; j++){
                if(st.charAt(j)==66&&s.charAt(j+1)==87){
                    b++;
                    break;
                }else if(s.charAt(j)==87){
                    b++;
                    continue;
                }
                b++;
                col++;
            }
            System.out.print(col+" ");
        }
    }
}


import java.util.*;
public class P721A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		String[] B = sc.nextLine().split("W");
		ArrayList<Integer> nums = new ArrayList<Integer>();
		for (String s : B)
			if (s.length() > 0)
				nums.add(s.length());
		String ans = "";
		for (int i : nums)
			ans += " " + i;
		System.out.println(nums.length());
		System.out.println(ans.substring(1));
	}

}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//package suffixstructures;

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

/**
 *
 * @author PrudhviNIT
 */

public class Main{

    /**
     * @param args the command line arguments
     */
    static String sub(String s, String t)
    {
        /*if(s.equals(t))
        {
            return s;
        }*/
        if(s.isEmpty()||t.isEmpty())
        {
            return "";
        }
        if(s.charAt(0)==t.charAt(0))
        {
            return s.charAt(0)+sub(s.substring(1),t.substring(1));
        }
        String s1 = sub(s.substring(1),t);
        String s2 = sub(s,t.substring(1));
        if(s1.length()>s2.length())
            return s1;
        return s2;
    }

    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s,t;
        s = br.readLine().trim();
        t = br.readLine().trim();
        int array=1,both=1;
        if(s.length()<t.length())
        {
            System.out.println("need tree");
            return;
        }
        if(sub(s,t).equals(t))
        {
            System.out.println("automaton");
            return;
        }
        int a1[],a2[],i;
        a1 = new int[26];
        a2 = new int[26];
        for(i=0;i<s.length();i++)
        {
            a1[s.charAt(i)-97]++;
        }
        for(i=0;i<t.length();i++)
        {
            a2[t.charAt(i)-97]++;
        }
        if(s.length()<t.length())
        {
            System.out.println("need tree");
            return;
        }
        if(s.length()==t.length())
        {
            for(i=0;i<26;i++)
            {
                if(a1[i]!=a2[i])
                {
                    array=0;
                    break;
                }
            }
            if(array==1)
            {
                System.out.println("array");
                return;
            }
        }
        for(i=0;i<26;i++)
        {
            if(a2[i]==0)
            {
                continue;
            }
            if(a2[i]==a1[i])
            {
                //Do nothing
            }
            else
            {
                System.out.println("need tree");
                return;
            }
        }
            System.out.println("both");
    }

}


package practiseCF;

import fastIO.InputReader;
import java.io.PrintWriter;
import java.util.*;

public class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
//        System.out.println(Math.toDegrees(Math.acos(0.5)));
        int n = in.nextInt();
        if(n >= 100) {
            out.print(0);
        } else {
            int [] a = new int[105];
            int [] b = new int[105];
            int [] c = new int[105];
            int [] d = new int[105];
            int [] e = new int[105];
            for(int i = 1; i <= n; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
                c[i] = in.nextInt();
                d[i] = in.nextInt();
                e[i] = in.nextInt();
            }

            Set<Integer> bad = new HashSet<>();

            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= n; j++) {
                    for(int k = 1; k <= n; k++)
                    {
                        if(i == j || j == k || k == i) {
                            continue;
                        }

                        long ax = a[j] - a[i];
                        long bx = b[j] - b[i];
                        long cx = c[j] - c[i];
                        long dx = d[j] - d[i];
                        long ex = e[j] - e[i];

                        long ay = a[k] - a[i];
                        long by = b[k] - b[i];
                        long cy = c[k] - c[i];
                        long dy = d[k] - d[i];
                        long ey = e[k] - e[i];

                        double val = ax * ay + bx * by + cx * cy + dx * dy + ex * ey;
                        long m1 = ax * ax + bx * bx + cx * cx + dx * dx + ex * ex;
                        long m2 = ay * ay + by * by + cy * cy + dy * dy + ey * ey;
                        val = val / Math.sqrt(m1);
                        val = val / Math.sqrt(m2);
                        if(Math.toDegrees(Math.acos(val)) +  0.000000001 < 90) {
                            bad.add(i);
                        }
                    }
                }
            }

            out.println(n - bad.size());

            for(int i = 1; i <= n; i++) {
                if(!bad.contains(i)) {
                    out.println(i);
                }
            }
        }
    }
}


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

public class Main {

    static Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    static Reader fastInput = new Reader();

    public static void main(String[] args) throws IOException {
        int n = fastInput.nextInt();
        if (n > 10) {
            System.out.println(0);
        } else {
            int[][] p = new int[n][5];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 5; j++) {
                    p[i][j] = fastInput.nextInt();
                }
            }
            ArrayList<Integer> good = new ArrayList<>();
            loop:
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i != j) {
                        for (int k = j + 1; k < n; k++) {
                            if (i != k) {
                                if (getAn(p[i], p[j], p[k]) < 90) {
                                    continue loop;
                                }
                            }
                        }
                    }
                }
                good.add(i + 1);
            }
            System.out.println(good.size());
            for (int i = 0; i < good.size(); i++) {
                System.out.println(good.get(i));
            }
        }
    }

    static double getAn(int[] p1, int[] p2, int[] p3) {
        double dot = 0, aLen = 0, bLen = 0;
        for (int i = 0; i < p1.length; i++) {
            dot += (p2[i] - p1[i]) * (p3[i] - p1[i]);
            aLen += (p2[i] - p1[i]) * (p2[i] - p1[i]);
            bLen += (p3[i] - p1[i]) * (p3[i] - p1[i]);
        }
        return 180 * Math.acos(dot / Math.sqrt(aLen * bLen)) / Math.PI;
    }

    static class Reader {

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

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

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

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

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

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

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

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

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

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

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

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

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

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


public class Main {

  private static void solve() {
    int m = ni();

    int mod = 1000000000 + 7;

    int[] primes = sieveEratosthenes(m + 1);

    long[] dp = new long[m + 1];

    long ret = 0;
    outer: for (int g = 2; g <= m; g ++) {
      dp[g] = f(m, g, mod);

      int[][] f = factor(g, primes);

        for (int[] v : f) {
          if (v[1] > 1) {
            continue outer;
          }
        }
        ret += dp[g] * (f.length % 2 == 1 ? 1 : (mod-1)) %mod;
        ret %=mod;
    }

    ret += inv(m, mod);
    ret %= mod;

    System.out.println(ret);

  }

  private static void dump(int mod) {
    for (int i = 1; i < 20; i ++) {
      for (int j = 1; j < 20; j ++) {
        System.out.println(i + " " + j + " " + inv(j, mod) * i % mod);
      }
    }
  }
  private static long f(long m, long g, int mod) {
    long a = (m/g) * inv(m, mod) % mod;
    long c = (m - (m/g) + mod) * inv(m/g, mod) % mod;

    long b = inv((mod-1+a) * (mod-1+a) % mod, mod) * a % mod;
    long ret = c * (mod + b - a) % mod;
    return ret;
  }

  public static long[][] enumDivisors(int[][] f)
  {
      int n = 1;
      for(int j = 0;j < f.length;j++){
          n *= f[j][1]+1;
      }
      long[][] divs = new long[n][2];
      int p = 1;
      divs[0][0] = 1;
      divs[0][1] = 1;
      for(int j = 0;j < f.length;j++){
          for(int q = p-1;q >= 0;q--){
              long b = divs[q][0];
              long s = -divs[q][1];
              for(int k = 0;k < f[j][1];k++){
                  b *= f[j][0];
//                if((long)b*b <= n)divs[p++] = b;
                  divs[p][1] = s;
                  divs[p++][0] = b;
                  s = -s;
              }
          }
      }
      long s = divs[n-1][1];
      for (int i = 0; i < n; i ++) {
        divs[i][1] *= s;
      }
      return divs;
  }

  public static int[][] factor(int n, int[] primes) {
    int[][] ret = new int[9][2];
    int rp = 0;
    for (int p : primes) {
      if (p * p > n)
        break;
      int i;
      for (i = 0; n % p == 0; n /= p, i++);
      if (i > 0) {
        ret[rp][0] = p;
        ret[rp][1] = i;
        rp++;
      }
    }
    if (n != 1) {
      ret[rp][0] = n;
      ret[rp][1] = 1;
      rp++;
    }
    return Arrays.copyOf(ret, rp);
  }

  public static int[] sieveEratosthenes(int n) {
    if (n <= 32) {
      int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
      for (int i = 0; i < primes.length; i++) {
        if (n < primes[i]) {
          return Arrays.copyOf(primes, i);
        }
      }
      return primes;
    }

    int u = n + 32;
    double lu = Math.log(u);
    int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];
    ret[0] = 2;
    int pos = 1;

    int[] isnp = new int[(n + 1) / 32 / 2 + 1];
    int sup = (n + 1) / 32 / 2 + 1;

    int[] tprimes = {3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
    for (int tp : tprimes) {
      ret[pos++] = tp;
      int[] ptn = new int[tp];
      for (int i = (tp - 3) / 2; i < tp << 5; i += tp)
        ptn[i >> 5] |= 1 << i;
      for (int j = 0; j < sup; j += tp) {
        for (int i = 0; i < tp && i + j < sup; i++) {
          isnp[j + i] |= ptn[i];
        }
      }
    }

    // 3,5,7
    // 2x+3=n
    int[] magic = {0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10,
        7, 12, 21, 17, 9, 6, 16, 5, 15, 14};
    int h = n / 2;
    for (int i = 0; i < sup; i++) {
      for (int j = ~isnp[i]; j != 0; j &= j - 1) {
        int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];
        int p = 2 * pp + 3;
        if (p > n)
          break;
        ret[pos++] = p;
        if ((long) p * p > n)
          continue;
        for (int q = (p * p - 3) / 2; q <= h; q += p)
          isnp[q >> 5] |= 1 << q;
      }
    }

    return Arrays.copyOf(ret, pos);
  }

  public static long inv(long a, int p)
  {
      long ret = 1;
      long mul = a;
      for(long n = p-2;n > 0;n >>>= 1){
          if((n&1)==1)ret = ret * mul % p;
          mul = mul * mul % p;
      }
      return ret;
  }

  public static long pow(long a, long n, long mod)
  {
      long ret = 1; // 1%mod if mod=1,n=0
      int x = 63-Long.numberOfLeadingZeros(n);
      for(;x >= 0;x--){
          ret = ret * ret % mod;
          if(n<<~x<0)ret = ret * a % mod;
      }
      return ret;
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

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

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

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

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


package round548;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class D3 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int mod = 1000000007;
		int n = ni();
		int[] invs = enumInvs(n, mod);
		int[] lpf = enumLowestPrimeFactors(n);
		int[] mobs = enumMobiusByLPF(n, lpf);

		// 4/3+2 = 10/3
		// 2 = 2

		long ans = 0;
		long ans2 = 0;
		for(int d = 2;d <= n;d++) {
			// sum (t/n)^k = 1/(1-t/n) = n/(n-t)
			ans -= mobs[d] * (long)invs[n-n/d];
			ans2 += mobs[d];
		}
		ans = ans*n + ans2 + 1;
		ans %= mod;
		if(ans < 0)ans += mod;
		out.println(ans);
	}

	public static int[] enumMobiusByLPF(int n, int[] lpf)
	{
		int[] mob = new int[n+1];
		mob[1] = 1;
		for(int i = 2;i <= n;i++){
			int j = i/lpf[i];
			if(lpf[j] == lpf[i]){
//				mob[i] = 0;
			}else{
				mob[i] = -mob[j];
			}
		}
		return mob;
	}

	public static int[] enumInvs(int n, int mod)
	{
		int[] inv = new int[n+1];
		inv[1] = 1;
		for(int i = 2;i <= n;i++){
			inv[i] = (int)(inv[mod%i]*(long)(mod-mod/i)%mod);
		}
		return inv;
	}

	public static long invl(long a, long mod) {
		long b = mod;
		long p = 1, q = 0;
		while (b > 0) {
			long c = a / b;
			long d;
			d = a;
			a = b;
			b = d % b;
			d = p;
			p = q;
			q = d - c * q;
		}
		return p < 0 ? p + mod : p;
	}

	public static int[] enumDivisorsFast(int n, int[] lpf)
	{
		int[] divs = {1};
		while(lpf[n] > 0){
			int p = lpf[n];
			int e = 0;
			for(;p == lpf[n];e++, n /= p);
			int olen = divs.length;
			divs = Arrays.copyOf(divs, olen*(e+1));
			for(int i = olen;i < divs.length;i++)divs[i] = divs[i-olen] * p;
		}
		return divs;
	}

	public static int[] enumLowestPrimeFactors(int n) {
		int tot = 0;
		int[] lpf = new int[n + 1];
		int u = n + 32;
		double lu = Math.log(u);
		int[] primes = new int[(int) (u / lu + u / lu / lu * 1.5)];
		for (int i = 2; i <= n; i++)
			lpf[i] = i;
		for (int p = 2; p <= n; p++) {
			if (lpf[p] == p)
				primes[tot++] = p;
			int tmp;
			for (int i = 0; i < tot && primes[i] <= lpf[p] && (tmp = primes[i] * p) <= n; i++) {
				lpf[tmp] = primes[i];
			}
		}
		return lpf;
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.util.Scanner;

public class Problem2{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        long n = Integer.parseInt(sc.nextLine());
        long upper = (long)(Math.pow(n,0.5)+1);
        long lower = (long) (Math.pow(10, (long)(Math.log10((long)Math.pow(n, 0.5)))) -1);
        if((Math.pow(n,0.5) - (long) (Math.pow(10, (long)(Math.log10((long)Math.pow(n, 0.5)))))) >= 10000)
            lower = (long) (Math.pow(n, 0.5)-10000);
        boolean f = true;
        for(long i=lower; i<=upper; i++){
            if(Math.pow(i, 2)+s(i)*i == n) {
                System.out.println(i);
                f = false;
                break;
            }
        }
        if(f)
            System.out.println(-1);
    }

    public static int s(long x){
        int output = 0;
        while(x != 0){
            output += x%10;
            x/=10;
        }
        return(output);
    }
}


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

import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

/**
 *
 * @author Darkhan
 */
public class task4 {
    static int[] a, b, ar;
    static int n, d;
    static long x;
    static ArrayList<Integer> bset = new ArrayList<>();
    static TreeSet<Integer> aset = new TreeSet<>();
    public static void main (String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextLong();
        a = new int[n];
        b = new int[n];
        ar = new int[n+1];
        initAB();
        Iterator<Integer> it;
        long t;
        if (d < 3000){
            for (int i=0;i<n;i++){
                if (b[i] == 1) bset.add(i);
                t = 0;
                for (Integer bset1 : bset) {
                    t = Math.max(t, a[i - bset1]);
                }
                out.println(t);
            }
        }
        else{
            int val;
            for (int i=0;i<n;i++){
                t = 0;
                aset.add(a[i]);
                it = aset.descendingIterator();
                while(it.hasNext()){
                    val = it.next();
                    if (b[i-ar[val]] == 0) continue;
                    t = val;
                    break;
                }
                out.println(t);
            }
        }
    }
    public static long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    public static void initAB() {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
            ar[i+1] = i;
        }
        for(int i = 0; i < n; i = i + 1){
            int t = (int)(getNextX() % (i + 1));
            ar[a[i]] = t;
            ar[a[t]] = i;
            swap(a, i, t);
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public static void swap(int[] a, int i, int j){
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
public class a
{
public static void main(String[] args)
{
  Scanner kbd = new Scanner(System.in);
 String s = kbd.next();
int n = kbd.nextInt();
 //v (ASCII code 118, lowercase v), < (ASCII code 60), ^ (ASCII code 94) or > (ASCII code 62)
 int a[]={118,60,94,62};
 int first = (int) s.charAt(0);
  int last=(int) s.charAt(s.length()-1);

 int first_index=0;
 for(int i=0;i<4;i++)
 {
   if(first==a[i])
   first_index=i;
 }
 //System.out.println(first_index);//2

 int last_index=0;
 for(int i=0;i<4;i++)
 {
   if(last==a[i])
   last_index=i;
 }
// System.out.println(last_index);//3
 int ex = n%4;//1
 int f=first_index;
 for(int i=0;i<ex;i++)
 {
   if(f==3)
   f=0;
   else
   f+=1;
 }

 int f1=first_index;
 for(int i=0;i<ex;i++)
 {
   if(f1==0)
   f1=3;
   else
   f1-=1;
 }

 if(a[f]==last&&a[f1]!=last)
 System.out.println("cw");
 else if(a[f1]==last&&a[f]!=last)
 System.out.println("ccw");
 else
 System.out.println("undefined");

}

}


package contest;

import java.util.Scanner;

public class First {

	@SuppressWarnings("null")
	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);

		String[] shape = new String[2];
		for (int i = 0; i < shape.length; i++)
			shape[i]=input.next();
		int num = input.nextInt();
		String[] s = new String[4];
		s[0]="v";
		s[1]="<";
		s[2]="^";
		s[3]=">";
		int j = 0;
		for (; j < s.length; j++) {
			if(s[j].equals(shape[0]))
				break;
		}

		num%=4;

		String targetR = "";
		for (int i = 1; i <=num; i++) {
			if(j+i>3){
				targetR=s[j+i-4];
			}
			else
			targetR=s[j+i];
		}

		String targetL="";
		for (int i = 1; i <=num; i++) {
			if(j-i<0){
				targetL=s[j-i+4];
			}
			else
			targetL=s[j-i];
		}

		System.out.println(targetR);
		System.out.println(targetL);
		if(targetR.equals(shape[1])&&targetL.equals(shape[1]))
			System.out.println("undefined");
		else if(targetR.equals(shape[1]))
			System.out.println("cw");
		else if(targetL.equals(shape[1]))
		System.out.println("ccw");
		else
			System.out.println("undefined");

	}

}


import java.util.Scanner;

public class Guard {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int square = 0;
        for (int i = 1; i <= 1000; i++) {
            if (i * i > n) {
                square = i - 1;
                break;
            }
        }
        int perim = square * 4;
        int leftOver = n - (square * square);
        while (leftOver > 0) {
            perim += 2;
            leftOver -= square;
        }
        System.out.println(perim);
    }

}


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

public class A{
    public static void main(String[] args) throws Exception{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(f.readLine());
        StringTokenizer st = new StringTokenizer(f.readLine());
        int[] places = new int[N/2];

        for(int i = 0;i<N/2;i++){
            places[i] = Integer.parseInt(st.nextToken());
        }

        int sum1 = 0;
        for(int i = 1;i <= N/2;i++){
            sum1 += Math.abs(i*2-1 - places[i-1]);
        }

        int sum2 = 0;
        for(int i = 1;i;i<=N/2;i++){
            sum2 += Math.abs(i*2 - places[i-1]);
        }

        System.out.println(Math.min(sum1,sum2));
    }
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (!br.ready()) {
			String[] entrada = br.readLine().split(" ");
			int m = Integer.parseInt(entrada[0]);
			int n = Integer.parseInt(entrada[1]);
			System.out.println((m*n)/2);
		}
	}
}


import java.io.BufferedReader;
	import java.io.IOException;
	import java.io.InputStreamReader;
	import java.io.PrintWriter;
	import java.util.*;
	public class ACM {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());

				int a = Integer.parseInt(st.nextToken());
				int n = Integer.parseInt(st.nextToken());
				StringTokenizer str = new StringTokenizer(br.readLine());
				int counter =0;
				int[] crime = new int[a];
				while(str.hasMoreTokens()) {
					for(int i=0; i<a;i++) {
						crime[i]=Integer.parseInt(str.nextToken());
					}
				}

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

				for(int i = 2*n-1;i<a; i++) {
					if(crime[i]==1)
						counter++;
				}

				pw.println(counter);
				pw.close();

				}

			}


// Working program with FastReader
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;

 public class ideone
{
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

	public static void main(String[] args)
	{
		FastReader s=new FastReader();
        int arr[]=new int[4];

            int hash[]=new int[1000000007];
            int sum=0;
            for(int i=0;i<1000000007;i++)
            {
                hash[i]=0;
            }
            for(int i=0;i<4;i++)
            {
                hash[arr[i]%1000000007]=hash[arr[i]%1000000007]+1;
                if(hash[arr[i]%1000000007]>1)
                sum+=1;

            }
            System.out.println(sum);

	}
}


package adowrath.euler;

import java.util.Scanner;
import java.util.stream.Stream;

public class ProjectEuler {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int additionalDays = 0;
		int nextYear = n;
		do {
			additionalDays += addDays(nextYear++);
			additionalDays %= 7;
			if(additionalDays == 0) {
				if(isLeap(n) != isLeap(nextYear)) {

				} else {
					break;
				}
			}
		} while(true);
		System.out.println(nextYear);
	}

	static boolean isLeap(int year) {
		return year % 400 == 0 || (!(year % 100 == 0) && year % 4 == 0);
	}

	static int addDays(int year) {
		return isLeap(year) ? 2 : 1;
	}

	//
	//	public static void main(String[] args) throws SecurityException {
	//		//		TODO Implement windows to control everything
	//
	//		Translator.init("project_euler");
	//
	//		EulerFrame.addClasses(Problems.class);
	//
	//		Application.launch(EulerFrame.class, args);
	//
	//	}
}


//package round426;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	long L, R;
	char[] r;
	boolean ex = false;

	void solve()
	{
		L = nl(); R = nl();
		if(R == 1000000000000000000L){
			if(L == R){
				out.println(1);
				return;
			}
			R = 999999999999999999L;
			ex = true;
		}
		String zr = ("0000000000000000000" + Long.toString(R));
		zr = zr.substring(zr.length()-18);
		r = zr.toCharArray();

		dfs(18, 0, new int[10]);
		out.println(ct);
	}

	int ct = 0;
	int[] g = new int[10];
	int[] temp = new int[10];
	int[] hist = new int[18];

	boolean check(int[] f)
	{
		if(f[0] == 17 && f[1] == 1 && ex)return true;
		System.arraycopy(f, 0, g, 0, 10);
		boolean edge = true;
		long num = 0;
		int min = 9;
		outer:
		for(int i = 0;i < 18;i++){
			inner:
			for(int j = edge?r[i]-'0':min;j >= 0;j--){
				if(f[j] > 0){
					if(!edge)min = j;
					if(edge && j == r[i]-'0'){
						int hp = 0;
//						System.arraycopy(f, 0, temp, 0, 10);
						f[j]--;
						hist[hp++] = j;
						int p = 0;
						for(int k = i+1;k < 18;k++){
							while(p < 9 && f[p] == 0)p++;
							if(p < r[k]-'0'){
								// ok
								break;
							}else if(p > r[k]-'0'){
								while(hp > 0)f[hist[--hp]]++;
//								System.arraycopy(temp, 0, f, 0, 10);
								continue inner;
							}
							f[p]--;
							hist[hp++] = p;
						}
						while(hp > 0)f[hist[--hp]]++;
//						System.arraycopy(temp, 0, f, 0, 10);
					}
					f[j]--;
					num = num * 10 + j;
					if(j < r[i]-'0')edge = false;
					continue outer;
				}
			}
			System.arraycopy(g, 0, f, 0, 10);
			return false;
		}
		boolean ret = num >= L;
		System.arraycopy(g, 0, f, 0, 10);
		return ret;
	}

	void dfs(int rem, int cur, int[] f)
	{
		if(cur == 9){
			f[cur] = rem;
			ct += check(f) ? 1 : 0;
			return;
		}

		for(int i = 0;i <= rem && i <= 18;i++){
			f[cur] = i;
			dfs(rem-i, cur+1, f);
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


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

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

    static class TaskC {
        public long a;
        public long b;
        public int pt;
        public int[] l;
        public int[] r;
        public int[] arr;
        public int ans;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            a = in.nextLong();
            b = in.nextLong();
            String sa = String.valueOf(a), sb = String.valueOf(b);
            while (sa.length() < sb.length()) sa = "0" + sa;
            l = new int[sa.length()];
            r = new int[sb.length()];
            for (int i = 0; i < sa.length(); i++) l[i] = sa.charAt(i) - '0';
            for (int i = 0; i < sb.length(); i++) r[i] = sb.charAt(i) - '0';
            arr = new int[10];
            long[] pow10 = new long[sb.length() + 1];
            pow10[0] = 1;
            for (int i = 1; i < pow10.length; i++) pow10[i] = pow10[i - 1] * 10;
            pt = 0;
            while (pt < sa.length() && l[pt] == r[pt]) {
                a -= pow10[sb.length() - pt - 1] * l[pt];
                b -= pow10[sb.length() - pt - 1] * l[pt];
                pt++;
            }
            if (pt == sb.length()) {
                out.println(1);
                return;
            }
            dfs(0, r.length - pt);
            out.println(ans);
        }

        public void dfs(int num, int left) {
            if (num == 9) {
                arr[9] = left;
                if (ok(arr)) {
                    ans++;
                }
            } else {
                for (int i = 0; i <= left; i++) {
                    arr[num] = i;
                    dfs(num + 1, left - i);
                }
            }
        }

        public boolean ok(int[] arr) {
            long num1 = 0;
            for (int cdig = 9; cdig >= 0; cdig--) {
                for (int k = 0; k < arr[cdig]; k++) {
                    num1 = num1 * 10 + cdig;
                }
            }
            if (num1 < a) {
                return false;
            }
            long num2 = 0;
            for (int cdig = 0; cdig <= 9; cdig++) {
                for (int k = 0; k < arr[cdig]; k++) {
                    num2 = num2 * 10 + cdig;
                }
            }
            if (num2 > b) {
                return false;
            }

            long cnum = 0;
            for (int cdig = r[pt]; cdig >= l[pt]; cdig--) {
                if (arr[cdig] > 0) {
                    arr[cdig]--;
                    if (cdig == l[pt]) {
                        long c1 = cnum * 10 + cdig;
                        for (int dd = 9; dd >= 0; dd--) {
                            for (int k = 0; k < arr[dd]; k++) c1 = c1 * 10 + dd;
                        }
                        if (c1 < a) {
                            arr[cdig]++;
                            return false;
                        }
                    }
                    arr[cdig]++;
                    return true;
                }
            }
            return false;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

    }

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

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

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException var2) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public long nextLong() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            long res = 0L;

            while (c >= 48 && c <= 57) {
                res *= 10L;
                res += (long) (c - 48);
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * (long) sgn;
                }
            }

            throw new InputMismatchException();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.nio.Buffer;
import java.util.*;

public class Pair {

    static class FastReader {
        private BufferedReader br;
        private StringTokenizer st;

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

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

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

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

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

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

    public static void main(String[] args) throws Exception {
        try {
            FastReader sc = new FastReader();
            int n = sc.nextInt();
            int[]arr = new int[n];
            for(int i=0;i<arr.length;i++){
                arr[i] = sc.nextInt();
            }
            int i=0;
            while(i<n-1 && arr[i]<arr[i+1]){
                i+=1;
            }
            while(i<n-1 && arr[i]==arr[i+1]){
                i+=1;
            }
            while(i<n-1 && arr[i]>arr[i+1]){
                i+=1;
            }
        }
        catch (Exception e) {
        }
    }
}


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

public class Solution{
    publuc static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int diploma = n/(2*(k+1));
        int certi = diploma*k;
        int non = n-diploma-certi;

        System.out.println(diploma+" "+certi+" "+non);
    }
}


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

public class Main
{
    static long mod=1000000007;
    public static void main(String[] args) throws Exception
    {
    	FastReader in=new FastReader();
    	PrintWriter pw=new PrintWriter(System.out);
    	int axmax=-101,axmin=101,aymax=-101,aymin=101;
    	int bxmax=-101,bxmin=101,bymax=-101,bymin=101;
    	int[][] c=new int[8][2];
    	for(int i=0;i<8;i++)
    	{
    		c[i][0]=in.nextInt();
    		c[i][1]=in.nextInt();
    		if(i>3)
    		{
    			c[i][0]=c[i][0]+c[i][1];
    			c[i][1]=c[i][1]-c[i][0];
    		}
    	}
    	for(int i=0;i<4;i++)
    	{

			axmin=Math.min(axmin,c[i][0]);
			axmax=Math.max(axmax,c[i][0]);
			aymin=Math.min(aymin,c[i][1]);
			aymax=Math.max(aymax,c[i][1]);
    	}
    	for(int i=4;i<8;i++)
    	{
			bxmin=Math.min(bxmin,c[i][0]);
			bxmax=Math.max(bxmax,c[i][0]);
			bymin=Math.min(bymin,c[i][1]);
			bymax=Math.max(bymax,c[i][1]);
    	}
    	String ans="NO";
    	for(int x=axmin;x<=axmax;x++)
    	{
    		for(int y=aymin;y<=aymax;y++)
    		{
    			if(bxmin<=x+y && x+y<=bxmax && bymin<=y-x && y-x<=bymax)
    				ans="YES";
    		}
    	}
    	pw.print(ans);
    	pw.flush();
    }

    public static long inverse(long a)
    {
    	long r=1,p=mod-2;
    	while(p>0)
    	{
    		if(p%2==1)
    		{
    			r*=a;
    			r%=mod;
    		}
    		p>>=1;
    		a=(a*a)%mod;
    	}

    	return r;
    }

}

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

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

class FastReader
{
    BufferedReader br;
    StringTokenizer st;

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

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

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

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


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

public class B{

	static int n;
	static char []s;
	static int [][][]memo;
	static int dp(int l,int r,int cnt) {
		if(l==r)
			return 1;
		if(l>r)
			return 0;
		if(memo[cnt][l][r]!=0)
			return memo[cnt][l][r];

		int ans=1+dp(l+1,r,1);
		for(int i=l+1;i<=r;i++)
			if(s[i]==s[l])
			{
				ans=Math.min(ans, dp(l+1,i-1,1)+dp(i,r,cnt+1));
			}
		return memo[cnt][l][r]=ans;

	}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		n=sc.nextInt();
		s=sc.next().toCharArray();
		memo=new int [n+1][n][n];
		out.println(dp(0, n-1, 1));

		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


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

/**
 *
 * @author Ala Abid
 */
public class A {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b= Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        int c = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        int[] t = new int[99999999];
        for(int i=b;i<99999998;i+=a){
            t[i]++;

        }
        for(int i=d;i<99999998;i+=c){
            t[i]++;
            if(t[i]==2) {
               System.out.println(i);return;
           }
        }

        System.out.println("-1");

    }

}


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

public class Bilet2 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        char[] c = in.next().toCharArray();

        int[] c1 = new int[3];
        int[] c2 = new int[3];

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

            c1[i] = c[i] - '0';
            c2[i] = c[5 - i] - '0';
        }

        int SumL = 0;
        int SumR = 0;

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

            SumL += c1[i];
            SumR += c2[i];
        }

        int[] min = new int[3];
        int[] max = new int[3];

        int dif;

        if (SumL > SumR){

            dif = SumL - SumR;
            max = c1;
            min = c2;
        }
        else {
            dif = SumR - SumL;
            max = c2;
            min = c1;
        }

        Arrays.sort(max);
        Arrays.sort(min);

        int tempDif = dif;

        int maxCount = 0;
        int minCount = 0;

        int index = 2;

        while (tempDif >= 0){

            tempDif -= max[index];
            maxCount++;
            index--;
        }

        tempDif = dif;
        index = 0;
        while (tempDif >= 0){

            tempDif -= (9 - min[index]);
            minCount++;
            index++;
        }

        if (minCount < maxCount)
            System.out.println(minCount);
        else
            System.out.println(maxCount);
    }
}


// package cf948;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.*;

public class CFB {
    private static final String INPUT = "994009";

    FastScanner sc;
    int[] primes;

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

    public void run() {
        sc = new FastScanner(oj ? System.in : new ByteArrayInputStream(INPUT.getBytes()));

        long s = System.currentTimeMillis();
        solve();
        System.out.flush();
        tr(System.currentTimeMillis() - s + "ms");
    }

    public void solve() {
        int x2 = sc.nextInt();

        createPrimes(x2/2);
//        System.out.println(Arrays.toString(primes));

        int maxp2 = getMaxp(x2);
//        System.out.println(maxp2);
//        if (1==1) return;

        int best = x2;
        for (int i = 1; i < maxp2; i++) {
            int x1 = x2 - i;
            int maxp1 = getMaxp(x1);
            if (maxp1 == 0) {
                best = Math.min(best, x1);
                continue;
            }

            best = Math.min(best, x1 - maxp1 + 1);
        }
        System.out.println(best);
    }

    private int getMaxp(int x2) {
        int maxp = 0;
        for (int prime : primes) {
            if (x2 % prime == 0) {
                return prime;
            }
        }
        return maxp/* != 0 ? maxp : x2*/;
    }

    private void createPrimes(int n) {
        Set<Integer> primes = new TreeSet<>();
        OUT: for (int i = 2; i <= n; i++) {
            int sqrt = (int) Math.sqrt(i);
            for (int prime : primes) {
                if (prime > sqrt) break;
                if (i % prime == 0) continue OUT;
            }
            primes.add(i);
        }

        this.primes = new int[primes.size()];
        int i = primes.size();
        for (int prime: primes) {
            this.primes[--i] = prime;
        }
    }

    //********************************************************************************************
    //********************************************************************************************
    //********************************************************************************************

    private static int ceil(double d) {
        int ret = (int) d;
        return ret == d ? ret : ret + 1;
    }

    private static int round(double d) {
        return (int) (d + 0.5);
    }

    private static int gcd(int a, int b) {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }

    private static long gcd(long a, long b) {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.longValue();
    }

    private int[] readIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = sc.nextInt();
        }
        return res;
    }

    private long[] readLongArray(int n) {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = sc.nextLong();
        }
        return res;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        FastScanner(InputStream stream) {
            this.stream = stream;
        }

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

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

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

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

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

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

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

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

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void tr(Object... o) {
        if (!oj) System.out.println(Arrays.deepToString(o));
    }
}


import java.util.Scanner;

public class Bus {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int B = scn.nextInt();
		int f = scn.nextInt();
		int k = scn.nextInt();
		int dir = 1;
		int jcnt = 0, fcnt = 0;
		int i = 0, b = B;
		while(jcnt < k) {
			if(i == f) {
				if(dir == 1 && (jcnt == k-1 && b < a-f) || ( jcnt < k-1 && b < (a-f)*2)) {
					b = B;
					fcnt++;
				} else if(dir == -1 && (jcnt == k-1 && b < f) || ( jcnt <k-1 && b < f*2)) {
					b = B;
					fcnt++;
				}
			}
			b -= 1;
			i += dir;
			if(i == a) {
				jcnt++;
				dir = -1;
			} else if (i == 0) {
				jcnt++;
				dir = 1;
			}
			if(b < 0) {
				fcnt = -1;
				break;
			}
		}
		System.out.println(fcnt);
	}

}


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

public class A2j {

    public static void main(String[] args) {

     Scanner sc=new Scanner(System.in);
 int n=sc.nextInt();
 int m=sc.nextInt();
 int count=0;
 if(n==m){System.out.println("0");}
else if(n>m||m<(n*2)&&m<(n*3)){System.out.println("-1");}
 else{
  int res=0;
  int dp[]=new int[m+1];
  Arrays.fill(dp, -1);

      if(  culc(m, dp, res, n)<0){System.out.println("-1");}
      else{System.out.println(culc(m, dp, res, n));}

    }

    }
    public static int culc(int m,int dp[],int res,int n) {
        if(m ==n){return 0;}
        if(dp[n] !=-1){return dp[n];}
        res=Integer.MIN_VALUE;
        if((n*2)<=m){res=Math.max(res, culc(m, dp, res, n*2)+1);}
        if((n*3)<=m){res=Math.max(res, culc(m, dp, res, n*3)+1);}
        return dp[n]=res;
    }
}


import java.util.Scanner;
public class MagicNumbers {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        String number=input.next();
        String [] num=number.split("");
        boolean m=true;

        for(int i=0;i<number.length();i++)
        {

            if(!(num[i+1].matches("1") || num[i+1].matches("4")))
            {
                m=false;
                break;
            }
            if(number.contains("444"))
            {
                m=false;
                break;
            }
        }
        if(m)
        System.out.println("YES");
        else
            System.out.println("NO");
    }
}


import java.io.*;

public class Middle{
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nk = br.readLine().split(" ");
        int N = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);
        total = (k-1<N-k)? 3*N+k-1:4*N-k;
        System.out.println(total);

    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
static int source;
static int sink;
static int t;
static int d;
static Queue<Node> q;

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

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = new StringTokenizer(br.readLine());
	source = Integer.parseInt(st.nextToken());
	sink = Integer.parseInt(st.nextToken());
	st = new StringTokenizer(br.readLine());
	t = Integer.parseInt(st.nextToken())-2;
	d = Integer.parseInt(st.nextToken());
	System.out.println(bfs());
}

static boolean valid(int f){
	if(f==sink) return true;
	for(int i=0;i<=d;i++){
		if(f<sink&&f+d==sink||f>sink&&f-d==sink) return true;
	}
	return false;
}
static int bfs(){
	q = new LinkedList();
	int max = -1;
	q.add(new Node(source,0,source));
	while(!q.isEmpty()){
		Node v = q.remove();
		if(v.steps==t){
			if(valid(v.w)){

				if(v.sum>max) max = v.sum;
			}
		}
		else{

			for(int i=0;i<=d;i++){
				q.add(new Node(i+v.w,v.steps+1,v.sum+(i+v.w)));
				if(v.w-i>0)q.add(new Node(v.w-i,v.steps+1,v.sum+(i+v.w)));
			}
		}

	}
	return max+sink;
}

}

	 class Node{
		int steps;
		int w;
		int sum;

Node(int w, int steps,int sum){
			this.w=w;
			this.steps = steps;
			this.sum = sum;
		}
	}


/*
javac f.java && java f
*/

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

public class f {
	public static void main(String[] args) { new f(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	int n;
	long[] a;

	int MAX = 5001;
	int pcnt, pr[];
	int[][] vp, cs;
	boolean[] isnt;

	f() {
		pcnt = 0;
		isnt = new boolean[MAX];
		isnt[0] = true; isnt[1] = true;
		for (int i = 2; i < MAX; i++)
			if (!isnt[i]) {
				pcnt++;
				for (int j = (i << 1); j < MAX; j += i)
					isnt[j] = true;
			}
		pr = new int[pcnt]; pcnt = 0;
		for (int i = 0; i < MAX; i++)
			if (!isnt[i])
				pr[pcnt++] = i;

		/*
		long ops = 0, gap3 = 0;
		for (int i = 0; i < pcnt; i++) {
			long del = i == 0 ? 1 : pr[i] - pr[i - 1];
			out.printf("del = %d | p = %d%n", del, pr[i]);
			ops += (del * del * del);
			gap3 = max(gap3, del * del * del);
		}
		out.println("--> " + ops + " OW3 " + gap3);
		*/

		vp = new int[MAX][pcnt];
		for (int i = 2; i < MAX; i++)
			for (int j = 0; j < pcnt; j++) {
				int k = i;
				while (k > 0) {
					vp[i][j] += (k / pr[j]);
					k /= pr[j];
				}
			}
		cs = new int[MAX][pcnt + 1];
		for (int i = 2; i < MAX; i++)
			for (int j = 1; j <= pcnt; j++)
				cs[i][j] = vp[i][j - 1] + cs[i][j - 1];

		n = in.nextInt();
		a = new long[MAX];
		for (int i = 0; i < n; i++) {
			int x = in.nextInt();
			if (x == 0) x++;
			a[x]++;
		}
		long[] f = new long[MAX + 1];
		for (int i = 1; i <= MAX; i++)
			f[i] = f[i - 1] + a[i - 1];

		long[] dist = new long[MAX + 1];
		for (int i = 1; i <= MAX; i++)
			dist[i] = dist[i - 1] + a[i - 1] * cs[i - 1][pcnt];

		// F I X  T H I S
		long ans = dist[MAX];
		int l = 2, r;
		for (int i = 0; i < pcnt; i++) {
			r = i == pcnt - 1 ? MAX - 1 : pr[i + 1] - 1;
			// everybody outside this range of highest prime must travel to 1 first
			// then travel up to the lca we're trying at each step
			long blw = dist[MAX] - (dist[r + 1] - dist[l]);
			if (r == 5000) out.println(blw);
			// so when trying lca(j, k) we need to know how many primes are on in it
			// and how far every person in the range [l, r] will need to travel
			for (int x = r; x >= l; x--)
				for (int y = x; y >= l; y--) {
					// lca will be gotten as (pIDX, cnt)
					int[] lca = {-1, 0};
					for (int z = i; z >= 0; z--)
						if (vp[x][z] != vp[y][z]) {
							lca[0] = z;
							lca[1] = min(vp[x][z], vp[y][z]);
							break;
						}

					long up = lca[1] + cs[x][pcnt] - cs[x][lca[0] + 1];
					up *= (f[MAX] - f[r + 1] + f[l]);

					long abv = 0;
					for (int z = r; z >= l; z--) {
						if (x == z && y == z) continue;
						// given lca(x, y) = {w, cnt}
						// if we get to w add in prefix of other primes in a[z] * cs[w - 1]
						// add a[z] * [abs(cnt - cnt[z]) to abv
						// if we dont get to w before they differ
						// add a[z] * (diff to here + here up)
						for (int w = i; w >= lca[0]; w--) {
							if (w == lca[0]) {
								abv += a[z] * cs[z][w];
								abv += a[z] * abs(vp[z][w] - lca[1]);
								break;
							}
							if (vp[z][w] != vp[x][w]) {
								abv += a[z] * cs[z][w];
								abv += a[z] * abs(vp[z][w] - vp[x][w]);
								abv += a[z] * (cs[x][w] - cs[x][lca[0] + 1]);
								abv += a[z] * lca[1];
								break;
							}
						}
					}
					ans = min(ans, abv + blw + up);
				}
			l = r + 1;
		}

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

	int abs(int x) { if (x < 0) return -x; return x; }
	long abs(long x) { if (x < 0) return -x; return x; }
	int max(int x, int y) { if (x < y) return y; return x; }
	int min(int x, int y) { if (x > y) return y; return x; }
	long max(long x, long y) { if (x < y) return y; return x; }
	long min(long x, long y) { if (x > y) return y; return x; }
	int gcd(int x, int y) { while (y != 0) { x = y^(x^(y = x)); y %= x; } return x; }
	long gcd(long x, long y) { while (y != 0) { x = y^(x^(y = x)); y %= x; } return x; }
	long lcm(int x, int y) { long xy = x; xy *= y; return xy / gcd(x, y); }
	long lcm(long x, long y) { return (x * y) / gcd(x, y); }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }

		void intArr(int sz, int[] x) { for (int i = 0; i < sz; i++) x[i] = nextInt(); }
		void longArr(int sz, long[] x) { for (int i = 0; i < sz; i++) x[i] = nextLong(); }
		void doubleArr(int sz, double[] x) { for (int i = 0; i < sz; i++) x[i] = nextDouble(); }
	}
}


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

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

    static class TaskC {
        int mod = 998244353;

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

            long ans = 0;

            long[] _3pow = new long[(int) n + 1];

            _3pow[0] = 1;

            for (int i = 1; i <= n; i++) {
                _3pow[i] = 3 * _3pow[i - 1];
                _3pow[i] %= mod;
            }

            long[] ncr = new long[(int) n + 1];

            ncr[0] = 1;

            for (int i = 1; i <= n; i++) {
                ncr[i] = ncr[i - 1] * (n - (i - 1));
                ncr[i] %= mod;
                ncr[i] *= pow(i, mod - 2, mod);
                ncr[i] %= mod;
            }

            for (int i = 1; i <= n; i++) {
                long val = _3pow[i] * pow(3, n * (n - i), mod);
                val %= mod;
                val *= ncr[i];
                val %= mod;
                if (i % 2 == 0)
                    ans -= 2 * val;
                else
                    ans += 2 * val;
                ans %= mod;
            }

            for (int i = 0; i < n; i++) {
                long val1 = 3 * ncr[i];
                val1 %= mod;
                long val2 = 1 - pow(3, i, mod);
                val2 %= mod;
                long val3 = pow(val2, n, mod);
                val3 -= pow(-pow(3, i, mod), n, mod);
                val1 *= val3;
                val1 %= mod;
                if (i % 2 == 0)
                    ans -= val1;
                else
                    ans += val1;
                ans %= mod;
            }

            ans += mod;
            ans %= mod;
            out.println(ans);
        }

        long pow(long a, long p, int mod) {
            if (p == 0) {
                return 1;
            }

            long t = pow(a, p / 2, mod);

            if (p % 2 != 0) {
                return (((t * t) % mod) * a) % mod;
            } else {
                return (t * t) % mod;
            }
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

    }

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

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

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

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

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

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

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

        }

    }
}