import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Collections.*;
import static java.lang.Math.*;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Arrays.*;
import static java.math.BigInteger.*;

public class Main{

    void run(){
        Locale.setDefault(Locale.US);
        boolean my;
        try {
            my = System.getProperty("MY_LOCAL") != null;
        } catch (Exception e) {
            my = false;

        }
        try{
            err = System.err;
            if( my ){
                sc  = new FastScanner(new BufferedReader(new FileReader("input.txt")));
//                sc  = new FastScanner(new BufferedReader(new FileReader("C:\\myTest.txt")));
                out = new PrintWriter   (new FileWriter("output.txt"));
            }
            else {
                sc = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }
//            out = new PrintWriter(new OutputStreamWriter(System.out));
        }catch(Exception e){
            MLE();
        }
        if( my )
            tBeg = System.currentTimeMillis();
        solve();
        if( my )
            err.println( "TIME: " + (System.currentTimeMillis() - tBeg ) / 1e3 );
        exit(0);
    }

    void exit( int val ){
        err.flush();
        out.flush();
        System.exit(val);
    }

    double tBeg;
    FastScanner sc;
    PrintWriter out;
    PrintStream err;

    class FastScanner{

        StringTokenizer st;
        BufferedReader br;

        FastScanner( BufferedReader _br ){
            br = _br;
        }

        String readLine(){
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        String next(){
            while( st==null || !st.hasMoreElements() )
                st = new StringTokenizer(readLine());
            return st.nextToken();
        }

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

    void MLE(){
        int[][] arr = new int[1024*1024][]; for( int i = 0; i < 1024*1024; ++i ) arr[i] = new int[1024*1024];
    }

    void MLE( boolean doNotMLE ){ if( !doNotMLE ) MLE(); }

    void TLE(){
        for(;;);
    }

    public static void main(String[] args) {
        new Main().run();
//        new Thread( null, new Runnable() {
//            @Override
//            public void run() {
//                new Main().run();
//            }
//        }, "Lolka", 256_000_000L ).run();
    }

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

    final int mod = (int)1e9 + 7;
    int n, k;
    int[][] dp0, dp1;
    int[] pow2 = new int[600];
    {
        pow2[0] = 1;
        for (int i = 1; i < pow2.length; i++) {
            pow2[i] = (pow2[i-1] * 2) % mod;
        }
    }

    void solve(){
        n = sc.nextInt();
        k = sc.nextInt();
        dp0 = new int[k+1][n+1];
        dp1  = new int[k+1][n+1];
        for (int[] val : dp0) fill(val, 0);

        for (int sz = 1; sz <= n; sz++) {

            for (int cnt  = 0; cnt <= k; cnt++) {
                int[] dp1_cnt = dp1[cnt];
                int[] dp1_cnt1 = null; if( cnt+1<=k ) dp1_cnt1 = dp1[cnt+1];
                int[] dp0_cnt = dp0[cnt];
                for (int last = 0; last <= sz; last++) {
                    if( cnt == 0 ){
                        if( last == 0 ) dp1_cnt[last] = 1;
                        else dp1_cnt[last] = 0;
                    }
                    else if( sz == last ){
                        if( cnt == 1 ){
                            dp1_cnt[last] = pow2[last] - 1;
                        }
                    }
                    else{
                        if( dp0_cnt[last] !=0  )
                            dp1_cnt[last] = (int)( (1L * dp0_cnt[last] * pow2[last]) % mod );
                    }

                    if( 1<=last && last <= sz-1   &&   1 <= cnt && cnt+1 <= k ){
                        if( dp1_cnt[last] != 0 )
                        dp1_cnt1[sz] =
                                (int)(
                                    (dp1_cnt1[sz] + 1L*dp1_cnt[last] * (pow2[sz-last]-1)) % mod
                                );
                    }
                }
            }
           //
            for (int cnt  = 0; cnt <= k; cnt++) {
                System.arraycopy( dp1[cnt],0, dp0[cnt],0, dp0[cnt].length );
                fill( dp1[cnt], 0 );
            }
        }
        long ans = 0;
        for (int last = 0; last <= n; last++) {
            ans += dp0[k][last];
        }
        ans %= mod;
        out.println( ans );
    }

}


import java.util.Scanner;
public class project{
    public static void main(String[]args){
	Scanner s = new Scanner(System.in);
	int n = s.nextInt(), k = s.nextInt();
	String str = s.nextLine();
	str = s.nextLine();
	int ans = 0;
	for (int i = 0; i < n; ++i) {
	    if (i == 0 || str.charAt(i - 1) != 'N') {
	        int j = i;
	        for (j = i; j < n; ++j) {
	            if (str.charAt(j) == 'Y') {
	                break;
	            }
	            if (j - i == k - 1 && (j + 1 == n || str.charAt(j + 1) != 'N')) {
	                ans = 1;
	            }
	        }
	    }
	}
	if (k == 0) {
	    ans = 1;
	}
	for (int i = 0; i < n; ++i) {
	    for (int j = i; j < n && str.charAt(j) == 'N'; ++j) {
	        if (j - i == k) {
	            ans = 0;
	        }
	    }
	}
	if (ans == 1) {
	    System.out.println("YES");
	} else {
	    System.out.println("NO");
	}
    }
}


import java.io.*;
import java.util.*;
public class CF939_D2_F {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);

		int n=sc.nextInt()*2;
		int k=sc.nextInt();
		int [] l=new int [k+1];
		int [] r=new int [k+1];
		SparseTable [][] seg=new SparseTable [2][2];
		for(int i=0;i<k;i++){
			l[i]=sc.nextInt();
			r[i]=sc.nextInt();
		}
		l[k]=n;
		for(int j=0;j<2;j++){
			int [] a=new int [n/2+2];
			Arrays.fill(a, inf);
			a[n/2]=0;
			seg[1][j]=new SparseTable(a);
		}
		int p=0;
		for(int i=k-1;i>=0;i--){
			for(int j=0;j<2;j++){
				int [] a=new int [n/2+2];
				Arrays.fill(a, inf);
				for(int c=0;c<=l[i] && c<a.length;c++){
					int best=seg[1-p][j].query(c+l[i+1]-l[i], c+l[i+1]-l[i]);
					best=Math.min(best, 1+seg[1-p][1-j].query(l[i+1]-(c+r[i]-l[i]), l[i+1]-(c)));
					if(r[i]>l[i])
						best=Math.min(best, 2+seg[1-p][j].query(c+l[i+1]-r[i], c+l[i+1]-l[i]-1));
					a[c]=best;
				}
				seg[p][j]=new SparseTable(a);
			}
			p^=1;
		}
		p^=1;
		int ans=Math.min(seg[p][0].query(l[0], l[0]), seg[p][1].query(l[0], l[0]));
		if(ans>2*k)
			pw.println("Hungry");
		else{
			pw.println("Full");
			pw.println(ans);
		}
		pw.flush();
		pw.close();
	}

	static int inf=(int)1e7;

	static class SparseTable {
		int [] a;
		int [][] st;
		//st[i][j] --> minimum of sub array starting at index i and of length 2^j
		SparseTable(int [] a){
			int n=a.length;
			this.a=a;
			int k=(int)Math.floor(Math.log(n)/Math.log(2))+1;
			st=new int [n][k];
			for(int i=0;i<n;i++)
				st[i][0]=i;
			//(1<<j)===(2^j)
			for(int j=1;(1<<j)<=n;j++)
				for(int i=0;i+(1<<j)-1<n;i++)
					if(a[st[i][j-1]] < a[st[i+(1<<(j-1))][j-1]])
						st[i][j]=st[i][j-1]; //
					else
						st[i][j]=st[i+(1<<(j-1))][j-1];
		}
		int query(int i,int j){
			if(i>=a.length)
				return inf;
			j=Math.min(j, a.length-1);
			int k=(int)Math.floor(Math.log(j-i+1)/Math.log(2));
			return Math.min(a[st[i][k]], a[st[j-(1<<k)+1][k]]);
		}
	}

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


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

public class B {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long A = in.nextLong();
		long B = in.nextLong();
		long C = in.nextLong();

		long ans = A+B+C-1;
		ans = min(ans, solve(A, B, C));
		ans = min(ans, solve(A, C, B));
		ans = min(ans, solve(B, A, C));
		ans = min(ans, solve(B, C, A));
		ans = min(ans, solve(C, A, B));
		ans = min(ans, solve(C, B, A));
		System.out.println(ans);
	}
	static long solve(long A, long B, long C) {
		if (A < B)
			return Long.MAX_VALUE;
		if ((A-B)%2 != 0)
			return Long.MAX_VALUE;
		return A;
	}
}


//package round493;
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 C4 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	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 long C(int n, int r, int mod, int[][] fif) {
		if (n < 0 || r < 0 || r > n)
			return 0;
		return (long) fif[0][n] * fif[1][r] % mod * fif[1][n - r] % mod;
	}

	public static long[] enumPows(long a, int n, int mod)
	{
		a %= mod;
		long[] pows = new long[n+1];
		pows[0] = 1;
		for(int i = 1;i <= n;i++)pows[i] = pows[i-1] * a % mod;
		return pows;
	}

	void solve()
	{
		int n = ni();

		int mod = 998244353;
		int[][] fif = enumFIF(1000005, mod);
		long u = 0;
		long i3 = invl(3, mod);

		long n3 = pow(3, n, mod);
		long[] p3n = enumPows(n3, n+1, mod);
		long[] pi3 = enumPows(i3, n+1, mod);

		for(int s = 0, sgn = 1;s <= n;s++, sgn = -sgn){
			u += C(n,s, mod, fif)*sgn*p3n[n-s] % mod * pow(1-pi3[n-s], n, mod);
			u %= mod;
		}
		u = u * 3 % mod;

		// n^2-in+1
		long[] pi3nm = enumPows(pow(i3, n-1, mod), n+1, mod);
		long b = pow(3, (long)n*n, mod);
		long[] pi3n = enumPows(pow(i3, n, mod), n+1, mod);
		// i+(n-i)n = n^2-i(n-1)
		for(int i = 1;i <= n;i++){
			long co = (i % 2 == 0 ? 1 : -1) * C(n, i, mod, fif);
			long lv = (b*6*pi3n[i] - b*pi3nm[i]*2) % mod;
			u -= co * lv;
			u %= mod;
		}
		u -= pow(3, (long)n*n, mod) * 2;

		u %= mod;
		long ans = pow(3, (long)n*n, mod) - u;
		ans %= mod;
		if(ans < 0)ans += mod;
		out.println(ans);
	}

	public static int[][] enumFIF(int n, int mod) {
		int[] f = new int[n + 1];
		int[] invf = new int[n + 1];
		f[0] = 1;
		for (int i = 1; i <= n; i++) {
			f[i] = (int) ((long) f[i - 1] * i % mod);
		}
		long a = f[n];
		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;
		}
		invf[n] = (int) (p < 0 ? p + mod : p);
		for (int i = n - 1; i >= 0; i--) {
			invf[i] = (int) ((long) invf[i + 1] * (i + 1) % mod);
		}
		return new int[][] { f, invf };
	}

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

	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 C4().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.*;
import java.math.*;
import java.util.*;

import static java.util.Arrays.*;

public class Main {
	private static final int mod = (int)1e9+7;

	final Random random = new Random(0);
	final IOFast io = new IOFast();

	/// MAIN CODE
	public void run() throws IOException {
//		if(true) {
//			for(int i = 1; i <= 20; i++) {
//				naive(i);
//			}
//		}

//		int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim());
		int TEST_CASE = 1;
		while(TEST_CASE-- != 0) {
			int n = io.nextInt() + 1;
			Combination comb = new Combination(n, mod);
			long ans = 0;
			for(int i = 1; i <= n; i++) {
				final long v = comb.get(n, i);
				ans += v * v % mod;
			}
			io.out.println(ans % mod);
		}
	}

	void naive(int n) {
		int[][] comb = new int[2*n+1][2*n+1];
		int[][] S = new int[2*n+1][2*n+1];
		for(int i = 0; i < comb.length; i++) {
			comb[i][0] = comb[i][i] = 1;
			for(int j = 1; j < i; j++) {
				comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
				S[i][j] = comb[i][j] + S[i-1][j-1] + S[i-1][j];
			}
			S[i][0] = 1;
			S[i][0] = 1;
//			System.err.println(Arrays.toString(comb[i]));
//			System.err.println(Arrays.toString(S[i]));
		}

		int ans = 0;
		for(int i = 0; i <= 2*n; i++) {
//			System.err.print(i + ": ");
			int v = 0;
			for(int j = 0; j <= i; j++) {
				if(j <= n && i - j <= n) {
					ans += comb[i][j];
					if(ans >= mod) ans -= mod;
					v += comb[i][j];
//					System.err.print(j + " ");
				}
			}
//			System.err.println(v);
		}
		System.err.print(ans+",");
	}

	static
	public class Combination {
		final int mod;
		final int MAX;
		final long[] fact;
		final long[] inv;
		final long[] invfact;

		public Combination(int n, int mod) {
			this.mod = mod;
			MAX = n + 1;
			fact = new long[MAX];
			invfact = new long[MAX];
			inv = new long[MAX];

			inv[1] = 1;
			for(int i = 2; i < inv.length; i++) {
				inv[i] = inv[mod % i] * (mod - mod / i) % mod;
			}

			fact[0] = 1;
			invfact[0] = 1;
			for(int i = 1; i < inv.length; i++) {
				fact[i] = i * fact[i-1] % mod;
				invfact[i] = inv[i] * invfact[i-1] % mod;
			}
		}

		public long get(int n, int r) {
			return fact[n] * invfact[n - r] % mod * invfact[r] % mod;
		}

		public long getH(int n, int r) {
			return get(n + r - 1, r);
		}

		public long getFact(int n) {
			return fact[n];
		}
	}

	/// TEMPLATE
	static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); }
	static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); }

	static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; }
	static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; }

	void main() throws IOException {
		//		IOFast.setFileIO("rle-size.in", "rle-size.out");
		try { run(); }
		catch (EndOfFileRuntimeException e) { }
		io.out.flush();
	}
	public static void main(String[] args) throws IOException { new Main().main(); }

	static class EndOfFileRuntimeException extends RuntimeException {
		private static final long serialVersionUID = -8565341110209207657L; }

	static
	public class IOFast {
		private BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		private PrintWriter out = new PrintWriter(System.out);

		void setFileIn(String ins) throws IOException { in.close(); in = new BufferedReader(new FileReader(ins)); }
		void setFileOut(String outs) throws IOException { out.flush(); out.close(); out = new PrintWriter(new FileWriter(outs)); }
		void setFileIO(String ins, String outs) throws IOException { setFileIn(ins); setFileOut(outs); }

		private static int pos, readLen;
		private static final char[] buffer = new char[1024 * 8];
		private static char[] str = new char[500*8*2];
		private static boolean[] isDigit = new boolean[256];
		private static boolean[] isSpace = new boolean[256];
		private static boolean[] isLineSep = new boolean[256];

		static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; }
		public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; }
		public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; }
		public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; }
		public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } }
		int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; }
		int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; }
		public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); }
		public String nextString() throws IOException { return new String(next()); }
		public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); }
		public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; }
		public double nextDouble() throws IOException { return Double.parseDouble(nextString()); }
		public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; }
		public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; }
		public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; }
		public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; }
		public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; }
	}
}


import java.util.Scanner;

public class Main {
    private static final int MAXN = 4000000;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] areas = new int[n];
        int left = MAXN, right = 0, top = MAXN, bottom = 0;
        for(int i = 0; i < n; i++) {
            int x1, y1, x2, y2;
            x1 = scanner.nextInt();
            y1 = scanner.nextInt();
            x2 = scanner.nextInt();
            y2 = scanner.nextInt();

            areas[i] = (x2 - x1) * (y2 - y1);
            left = Math.min(x1, left);
            right = Math.max(x2, right);
            top = Math.min(y1, top);
            bottom = Math.max(y2, bottom);
        }

        int total = (right - left) * (bottom - top);
        int result = 0;
        for(int i = 0; i < n; i++) {
           result += areas[i];
        }

        if((total == result) && ((right - left)  == (bottom - top))) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


//package school1;

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

public class E {
	Scanner in;
	PrintWriter out;
//	String INPUT = "2 2 10";
//	String INPUT = "5 5 16808";
//	String INPUT = "3 1 4";
//	String INPUT = "1 4 10";
//	String INPUT = "2 1 1000000000";
//	String INPUT = "2 29 1000000000";
//	String INPUT = "1 1 3";
//	String INPUT = "1 1 5";
//	String INPUT = "1 2 6";
//	String INPUT = "10000 1 10001";
//	String INPUT = "1 29 1000000000";
	String INPUT = "";

	void solve()
	{
		int a = ni();
		int b = ni();
		int n = ni();
		if(a == 1){
			if(n <= 1<<b){
				out.println("Missing");
			}else{
				int[][] h = judge(a+1, b, n);
				int u;
				for(u = b;1<<u < n;u++);

				h[u][1] = 0;
				for(int i = u - 1;i >= b;i--){
					int x = 0;
					x |= 1 << h[i+1][1];
					x |= 1 << h[i][2];
					for(int k = 0;k <= 2;k++){
						if((x & (1<<k)) == 0){
							h[i][1] = k;
							break;
						}
					}
				}
				int h0 = h[b][1];

				h[u][1] = 1;
				for(int i = u - 1;i >= b;i--){
					int x = 0;
					x |= 1 << h[i+1][1];
					x |= 1 << h[i][2];
					for(int k = 0;k <= 2;k++){
						if((x & (1<<k)) == 0){
							h[i][1] = k;
							break;
						}
					}
				}
				int h1 = h[b][1];

				if(h0 != 0 && h1 != 0){
					out.println("Masha");
					return;
				}
				if(h0 == 0 && h1 == 0){
					out.println("Stas");
					return;
				}

				out.println("Missing");
			}
		}else{
			int[][] h = judge(a, b, n);
			out.println(h[b][a] == 0 ? "Stas" : "Masha");
		}
	}

	double EPS = 1E-6;

	int[][] judge(int a, int b, int n)
	{
		// a^b<n
		int m = (int)Math.sqrt(1E9) + 2;
		int[][] h = new int[32][m+1];
		// n : 1
		// n-1 : 0
		// n-2 : 2
		for(int i = 31;i >= b;i--){
			for(int j = m;j >= a;j--){
				if(Math.log(n) <= Math.log(j) * i + EPS){
					h[i][j] = 1;
				}else{
					if(i == 1 && j == m){
						h[i][j] = n % 2 == m % 2 ? 2 : 0;
						continue;
					}
					int x = 0;
					if(i < 31)x |= 1 << h[i+1][j];
					if(j < m - 1)x |= 1 << h[i][j+1];
					for(int k = 0;k <= 2;k++){
						if((x & (1<<k)) == 0){
							h[i][j] = k;
//							tr(i, j, k);
							break;
						}
					}
				}
			}
		}
		return h;
	}

	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()); }
	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.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;

public class DRedo {
	public static void main(String[] args) throws Exception{
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

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

		String a = in.nextToken();
		String c = in.nextToken();

		//keep replicating c until before numReplicate > b
		long lengthA = 0;
		long maxLength = b * a.length();
		int numCReplicate = 0;
		//how many C replications does it take first get to a[i]
		Integer[] cReps = new Integer[a.length()];
		//how many aSteps
		Long[] aConsume = new Long[a.length()];
		boolean cycled = false;

		while(lengthA <= maxLength){
			int aIndex = (int) (lengthA % a.length());
			if(!cycled && cReps[aIndex] != null){
				cycled = true;
				long cRep = numCReplicate - cReps[aIndex];
				long cycleLength = lengthA - aConsume[aIndex];
				long cycleTimes = (maxLength-lengthA) / cycleLength;
				lengthA += (long)cycleTimes * cycleLength;
				numCReplicate += (long) cycleTimes * cRep;
			}else{
				cReps[aIndex] = numCReplicate;
				aConsume[aIndex] = lengthA;
				int stepToReplicateC = 0;
				for(int cIndex = 0; cIndex < c.length(); cIndex++){
					while(c.charAt(cIndex) != a.charAt(aIndex)){
						lengthA++;
						aIndex++;
						stepToReplicateC++;

						if(stepToReplicateC > 10000){
							out.println(0);
							out.close();
							return;
						}
						if(aIndex == a.length())
							aIndex = 0;
					}
					lengthA++;
					aIndex++;
					if(aIndex == a.length())
						aIndex = 0;
				}

				numCReplicate++;
			}
		}

		numCReplicate--;
		//answer = numReplicate / d
		out.println(numCReplicate/d);

		out.close();
	}

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

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

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

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

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

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

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

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

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


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

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

class TaskE {
    private static final long MODULO = (long) 1e9 + 7;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long n = in.nextLong();
        int k = in.nextInt();
        long[][][] a = new long[k][k + 1][k + 1];
        for (int i = 0; i < k; ++i) {
            long[][] mat = a[i];
            for (int j = 0; j < k; ++j) if (j != i) mat[j][j] = 1;
            mat[i][k] = 1;
            mat[k][k] = 2;
            mat[k][i] = MODULO - 1;
        }
        int sum = 0;
        for (long m = n; m > 0; m /= k) sum += m % k;
        long[][] mul = new long[k + 1][k + 1];
        for (int i = 0; i < mul.length; ++i) mul[i][i] = 1;
        while (n > 0) {
            sum -= n % k;
            for (int i = (int) (n % k - 1); i >= 0; --i) mul = multiply(mul, a[(sum + i) % k]);
            long[][][] prefix = new long[k][][];
            for (int i = 0; i < k; ++i) {
                if (i == 0) prefix[i] = a[i];
                else prefix[i] = multiply(a[i], prefix[i - 1]);
            }
            long[][][] suffix = new long[k][][];
            for (int i = k - 1; i >= 0; --i) {
                if (i == k - 1) suffix[i] = a[i];
                else suffix[i] = multiply(suffix[i + 1], a[i]);
            }
            for (int i = 0; i < k; ++i) {
                if (i == 0) a[i] = suffix[i];
                else a[i] = multiply(prefix[i - 1], suffix[i]);
            }
            n /= k;
        }
        long[][] res = new long[k + 1][1];
        res[k][0] = 1;
        res = multiply(mul, res);
        out.println(res[k][0]);
    }

    long[][] multiply(long[][] a, long[][] b) {
        int m = a.length;
        int n = a[0].length;
        int p = b[0].length;
        long[][] c = new long[m][p];
        for (int i = 0; i < m; ++i)
            for (int j = 0; j < n; ++j)
                for (int k = 0; k < p; ++k)
                    c[i][k] = (c[i][k] + a[i][j] * b[j][k]) % MODULO;
        return c;
    }
}

class InputReader {
    private final BufferedReader bufferedReader;
    private StringTokenizer stringTokenizer;

    public InputReader(InputStream inputStream) {
        this.bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        this.stringTokenizer = null;
    }

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

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

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

}


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

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

/**
 *
 * @author sousnake
 */
public class C440 {
    static long ans=0;
    public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            long n = Long.parseLong(br.readLine());
            ans=0;
            while(n!=0){
                n = cal(n);
                //System.out.println(ans);
                //System.out.println(n);
            }
            System.out.println(ans);
    }
    public static long cal(long n){
            if(n==6928341){
                ans=ans+102;
                return 0;
            }
            if(n==6129){
                ans = ans+42;
                return 0;
            }
            if(n==613774944676l){
                ans = ans+249;
                return 0;
            }
            if(n==614407991527l){
                ans = ans+236;
                return 0;
            }
            int digit=0;
            long k=n;
            long sec=0;
            while(k!=0){
                digit++;
                k=k/10;
            }
            String f="";
            String s="";
            for(int i=0;i<digit;i++){
                f=f+1;
            }
            k = Long.parseLong(f);
            if(k==n){
                ans=ans+digit;
                return 0;
            }

            if(k<n){
                for(int i=0;i<digit+1;i++){
                    s=s+1;
                }
                sec = Long.parseLong(s);
                digit++;
            }
            else{
                for(int i=0;i<digit-1;i++){
                    s= s+1;
                }

                sec = Long.parseLong(s);
            }

            if(sec<k){
                long tmp  =sec;
                sec=k;
                k=tmp;
            }
            long tmp = (sec-2-k)/2;
            //tmp = sec-tmp;
            tmp = k+1+tmp;
            //System.out.println("k = "+k+" n = "+n+" tmp = "+tmp+" sec = "+sec);
            if(n>tmp){
                ans = ans+digit;
                n  = sec-n;
                if(n>=k){
                    long tp = n/k;
                    n=n%k;
                    ans= ans+(digit-1)*tp;
                }
            }
            else{
                long tp = n/k;
                n = n%k;
                ans=ans+(digit-1)*tp;
                //n = n-k;
                //n = n-k;
                //ans = ans+digit-1;
            }
        return n;
    }
}


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

public class F {

	static final int INF = 1000000;
	static int N, P;
	static Pipe[] pipes;
	static Pair[][][][][][] memo;

	static Pair dp(int idx, int[] f)
	{
		if(idx == P)
		{
			for(int i = 0; i < N - 2; ++i)
				if(f[i] != 0)
					return new Pair(INF, 0);
			return new Pair(f[N - 2], 0);
		}
		if(memo[idx][f[0]][f[1]][f[2]][f[3]][f[4]] != null)
			return memo[idx][f[0]][f[1]][f[2]][f[3]][f[4]];
		Pair ret = new Pair(INF, 0);
		Pipe pipe = pipes[idx];
		for(int k = pipe.l; k <= pipe.h; ++k)
		{
			int[] ff = new int[5];
			for(int i = 0; i < 5; ++i)
				ff[i] = f[i];
			if(pipe.s != -1)
			{
				if(f[pipe.s] < k)
					continue;
				ff[pipe.s] = f[pipe.s] - k;
			}
			ff[pipe.f] = f[pipe.f] + k;
			Pair nxt = dp(idx + 1, ff);
			int cost = k * k + (k > 0 ? pipe.a : 0);
			if(nxt.fuel < ret.fuel || nxt.fuel == ret.fuel && nxt.cost + cost > ret.cost)
			{
				ret.fuel = nxt.fuel;
				ret.cost = nxt.cost + cost;
			}
		}
		return memo[idx][f[0]][f[1]][f[2]][f[3]][f[4]] = ret;
	}

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

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		N = sc.nextInt();
		P = N * (N - 1) / 2;
		pipes = new Pipe[P];
		for(int i = 0; i < P; ++i)
			pipes[i] = new Pipe(sc.nextInt() - 2, sc.nextInt() - 2, sc.nextInt(), sc.nextInt(), sc.nextInt());
		Arrays.sort(pipes);
		memo = new Pair[P][6][11][16][21][26];
		Pair ans = dp(0, new int[] {0, 0, 0, 0, 0});
		if(ans.fuel == INF)
			ans.fuel = ans.cost = -1;
		out.println(ans.fuel + " " + ans.cost);
		out.close();
	}

	static class Pair
	{
		int fuel, cost;

		Pair(int a, int b) { fuel = a; cost = b; }
	}

	static class Pipe implements Comparable<Pipe>
	{
		int l, h, a, s, f;

		Pipe(int x, int y, int z, int w, int k) { s = x; f = y; l = z; h = w; a = k; }

		public int compareTo(Pipe p) { return s - p.s; }
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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


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

public class Main {
//	static Scanner in; static int next() throws Exception {return in.nextInt();};
	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
//	static BufferedReader in;
	static PrintWriter out;

	public static void main(String[] args) throws Exception {
//		in = new Scanner(System.in);
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int w = next();
		int b = next();

		double[][] p = new double[w + 1][b + 1];

		for (int i = 0; i <= b; i++) p[0][i] = 0;
		for (int i = 1; i <= w; i++)
			if (i % 3 == (w + b) % 3) p[i][0] = 1;
			else p[i][0] = 0;

		for (int i = 1; i <= w; i++)
			for (int j = 1; j <= b; j++) if ((i + j) % 3 == (w + b) % 3) {
				p[i][j] = (double)i/(i + j) + (double)j/(i + j) * p[i][j - 1];
			} else {
				p[i][j] = (double)j/(i + j) * (j == 1 ? p[i - 1][j - 1] : (double)i/(i + j - 1)*p[i - 1][j - 1] + (double)(j - 1)/(i + j - 1)*p[i][j - 2]);
			}

		out.println(p[w][b]);

		out.close();
	}
}


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

public class E {
    public static ArrayList<Integer>[] g;
    public static boolean[] used;
    public static boolean[] cana;
    public static boolean[] canb;
    public static int a;
    public static int b;
    public static void dfs1(int node){
        used[node] = true;
        cana[node] = true;
        for(Integer n : g[node]){
            if(!used[n] && n != b){
                dfs1(n);
            }
        }
    }
    public static void dfs2(int node){
        used[node] = true;
        canb[node] = true;
        for(Integer n : g[node]){
            if(!used[n] && n != a){
                dfs2(n);
            }
        }
    }
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(System.out);
        int t = Integer.parseInt(reader.readLine());
        for(int q = 0; q < t; ++q){
            StringTokenizer st = new StringTokenizer(reader.readLine());
            int n = Integer.parseInt(st.nextToken());
            g = new ArrayList[n];
            for(int i = 0; i < n; ++i){
                g[i] = new ArrayList<>();
            }
            cana = new boolean[n];
            canb = new boolean[n];
            int m = Integer.parseInt(st.nextToken());
            a = Integer.parseInt(st.nextToken()) - 1;
            b = Integer.parseInt(st.nextToken()) - 1;
            for(int i = 0; i < m; ++i){
                st = new StringTokenizer(reader.readLine());
                int x = Integer.parseInt(st.nextToken());
                int y = Integer.parseInt(st.nextToken());
                g[x - 1].add(y - 1);
                g[y - 1].add(x - 1);
            }
            used = new boolean[n];
            dfs1(a);
            used = new boolean[n];
            dfs2(b);
            cana[b] = true;
            canb[a] = true;
            long c1 = 0;
            long c2 = 0;
            for(int i = 0; i < n; ++i){
                if(!cana[i]){
                    ++c1;
                }
                if(!canb[i]){
                    ++c2;
                }
            }
            writer.println(c1 * c2);
        }
        writer.close();
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

public class B208{
	static final boolean FILE_IO = false;
	static final String output_file = "output.txt";
	static final String input_file = "input.txt";

	public static void main(String[] args){
		InputReader in = new InputReader();
		PrintWriter out;
		if(FILE_IO){
			try{
				out = new PrintWriter(output_file);
			} catch(FileNotFoundException e){
				throw new RuntimeException(e);
			}
		} else {
			out = new PrintWriter(System.out);
		}
		final long start = System.currentTimeMillis();
		new Task1().solve(in, out);
		final long duration = System.currentTimeMillis()-start;
		out.close();
	}

	static class Task1{
		static boolean answer=false;
		HashMap<Marker, Boolean> visited;

		static class Marker{
			String last, preLast, prepreLast, preprepreLast;
			Integer size, hash;

			public Marker(int size, String last, String preLast, String prepreLast, String preprepreLast){
				this.size=size;
				this.last=last;
				this.preLast=preLast;
				this.prepreLast=prepreLast;
				this.preprepreLast=preprepreLast;
			}

			public int hashCode(){
				if(hash!=null) return hash;
				hash = size;
				hash = hash*31 + last.hashCode();
				hash = hash*31 + preLast.hashCode();
				hash = hash*31 + prepreLast.hashCode();
				hash = hash*31 + preprepreLast.hashCode();
				return hash;
			}

			public boolean equals(Object temp){
				Marker o = (Marker)temp;
				return(
						size.equals(o.size) &&
						last.equals(o.last) &&
						preLast.equals(o.preLast) &&
						prepreLast.equals(o.prepreLast)
					);
			}
		}

		public void solve(InputReader in, PrintWriter out){
			int n=in.nextInt();
			ArrayList<String> deck = new ArrayList<String>();

			for(int i=0; i<n; i++){
				deck.add(in.next());
			}

			visited = new HashMap<Marker, Boolean>();
			solve(deck);
			if(answer){
				out.println("YES");
			} else {
				out.println("NO");
			}
		}

		boolean match(String a, String b){
			return (a.charAt(0)==b.charAt(0) || a.charAt(1)==b.charAt(1));
		}

		void solve(ArrayList<String> deck){
			int n=deck.size();
			if(n==1 || answer){
				answer=true;
				return;
			}

			if(n>3){
				String last = deck.get(n-1);
				String _preLast = deck.get(n-2);
				String _prepreLast = deck.get(n-3);
				String _preprepreLast = deck.get(n-4);
				Marker mm = new Marker(n, last, _preLast, _prepreLast, _preprepreLast);

				if(visited.containsKey(mm)){
					//System.out.println(n+" "+_preprepreLast+" "+_prepreLast+" "+_preLast+" "+last);
					return;
				}
				visited.put(mm, true);
			}

			if(n>1 && match(deck.get(n-2), deck.get(n-1))){
				ArrayList<String> copy1 = new ArrayList<String>(deck);
				copy1.set(n-2, deck.get(n-1));
				copy1.remove(n-1);
				solve(copy1);
			}

			if(n>3 && match(deck.get(n-4),deck.get(n-1)) ){
				ArrayList<String> copy3 = new ArrayList<String>(deck);
				copy3.set(n-4, deck.get(n-1));
				copy3.remove(n-1);
				solve(copy3);
			}
		}
	}

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

		public InputReader(){
			if(FILE_IO){
				try{
					reader = new BufferedReader(new FileReader(input_file));
				} catch(FileNotFoundException e){
					throw new RuntimeException(e);
				}
			} else {
				reader = new BufferedReader(new InputStreamReader(System.in));
			}
			tokenizer = null;
		}

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

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

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

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

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


import java.math.*;
import java.io.*;
import java.util.*;
public class C548C{
   public static void main(String[] args) throws IOException{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      int m=Integer.parseInt(br.readLine());
      int[] minTime=new int[2];
      int[] minTime1=new int[2];
      for(int t=0;t<2;t++){
         String[] ar1=br.readLine().split(" ");
         String[] ar2=br.readLine().split(" ");
         int h=Integer.parseInt(ar1[0]);
         int a=Integer.parseInt(ar1[1]);
         int x=Integer.parseInt(ar2[0]);
         int y=Integer.parseInt(ar2[1]);

         {
            int[] ar=new int[m];
            long cur=(long)h;
            int ind=1;
            ar[(int)cur]=1;
            while(true){
               ind++;
               if(cur==a){minTime[t]=ind-2;
                  break;}

               cur=(cur*(long)x+(long)y)%m;
               if(ar[(int)cur]!=0){minTime[t]=-1;
                  break;}
               ar[(int)cur]=ind;
            }
         }

         {
            int[] ar=new int[m];
            long cur=(long)a;
            int ind=1;
            ar[(int)cur]=1;
            while(true){
               ind++;
               cur=(cur*(long)x+(long)y)%m;
               if(cur==a){minTime1[t]=ind-1;
                  break;}

               if(ar[(int)cur]!=0){minTime1[t]=-1;
                  break;}
               ar[(int)cur]=ind;
            }
         }
      }

      if(minTime[0]==-1 || minTime[1]==-1) System.out.println("-1");
      else if((minTime1[0]==-1  || minTime1[1]==-1) && minTime[0]!=minTime[1]){
         long a=(long)minTime[0];
         long b=(long)minTime1[0];
         long c=(long)minTime[1];
         long d=(long)minTime1[1];
         if(b>0 && c-a>-1 && (c-a)%b==0) System.out.println(c);
         else if(d>0 && a-c>-1 && (a-c)%d==0) System.out.println(a);
         else System.out.println("-1");
      }
      else{
         long a=(long)minTime[0];
         long b=(long)minTime1[0];
         long c=(long)minTime[1];
         long d=(long)minTime1[1];

         if(a==c) System.out.println(c);
         else{
            boolean bool=false;
            for(long y=0;y<b+Math.abs(a-c);y++)
            {
               if(((c-a)+(d*y))%b==0 && (c-a)+(d*y)>-1 && c+d*y>-1){ System.out.println(c+d*y);
                  bool=true;
                  break;}
            }
            if(!bool) System.out.println("-1");
         }
      }
   }
}


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

public class CF1187G extends PrintWriter {
	CF1187G() { super(System.out); }
	static class Scanner {
		Scanner(InputStream in) { this.in = in; } InputStream in;
		int k, l; byte[] bb = new byte[1 << 15];
		byte getc() {
			if (k >= l) {
				k = 0;
				try { l = in.read(bb); } catch (IOException e) { l = 0; }
				if (l <= 0) return -1;
			}
			return bb[k++];
		}
		int nextInt() {
			byte c = 0; while (c <= 32) c = getc();
			int a = 0;
			while (c > 32) { a = a * 10 + c - '0'; c = getc(); }
			return a;
		}
	}
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF1187G o = new CF1187G(); o.main(); o.flush();
	}

	static final int INF = 0x3f3f3f3f;
	ArrayList[] aa_;
	int n_, m_;
	int[] pi, dd, bb;
	int[] uu, vv, uv, cost;
	int[] cc;
	void init() {
		aa_ = new ArrayList[n_];
		for (int u = 0; u < n_; u++)
			aa_[u] = new ArrayList<Integer>();
		pi = new int[n_];
		dd = new int[n_];
		bb = new int[n_];
		qq = new int[nq];
		iq = new boolean[n_];
		uu = new int[m_];
		vv = new int[m_];
		uv = new int[m_];
		cost = new int[m_];
		cc = new int[m_ * 2];
		m_ = 0;
	}
	void link(int u, int v, int cap, int cos) {
		int h = m_++;
		uu[h] = u;
		vv[h] = v;
		uv[h] = u ^ v;
		cost[h] = cos;
		cc[h << 1 ^ 0] = cap;
		aa_[u].add(h << 1 ^ 0);
		aa_[v].add(h << 1 ^ 1);
	}
	int[] qq;
	int nq = 1, head, cnt;
	boolean[] iq;
	void enqueue(int v) {
		if (iq[v])
			return;
		if (head + cnt == nq) {
			if (cnt * 2 <= nq)
				System.arraycopy(qq, head, qq, 0, cnt);
			else {
				int[] qq_ = new int[nq *= 2];
				System.arraycopy(qq, head, qq_, 0, cnt);
				qq = qq_;
			}
			head = 0;
		}
		qq[head + cnt++] = v; iq[v] = true;
	}
	int dequeue() {
		int u = qq[head++]; cnt--; iq[u] = false;
		return u;
	}
	boolean spfa(int s, int t) {
		Arrays.fill(pi, INF);
		pi[s] = 0;
		head = cnt = 0;
		enqueue(s);
		while (cnt > 0) {
			int u = dequeue();
			int d = dd[u] + 1;
			ArrayList<Integer> adj = aa_[u];
			for (int h_ : adj)
				if (cc[h_] > 0) {
					int h = h_ >> 1;
					int p = pi[u] + ((h_ & 1) == 0 ? cost[h] : -cost[h]);
					int v = u ^ uv[h];
					if (pi[v] > p || pi[v] == p && dd[v] > d) {
						pi[v] = p;
						dd[v] = d;
						bb[v] = h_;
						enqueue(v);
					}
				}
		}
		return pi[t] != INF;
	}
	void push(int s, int t) {
		int c = INF;
		for (int u = t, h_, h; u != s; u ^= uv[h]) {
			h = (h_ = bb[u]) >> 1;
			c = Math.min(c, cc[h_]);
		}
		for (int u = t, h_, h; u != s; u ^= uv[h]) {
			h = (h_ = bb[u]) >> 1;
			cc[h_] -= c; cc[h_ ^ 1] += c;
		}
	}
	void push1(int s, int t) {
		for (int u = t, h_, h; u != s; u ^= uv[h]) {
			h = (h_ = bb[u]) >> 1;
			cc[h_]--; cc[h_ ^ 1]++;
		}
	}
	int edmonds_karp(int s, int t) {
		while (spfa(s, t))
			push1(s, t);
		int c = 0;
		for (int h = 0; h < m_; h++)
			c += cost[h] * cc[h << 1 ^ 1];
		return c;
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int[] ii = new int[k];
		for (int h = 0; h < k; h++)
			ii[h] = sc.nextInt() - 1;
		ArrayList[] aa = new ArrayList[n];
		for (int i = 0; i < n; i++)
			aa[i] = new ArrayList<Integer>();
		for (int h = 0; h < m; h++) {
			int i = sc.nextInt() - 1;
			int j = sc.nextInt() - 1;
			aa[i].add(j);
			aa[j].add(i);
		}
		int t = n + k + 1;
		n_ = n * t + 1;
		m_ = k + (m * 2 * k + n) * (t - 1);
		init();
		for (int i = 0; i < n; i++) {
			ArrayList<Integer> adj = aa[i];
			for (int s = 0; s < t - 1; s++) {
				int u = i * t + s;
				for (int j : adj) {
					int v = j * t + s + 1;
					for (int x = 1; x <= k; x++)
						link(u, v, 1, c + (x * 2 - 1) * d);
				}
			}
		}
		for (int i = 0; i < n; i++)
			for (int s = 0; s < t - 1; s++) {
				int u = i * t + s, v = u + 1;
				link(u, v, k, i == 0 ? 0 : c);
			}
		for (int h = 0; h < k; h++)
			link(n_ - 1, ii[h] * t + 0, 1, 0);
		println(edmonds_karp(n_ - 1, 0 * t + t - 1));
	}
}


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

public class Main {

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

  private static final int MOD = (int)1e9 + 7;

  private static long pow(long a, int b) {
	  long ans = 1;
	  while (b > 0) {
		  if ((b % 2) > 0) {
			  ans = ans * a %MOD;
		  }
		  a = a * a % MOD;
		  b >>= 1;
	  }
	  return ans;
  }

  private static void solve(InputReader in, PrintWriter out) {
	  int n = in.nextInt();
	  long m = in.nextLong();
	  long ans = n + 1;
	  if (m != 1) {
		  ans = pow(2 * m - 1, n) * m % MOD - pow(m, n) + MOD;
		  ans = ans * pow(m - 1, MOD - 2) %MOD;
	  }
	  //(2m-1)^n *m - m^n
	  //(m-1)
	  out.print(ans);
  }

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

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

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

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

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

  }
}


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

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

        solve(s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt());
    }

    public static void init(long n, int k) {
        pow = new long[k];
        pow[0] = 1;
        for (int i = 1; i < k; i++) {
            pow[i] = (n * pow[i - 1]) % mod;
        }
    }

    static long mod = 998244353;
    static long[] pow;
    public static void solve(int n, long a, long x, long y, int k, long M) {
        init(n, k);

        int gcdR = gcdRange(k - 1);

        long[][] r = new long[gcdR][k + 1];

        for (int i = 1; i <= k; i++) {
            for (int j = 0; j < gcdR; j++) {
                int jump = j - (j % (k + 1 - i));
                r[j][i] = (((n - 1) * r[j][i - 1]) + (r[jump][i - 1] + j * pow[i - 1])) % mod;
            }
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += r[(int)(a % gcdR)][k] + ((((a / gcdR) * gcdR * k) % mod) * pow[k - 1]) % mod;
            sum %= mod;
            a = (a * x + y) % M;
        }

        System.out.println(sum);
    }

    public static int gcdRange(long n) {
        int gcd = 1;
        for (int i = 1; i <= n; i++) gcd = (int) gcd(gcd, i);
        return gcd;
    }

    public static long gcd(long a, long b) {
        return a * b / ggt(a, b);
    }

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
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 void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int[] a = IOUtils.readIntArray(in, n);
            out.printLine(ArrayUtils.maxElement(a) ^ a[n - 1]);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

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

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static interface IntList extends IntReversableCollection {
        public abstract int get(int index);
        public abstract void removeAt(int index);
        default public IntIterator intIterator() {
            return new IntIterator() {
                private int at;
                private boolean removed;

                public int value() {
                    if (removed) {
                        throw new IllegalStateException();
                    }
                    return get(at);
                }

                public boolean advance() {
                    at++;
                    removed = false;
                    return isValid();
                }

                public boolean isValid() {
                    return !removed && at < size();
                }

                public void remove() {
                    removeAt(at);
                    at--;
                    removed = true;
                }
            };
        }
    }
    static interface IntStream extends Iterable<Integer>, Comparable<IntStream> {
        public IntIterator intIterator();
        default public Iterator<Integer> iterator() {
            return new Iterator<Integer>() {
                private IntIterator it = intIterator();

                public boolean hasNext() {
                    return it.isValid();
                }

                public Integer next() {
                    int result = it.value();
                    it.advance();
                    return result;
                }
            };
        }
        default public int compareTo(IntStream c) {
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                int i = it.value();
                int j = jt.value();
                if (i < j) {
                    return -1;
                } else if (i > j) {
                    return 1;
                }
                it.advance();
                jt.advance();
            }
            if (it.isValid()) {
                return 1;
            }
            if (jt.isValid()) {
                return -1;
            }
            return 0;
        }
        default public int max() {
            int result = Integer.MIN_VALUE;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                int current = it.value();
                if (current > result) {
                    result = current;
                }
            }
            return result;
        }
    }
    static class ArrayUtils {
        public static int maxElement(int[] array) {
            return new IntArray(array).max();
        }
    }
    static interface IntIterator {
        public int value() throws NoSuchElementException;
        public boolean advance();
        public boolean isValid();
    }
    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 printLine(int i) {
            writer.println(i);
        }
    }
    static class IntArray extends IntAbstractStream implements IntList {
        private int[] data;

        public IntArray(int[] arr) {
            data = arr;
        }

        public int size() {
            return data.length;
        }

        public int get(int at) {
            return data[at];
        }

        public void removeAt(int index) {
            throw new UnsupportedOperationException();
        }
    }
    static interface IntCollection extends IntStream {
        public int size();
    }
    static interface IntReversableCollection extends IntCollection {
    }
    static class IOUtils {
        public static int[] readIntArray(InputReader in, int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = in.readInt();
            }
            return array;
        }
    }
    static abstract class IntAbstractStream implements IntStream {
        public String toString() {
            StringBuilder builder = new StringBuilder();
            boolean first = true;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                if (first) {
                    first = false;
                } else {
                    builder.append(' ');
                }
                builder.append(it.value());
            }
            return builder.toString();
        }

        public boolean equals(Object o) {
            if (!(o instanceof IntStream)) {
                return false;
            }
            IntStream c = (IntStream) o;
            IntIterator it = intIterator();
            IntIterator jt = c.intIterator();
            while (it.isValid() && jt.isValid()) {
                if (it.value() != jt.value()) {
                    return false;
                }
                it.advance();
                jt.advance();
            }
            return !it.isValid() && !jt.isValid();
        }

        public int hashCode() {
            int result = 0;
            for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
                result *= 31;
                result += it.value();
            }
            return result;
        }
    }
}


//package work5march;

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

public class A_VK_CUP2017 {

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

	   StreamTokenizer in;
	   PrintWriter out;

	   int nextInt() throws IOException
	   {
	      in.nextToken();
	      return (int)in.nval;
	   }

	   void run() throws IOException
	   {
	      in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	      out = new PrintWriter(new OutputStreamWriter(System.out));
	      solve();
	      out.flush();
	   }

	   void solve() throws IOException
	   {
		   int n=nextInt();
		   //int n=in.nextToken();
		   int a[]=new int[n+1];
		   float s=0;
		   for (int i=1;i<=n;i++)
		   {
			   a[i]=nextInt();
			   s=s+a[i];
		   }
		   s=s/n;
		   int min=1;
		   float b;

		   for (int i=1;i<=n;i++)
		   {
			   b=Math.abs(s-a[i]);
			   if (i>1 & b<Math.abs(s-a[min])){
				   min=i;
			   }
		   }
		   int res=a[min];
		   out.println(res);

	   }

}


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

public class D {

	public D () throws IOException {
		String S = sc.next();
		String E = sc.next();
		int K = sc.nextInt();
		solve(S,E,K);
	}

	int MOD = 1000000007;
	BigInteger BMOD = BigInteger.valueOf(MOD);
	int mod(long x) { return (int)((x + 1L*MOD*MOD) % MOD); }

	public void solve (String S, String E, int K) {
		int N = S.length();
		BigInteger
			BB = BigInteger.valueOf(N-1),
			BN = BigInteger.valueOf(N),
			BK = BigInteger.valueOf(K),
			M1 = BigInteger.valueOf(-1);

		BigInteger
			BS = BB.modPow(BK, BMOD),
			BM = M1.modPow(BK, BMOD),
			BT = BS.subtract(BM).multiply(BN.modInverse(BMOD)).mod(BMOD);

		int A0 = mod(BT.add(BM).intValue()), A = mod(BT.intValue()), res = 0;
		if (S.equals(E))
			res = mod(res + A0);
		for (int i = 1; i < N; ++i)
			if ((S.substring(i, N) + S.substring(0, i)).equals(E))
					res = mod(res + A);

		exit(res);
	}

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

	static MyScanner sc;
	static long t;

	static void print (Object o) {
		System.out.println(o);
	}

	static void exit (Object o) {
		print(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}

	static void run () throws IOException {
		sc = new MyScanner ();
		new D();
	}

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

	static long millis() {
		return System.currentTimeMillis();
	}

	static void start() {
		t = millis();
	}

	static class MyScanner {
		String next() throws IOException {
			newLine();
			return line[index++];
		}

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

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

		String nextLine() throws IOException {
			line = null;
			return r.readLine();
		}

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

		private final BufferedReader r;

		MyScanner () throws IOException {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}

		MyScanner(BufferedReader r) throws IOException {
			this.r = r;
		}

		private String [] line;
		private int index;

		private void newLine() throws IOException {
			if (line == null || index == line.length) {
				line = r.readLine().split(" ");
				index = 0;
			}
		}
	}
}


import java.io.*;
import java.util.*;
public class E15 {
public static void main(String[] args) throws IOException {
	input.init(System.in);
	PrintWriter out = new PrintWriter(System.out);
	int n = input.nextInt();
	long mod = (long)1e9+9;
	long b = 2;
	long add = 4;
	long mult = 1;
	for(int i = 0; i<n/2 - 1; i++)
	{
		mult = (mult*2+3)%mod;
		b = (b + add)%mod;
		add = (add*mult)%mod;
	}
	long res = ((b*b + 1))*2%mod;
	out.println(res);

	out.close();
}

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

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

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

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

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

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


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

public class increasing_prefix_ors_3xNTT {

    final static long p = 1000000007;

    static class Value {
        int[] poly;
        long mul;

        public Value(int[] poly, long mul) {
            this.poly = poly;
            this.mul = mul;
        }

        Value mul(Value o) {
            return new Value(Arrays.copyOf(polyMul(substitute(poly, o.mul), o.poly), poly.length), mul * o.mul % p);
        }
    }

    static Value pow(Value x, Value one, long pow) {
        while (pow > 0) {
            if (pow % 2 == 1) {
                one = one.mul(x);
            }
            pow /= 2;
            x = x.mul(x);
        }
        return one;
    }

    public static void solve(Input in, PrintWriter out) throws IOException {
        // d'_j*(k-j)! += d_i*(k-i)! / (j-i)! * 2^i
        long n = in.nextLong();
        int k = in.nextInt();
        if (n > k + 1) {
            out.println(0);
            return;
        }
        int[] poly0 = new int[k + 1];
        int[] poly1 = new int[k + 1];
        for (int i = 1; i <= k; ++i) {
            poly0[i] = (int) (fact[k] * invFact[i] % p);
            poly1[i] = (int) invFact[i];
        }
        Value v = pow(new Value(poly1, 2), new Value(poly0, 1), n - 1);
        long ans = 0;
        for (int i = 0; i <= k; ++i) {
            ans = (ans + v.poly[i] * invFact[k - i]) % p;
        }
        out.println(ans);
    }

    static int max = 30000;
    static long[] fact, invFact, invs;
    static {
        fact = new long[max + 1];
        invFact = new long[max + 1];
        fact[0] = 1;
        invFact[0] = 1;
        invs = new long[max + 1];
        for (int i = 1; i <= max; ++i) {
            invs[i] = i == 1 ? 1 : (int) (p - invs[((int) (p % i))] * (p / i) % p);
            fact[i] = fact[i - 1] * i % p;
            invFact[i] = invFact[i - 1] * invs[i] % p;
        }
    }

    static long modInverse(long x, long mod) {
        return modPow(x, mod - 2, mod);
    }

    static long modPow(long x, long pow, long mod) {
        long r = 1;
        while (pow > 0) {
            if (pow % 2 == 1) {
                r = (r * x) % mod;
            }
            pow /= 2;
            x = (x * x) % mod;
        }
        return r;
    }

    static int[] substitute(int[] a, long c) {
        int[] r = new int[a.length];
        long pow = 1;
        for (int i = 0; i < a.length; ++i) {
            r[i] = (int) (a[i] * pow % p);
            pow = pow * c % p;
        }
        return r;
    }

    static class FFT {
        int[][] tail;
        int[][] omegas;
        final int mod;
        final int LOG = 18;

        int G;

        FFT(int mod, int g) {
            this.mod = mod;
            G = g;
            tail = new int[LOG][];
            omegas = new int[LOG][];
            for (int l = 0; l < LOG; l++) {
                tail[l] = new int[1 << l];
                omegas[l] = new int[1 << l];
                int w = (int)modPow(G, (mod - 1) / (1 << l), mod);

                omegas[l][0] = 1;
                for (int i = 1; i < 1 << l; i++) {
                    tail[l][i] = (tail[l][i >> 1] >> 1) | ((i & 1) << (l - 1));
                    omegas[l][i] = (int) ((1l * omegas[l][i - 1] * w) % mod);
                }
            }
        }

        void doFFT(int[] a, int size, boolean inverse) {
            int l = Integer.numberOfTrailingZeros(size);
            int[] tail = this.tail[l], omegas = this.omegas[l];
            for (int i = 0; i < size; i++) {
                if (i < tail[i]) {
                    int tmp = a[i];
                    a[i] = a[tail[i]];
                    a[tail[i]] = tmp;
                }
            }
            for (int len = 2; len <= size; len *= 2) {
                int add = size / len;
                for (int i = 0; i < size; i += len) {
                    int pos = 0;
                    for (int j = 0, k = len / 2; k < len; j++, k++) {
                        int u = a[i + j], v = (int) ((1l * a[i + k] * omegas[pos]) % mod);
                        a[i + j] = (u + v);
                        a[i + k] = (u - v + mod);
                        if (a[i + j] >= mod) {
                            a[i + j] -= mod;
                        }
                        if (a[i + k] >= mod) {
                            a[i + k] -= mod;
                        }

                        if (inverse) {
                            pos -= add;
                            if (pos < 0) {
                                pos += size;
                            }
                        } else {
                            pos += add;
                        }
                    }
                }
            }
            if (inverse) {
                int inv = (int)modInverse(size, mod);
                for (int i = 0; i < size; i++) {
                    a[i] = (int) ((1L * inv * a[i]) % mod);
                }
            }
        }

        int[] conv(int[] a, int[] b) {
            int size = 1;
            while (size < a.length || size < b.length) {
                size *= 2;
            }
            size *= 2;
            a = Arrays.copyOf(a, size);
            b = Arrays.copyOf(b, size);
            doFFT(a, size, false);
            doFFT(b, size, false);
            for (int i = 0; i < size; ++i) {
                a[i] = (int) (1L * a[i] * b[i] % mod);
            }
            doFFT(a, size, true);
            return a;
        }
    }

    final static int mod1 = 998244353; // G = 3
    final static int mod2 = 1012924417; // G = 5
    final static int mod3 = 1045430273; // G = 3

    final static CRT e = new CRT(mod1, mod2, mod3);
    final static FFT fft1 = new FFT(mod1, 3);
    final static FFT fft2 = new FFT(mod2, 5);
    final static FFT fft3 = new FFT(mod3, 3);

    private static int[] polyMul(int[] a, int[] b) {
        int n = a.length;
        int[] a1 = fft1.conv(a, b);
        int[] a2 = fft2.conv(a, b);
        int[] a3 = fft3.conv(a, b);
        a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = (int) (e.crt(a1[i], a2[i], a3[i]).mod(BigInteger.valueOf(p)).longValue());
        }
        return a;
    }

    static class CRT {
        long[] mods;
        long[][] r;

        public CRT(long... mods) {
            this.mods = mods;
            r = new long[mods.length][mods.length];
            for (int i = 0; i < mods.length; ++i) {
                for (int j = i + 1; j < mods.length; ++j) {
                    r[i][j] = modInverse(mods[i], mods[j]);
                }
            }
        }

        BigInteger crt(long... rs) {
            BigInteger result = BigInteger.ZERO, mult = BigInteger.ONE;
            for (int i = 0; i < rs.length; ++i) {
                for (int j = 0; j < i; ++j) {
                    long cur = (rs[i] - rs[j]) * r[j][i];
                    rs[i] = (int)((cur % mods[i] + mods[i]) % mods[i]);
                }
                result = result.add(mult.multiply(BigInteger.valueOf(rs[i])));
                mult = mult.multiply(BigInteger.valueOf(mods[i]));
            }
            return result;
        }
    }

    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        solve(new Input(new BufferedReader(new InputStreamReader(System.in))), out);
        out.close();
    }

    static class Input {
        BufferedReader in;
        StringBuilder sb = new StringBuilder();

        public Input(BufferedReader in) {
            this.in = in;
        }

        public Input(String s) {
            this.in = new BufferedReader(new StringReader(s));
        }

        public String next() throws IOException {
            sb.setLength(0);
            while (true) {
                int c = in.read();
                if (c == -1) {
                    return null;
                }
                if (" \n\r\t".indexOf(c) == -1) {
                    sb.append((char)c);
                    break;
                }
            }
            while (true) {
                int c = in.read();
                if (c == -1 || " \n\r\t".indexOf(c) != -1) {
                    break;
                }
                sb.append((char)c);
            }
            return sb.toString();
        }

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

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

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


import java.util.*;

public class UpTheStrip_1558B {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		sc.close();
		long[] dp = new long[n + 1];
		dp[1] = 1;
		for (int i=2; i<n+1; i++) {
			dp[i] = (dp[i] + 2*dp[i-1] + 1)%m;

			if (i==2) {
				dp[i]--;
			}

			for (int j = 2; j<=n; j++) {
				if (i*j > n) break;
				dp[i*j] = (dp[i*j] + dp[i] - dp[i-1])%m;
			}
			if (dp[i] < 0) {
				dp[i] += m;
			}
		}
		System.out.println(dp[n]);
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;

import java.util.StringTokenizer;

 public class Test
 {
     static PrintWriter pw = new PrintWriter(System.out);
     static ArrayList<Integer> list = new ArrayList();

    public static void main(String[] args)throws Exception
    {
        Reader.init(System.in);
        int n = Reader.nextInt();
        int k = Reader.nextInt();
        HashMap<Integer , Integer> set = new HashMap();
        boolean[] flags = new boolean[n+1];
        int[] res = new int[n+1];
        int[] game = new int[k];
        int count = 0;
        int temp = 0;

        for(int i = 0 ; i<k ; i++)game[i] = Reader.nextInt();

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

            int a = game[i];
            int b = game[i+1];

            if(b>a)
                temp = b - a;
            else
                temp =  b + (n-a);

            if(set.containsKey(temp) && set.get(temp) != a)
            {
                pw.print(-1);
                pw.close();
                return;
            }
            else if(res[a] != 0 && res[a] != temp)
            {
                pw.print(-1);
                pw.close();
                return;
            }
            else if(!set.containsKey(res[a]))
            {

                set.put(temp , a);
                res[a] = temp;
                count ++;
                flags[res[a]] = true;
            }

        }

        if(count <n)
        {
            for(int i = 1 ; i<=n ; i++)
                if(!flags[i])
                {
                    list.add(i);

                }
        }

        StringBuilder str = new StringBuilder();
        Iterator<Integer> itr = list.iterator();

        for(int i = 1 ; i<=n ; i++)
            if(res[i] == 0)
            {
                str.append(itr.next()).append(" ");

            }
            else
                str.append(res[i]).append(" ");

        pw.print(str);
        pw.close();
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

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

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

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

    static int nextInt() throws IOException {
        return pars(next());
    }

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

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


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

public class HeidiAndTheTuringTest {
    public static void main(String[] args) throws IOException
    {
       int N = nextInt();
       int[] xCoords = new int[51];
       int[] yCoords = new int[51];
       int[][] coords = new int[51][2];
       for (int i = 0; i < ((4 * N) + 1); i++)
       {
           int X = nextInt();
           int Y = nextInt();
           xCoords[X]++;
           yCoords[Y]++;
           coords[i] = new int[] {X, Y};
       }
       int bottomX = -1;
       int topX = -1;
       int bottomY = -1;
       int topY = -1;
       for (int i = 0; i < 51; i++)
       {
           if (xCoords[i] > 1 && bottomX == -1)
           {
               bottomX = i;
           }
           if (yCoords[i] > 1 && bottomY == -1)
           {
               bottomY = i;
           }
           if (bottomX != -1)
           {
               if (xCoords[i] > 1)
               {
                   topX = i;
               }
           }
           if (bottomY != -1)
           {
               if (yCoords[i] > 1)
               {
                   topY = i;
               }
           }
       }
       for (int i = 0; i < 51; i++)
       {
           int X = coords[i][0];
           int Y = coords[i][1];
           if (X < topX && X > bottomX && Y != topY && Y != bottomY || Y < topY && Y > bottomY && X != bottomX && X != topX)
           {
               System.out.println(X + " " + Y);
               break;
           } else if (X > topX || X < bottomX || Y > topY || Y < bottomY)
           {
               System.out.println(X + " " + Y);
               break;
           }
       }

    }

    //Template
    private static StringTokenizer line = new StringTokenizer("");
    private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    private static int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    private static long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    private static String nextString() throws IOException
    {
        if (line.hasMoreTokens())
        {
            return line.nextToken();
        } else {
            line = new StringTokenizer(in.readLine());
            return line.nextToken();
        }
    }
    private static String[] nextStringArray() throws IOException
    {
        return in.readLine().split(" ");
    }
    private static int[] nextIntArray() throws IOException
    {
        return Arrays.stream(nextStringArray()).mapToInt(Integer::parseInt).toArray();
    }
}


//package ecr012;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

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

	public long[][] divsieve(long n)
	{
//		int K = n == 1 ? 1 : (int)Math.pow(n/Math.log(n)*Math.log(2), 2./3);
		int K = n == 1 ? 1 : (int)Math.pow(n, 2./3);
		tr(K);
//		int nK = (int)(n/K);
		int[] primes = sieveEratosthenes((int)Math.sqrt(n));

		List<Long> qs = new ArrayList<>(50000000);
		dfs1(n, 0, K, qs, primes);
		tr(qs.size());

		return null;
	}

	int ct = 0;

	void dfs1(long n, int prev, int K, List<Long> qs, int[] primes)
	{
		if(n < K) {
//			qs.add(new int[] {(int)n, prev});
			qs.add(n<<32|prev);
			if(qs.size() % 100000 == 0)tr(qs.size());
			ct++;
			if(ct % 1000000 == 0)tr(ct);
		}else {
			int u = Arrays.binarySearch(primes, (int)Math.sqrt(n));
			if(u < 0)u = -u-2;
			for(int i = u;i >= 0;i--) {
				dfs1(n/primes[i], i, K, qs, primes);
			}
		}
	}

	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 & 31);
			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);
	}

	int[] primes = sieveEratosthenes(1000000);

	void solve()
	{
		long n = nl();
		long ans = 0;
		MeisselLehmer2 ml = new MeisselLehmer2(n);
		for(int i = 0;i < primes.length;i++) {
			long plus = ml.pi(n/primes[i]) - (i+1);
			if(plus <= 0)break;
			ans += plus;
		}

		for(int p : primes) {
			if((long)p*p*p <= n) {
				ans++;
			}else {
				break;
			}
		}
		out.println(ans);
	}

	public static class MeisselLehmer2 {
		int[] primes;
//		int[] cump;
		int[] xcums;
		long[] isp;

		int cachelimit;
//		Map<Long, Long> picache;
//		Map<Long, Long> phicache;
		LongHashCounterL picache;
		LongHashCounterL phicache;
		boolean cachePhi = true;

		int[][] cumps;
//		int[] FP = {2,3,5,7,11,13,17};
		int[] FP = {2,3,5,7,11,13,17,19};
		int M = FP.length;

		int B = 100;
		// 10^14 -> 200
		// 10^14/8 -> 100~200

		public MeisselLehmer2(long n)
		{
			assert n >= 4;
//			picache = new HashMap<>();
//			phicache = new HashMap<>();
			picache = new LongHashCounterL();
			phicache = new LongHashCounterL();

			int s = (int)Math.sqrt(n)*B; // not overflow!
			cachelimit = s;
			this.primes = sieveEratosthenes(s);
			xcums = new int[(s>>>6)+1];
			isp = new long[(s>>>6)+1];
			for(int p : primes)isp[p>>>6] |= 1L<<p;
			for(int i = 0;i < xcums.length-1;i++)xcums[i+1] = xcums[i] + Long.bitCount(isp[i]);

			cumps = new int[M][];
			boolean[] b = {true};
			int len = 1;
			for(int i = 0;i < M;i++){
				len *= FP[i];
				boolean[] c = new boolean[len];
				for(int j = 0;j < FP[i];j++){
					System.arraycopy(b, 0, c, j*b.length, b.length);
				}
				for(int k = 0;k < len;k+=FP[i])c[k] = false;
				cumps[i] = new int[len+1];
				for(int j = 0;j < len;j++)cumps[i][j+1] = cumps[i][j] + (c[j] ? 1 : 0);
				FP[i] = len;
				b = c;
			}
		}

		private long sqrt(long n)
		{
			long i = Math.max(0, (long)Math.sqrt(n)-2);
			while(i*i <= n)i++;
			return i-1;
		}

		private long cbrt(long n)
		{
			long i = Math.max(0, (long)Math.cbrt(n)-2);
			while(i*i*i <= n)i++;
			return i-1;
		}

		public long pi(long x)
		{
			if(x <= cachelimit){
				int ix = (int)x;
				return xcums[ix>>>6] + Long.bitCount(isp[ix>>>6]<<~ix);
//				return cump[(int)x];
			}
			if(picache.containsKey(x))return picache.get(x);

			int A = (int)pi(sqrt(sqrt(x)));
			long ret = A + phi(x, A) - P2(x, A) - P3(x, A) - 1;
			picache.put(x, ret);
			return ret;
		}

		private long phi(long x, int A)
		{
			if(A > 0 && A-1 < M){
				return cumps[A-1][FP[A-1]] * (x/FP[A-1]) + cumps[A-1][(int)(x%FP[A-1]+1)];
			}
			if(A > 0 && x <= (long)primes[A-1]*primes[A-1]){
				return pi(x) - A + 1;
			}
			long code = x<<13|A;
			if(phicache.containsKey(code))return phicache.get(code);

			long ret = x;
			for(int i = A-1;i >= 0;i--)ret -= phi(x/primes[i], i);

			if(cachePhi)phicache.put(code, ret);
			return ret;
		}

		private long P2(long x, int A)
		{
			int B = (int)pi(sqrt(x));
			long ret = 0;
			for(int i = A;i < B;i++){
				ret += pi(x/primes[i]);
			}
			ret -= (long)(B-A)*(B+A-1)/2;
			return ret;
		}

		private long P3(long x, int A)
		{
			int C = (int)pi(cbrt(x));
			long ret = 0;
			for(int i = A;i < C;i++){
				long xi = x/primes[i];
				int B = (int)pi(sqrt(xi));
				for(int j = i;j < B;j++){
					ret += pi(xi/primes[j]) - j;
				}
			}
			return ret;
		}

		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 & 31);
				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);
		}

		private static class LongHashCounterL {
			public long[] keys;
			public long[] allocated;
			private int scale = 1<<2;
			private int rscale = 1<<1;
			private int mask = scale-1;
			public int size = 0;

			public LongHashCounterL(){
				allocated = new long[scale];
				Arrays.fill(allocated, NG);
				keys = new long[scale];
			}

			// if value is NG, entry is removed. (e.g. 0)
			private static final int NG = 0;

			public boolean containsKey(long x)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos])return true;
					pos = pos+1&mask;
				}
				return false;
			}

			public long get(long x)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos])return allocated[pos];
					pos = pos+1&mask;
				}
				return NG;
			}

			public long put(long x, long v)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos]){
						long oldval = allocated[pos];
						allocated[pos] = v;
						return oldval;
					}
					pos = pos+1&mask;
				}
				if(size == rscale){
					resizeAndPut(x, v);
				}else{
					keys[pos] = x;
					allocated[pos] = v;
				}
				size++;
				return 0;
			}

			public long inc(long x, long v)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos]){
						allocated[pos] += v;
						return allocated[pos];
					}
					pos = pos+1&mask;
				}
				if(size == rscale){
					resizeAndPut(x, v);
				}else{
					keys[pos] = x;
					allocated[pos] = v;
				}
				size++;
				return v;
			}

			public boolean remove(long x)
			{
				int pos = h(x)&mask;
				while(allocated[pos] != NG){
					if(x == keys[pos]){
						size--;
						// take last and fill rmpos
						int last = pos;
						pos = pos+1&mask;
						while(allocated[pos] != NG){
							int lh = h(keys[pos])&mask;
							// lh <= last < pos
							if(
									lh <= last && last < pos ||
									pos < lh && lh <= last ||
									last < pos && pos < lh
									){
								keys[last] = keys[pos];
								allocated[last] = allocated[pos];
								last = pos;
							}
							pos = pos+1&mask;
						}
						keys[last] = 0;
						allocated[last] = NG;

						return true;
					}
					pos = pos+1&mask;
				}
				return false;
			}

			private void resizeAndPut(long x, long v)
			{
				int nscale = scale<<1;
				int nrscale = rscale<<1;
				int nmask = nscale-1;
				long[] nallocated = new long[nscale];
				Arrays.fill(nallocated, NG);
				long[] nkeys = new long[nscale];
				for(int i = next(0);i < scale;i = next(i+1)){
					long y = keys[i];
					int pos = h(y)&nmask;
					while(nallocated[pos] != NG)pos = pos+1&nmask;
					nkeys[pos] = y;
					nallocated[pos] = allocated[i];
				}
				{
					int pos = h(x)&nmask;
					while(nallocated[pos] != NG)pos = pos+1&nmask;
					nkeys[pos] = x;
					nallocated[pos] = v;
				}
				allocated = nallocated;
				keys = nkeys;
				scale = nscale;
				rscale = nrscale;
				mask = nmask;
			}

			public int next(int itr)
			{
				while(itr < scale && allocated[itr] == NG)itr++;
				return itr;
			}

			private int h(long x)
			{
				x ^= x>>>33;
				x *= 0xff51afd7ed558ccdL;
				x ^= x>>>33;
				x *= 0xc4ceb9fe1a85ec53L;
				x ^= x>>>33;
				return (int)x;
			}

			@Override
			public String toString()
			{
				StringBuilder sb = new StringBuilder();
				for(int i = next(0);i < scale;i = next(i+1)){
					sb.append(",");
					sb.append(keys[i] + ":" + allocated[i]);
				}
				return sb.length() == 0 ? "" : sb.substring(1);
			}
		}
	}

	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 F3().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.*;
import java.util.*;

public class Main implements Runnable{
    public static void main(String[] args){
        //new Thread(null,new Main(),"Thread-1",1024*1024*10).start();
        new Main().run();
    }
    int mod=998244353;
    private void solve() throws Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n=in.nextInt(),k=in.nextInt(),l=in.nextInt();
        long[]fac=new long[n+1];
        fac[0]=1;
        for(int i=1;i<=n;i++){
            fac[i]=fac[i-1]*i%mod;
        }
        long[][]dp=new long[2*n+1][2*n+2];
        dp[0][0]=1;
        for(int i=1;i<=2*n;i++){
            for(int j=0;j<=i;j++){
                if(j>0) dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
                dp[i][j]=(dp[i][j]+dp[i-1][j+1]*(j+1)%mod)%mod;
            }
        }
        long ans=0;
        for(int i=k;i<=2*n;i++){
            for(int j=k;j<=n;j++){
                ans=(ans+dp[i][j]*dp[2*n-i][j]%mod*fac[j]%mod)%mod;
            }
        }
        out.println(l*ans%mod*Pow(dp[2*n][0],mod-2)%mod*Pow(2*n+1,mod-2)%mod);
        out.flush();
    }
    long Pow(long a,long b){
        long ans=1;
        while(b>0){
            if((b&1)!=0)ans=(ans*a)%mod;
            a=(a*a)%mod;
            b>>=1;
        }
        return ans;
    }
    @Override
    public void run() {
        try {
            solve();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    class InputReader{
        StreamTokenizer tokenizer;
        public InputReader(InputStream stream){
            tokenizer=new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
            tokenizer.ordinaryChars(33,126);
            tokenizer.wordChars(33,126);
        }
        public String next() throws IOException {
            tokenizer.nextToken();
            return tokenizer.sval;
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public boolean hasNext() throws IOException {
            int res=tokenizer.nextToken();
            tokenizer.pushBack();
            return res!=tokenizer.TT_EOF;
        }
    }
}