import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: piyushd
 * Date: 3/29/11
 * Time: 7:56 PM
 * To change this template use File | Settings | File Templates.
 */
public class TaskD {

    final int MOD = 1000000007;

    void run() {
        String start = next();
        String end = next();
        int K = nextInt();
        int N = start.length();

        if (K == 0) {
            if (start.equals(end)) {
                System.out.println(1);
            } else {
                System.out.println(0);
            }

            return;
        }

        long[] dp = new long[N];
        Arrays.fill(dp, 1);
        dp[0] = 0;

        for (int i = 1; i < K; i++) {
            long sum = 0;
            for (int j = 0; j < N; j++) sum += dp[j];
            sum %= MOD;

            for (int j = 0; j < N; j++) dp[j] = (sum - dp[j] + MOD) % MOD;
        }

        long ans = 0;
        String s1, s2;
        for (int i = 0; i < N; i++) {
            s1 = start.substring(0, i);
            s2 = start.substring(i);

            if (end.equals(s2.concat(s1))) {
                ans += dp[i];
                if (ans >= MOD) ans -= MOD;
            }
        }

        System.out.println(ans);
    }

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

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

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

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

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

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


import java.util.*;

public class JavaApplication8 {

    public static void main(String args[]){
        int kr=0,kg=0,ky=0,kb=0,count=0;
        Scanner input=new Scanner(System.in);
        String s=input.next();
        for(int i=0;i<s.length();i++){
            int k=i+4;
            if(k>s.length()){
                k=i-4;
            }
            if(s.charAt(i)=='!'){
                if(s.charAt(k)!='!'){
                    switch(s.charAt(k)){
                        case('R'):kr++;break;
                            case('G'):kg++;break;
                                case('Y'):ky++;break;
                                    case('B'):kb++;break;
                    }

                }
            }
        }
        System.out.println(kr+" "+kb+" "+ky+" "+kg);
    }

	}


import java.util.*;

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

        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = sc.nextLong();

        sc.nextLine();

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        if(a >= x) {
            a -= x;

            if((a+b) >= y) {
                int remainingGrapes = a+b+c - y;

                if(remainingGrapes >= c) {
                    System.out.println("YES");
                }
                else {
                    System.out.println("NO");
                }
            }
            else {
                System.out.println("NO");
            }
        }
        else {
            System.out.println("NO");
        }
    }
}


/**
 * Created by Alyssa Herbst on 9/11/2018 8:40 PM.
 */

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

import static java.lang.Math.*;

public class B {
    static StringBuilder sb;
    static int N;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        //Scanner sc = new Scanner(System.in);
        sb = new StringBuilder();
        int T = sc.nextInt();
        for (int i = 0; i < T; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            sb.append(a-b == 1 &&isPrime(a + a-1) ? "YES" : "NO").append('\n');
        }
        System.out.println(sb);
    }

    static boolean isPrime(long a) {

        for (int i = 0; i < primes.length && primes[i]*primes[i] <= a; i++) {
            if(a % primes[i] == 0) {
                return false;
            }
        }
        return true;
    }

    static int MAX = 1000000000;
    static long[] primes;

    static {
        primes = generatePrimes(MAX);
    }
    /* generate all prime numbers from 2..N, inclusive */
    static long [] generatePrimes(int N) {
        List<Long> primes = new ArrayList<Long>();
        boolean [] isPrime = sieve(N);
        for (int i = 0; i <= N; i++)
            if (isPrime[i])
                primes.add((long)i);
        long [] pa = new long[primes.size()];
        for (int i = 0; i < pa.length; i++)
            pa[i] = (long)primes.get(i);
        return pa;
    }
    /* returns boolean array a[] such that a[p] == true iff p is prime. */
    static boolean [] sieve(int N) {
        boolean [] a = new boolean[N+1];
        Arrays.fill(a, true);
        a[0] = a[1] = false;
        for (int p = 2; p * p <= N; p++)
            if (a[p]) {
                // Iterate through all multiples m of the prime and mark
                // them as not prime.
                for (int m = p * p; m <= N; m += p)
                    a[m] = false;
            }
        return a;
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(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 readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] readIntBrray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }

        long[] readLongBrray(int n) {
            long[] a = new long[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextLong();
            }
            return a;
        }
    }
}


import java.util.Scanner;
public class messMakers {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int cows[] = new int[n];
		input.close();
		for (int i = 0; i < n; i++) {
			cows[i] = i;
		}
		int j=n-1;
		for (int i = 0; i < k&&i<n; i++){
			int temp=cows[i];
			cows[i]=cows[j];
			cows[j]=temp;
			j--;

		}
		int mess=0;
		for (int i = 0; i < n-1; i++){
			for (int l = i+1; l < n; l++){
				if(cows[i]>cows[l]){
					mess++;
				}
			}

		}
		System.out.println(mess);
	}

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class BurglarAndMatches {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(;m>0;m--){
            int b = in.nextInt();
            int nb = in.nextInt();
            for(;b>0;b--){
                list.add(nb);
            }
        }
        Collections.sort(list);
        Collections.reverse(list);
        int sol=0;
        for(int i=0;i<n && i<list.size();i++){
            sol+=list.get(i);
        }
        System.out.println(sol);

    }
}


//package CodeForces;

import java.util.Scanner;

public class SquaresAndSegments {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		if(n==1)
		{
			System.out.println(2);
		}
		else
		{
			int arr[]=new int[n+1];
			arr[1]=2;
			int no=1;
			int index=2;
			while(index<arr.length)
			{
				int temp=arr[(int)Math.pow(no,2)];
				for(int j=0;j<no&&index<arr.length;j++)
				{
					arr[index]=temp+1;
					index=index+1;
				}
				for(int j=0;j<no&&index<arr.length;j++)
				{
					arr[index]=temp+2;
					index=index+1;
				}
				if(index<arr.length)
				{
					arr[index]=temp+2;
					index=index+1;
				}
				no++;
			}
//			for(int i=0;i<arr.length;i++)
//			{
//				System.out.print(arr[i]+" ");
//			}
			System.out.println(arr[arr.length-1]);
		}

	}

}


import java.util.*;

public class Solution {
    public static int[][] plane;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        plane = new int[n][n];
        int count = (new Double(Math.sqrt(n)).intValue());
        int prod = count * count;
        if (n == prod) {
            System.out.println(2 * count);
        } else if (prod + count >= n) {
            System.out.println(2 * count + 1);
        } else if (prod + 2 * count >= n) {
            System.out.println(2 * count + 2);
        }
        scan.close();
    }
}


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

public class DreamonSums {

    /**
     * @param args
     */

    public static void main(String[] args) throws Exception{
        // TODO Auto-generated method stub
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = new String[2];
        input = br.readLine().split(" ",2);
       BigInteger a = new BigInteger(input[0]);
       BigInteger b = new BigInteger(input[1]);

       BigInteger len = a.multiply(b.multiply(b));
       BigInteger i = BigInteger.ZERO;
       BigInteger sum = BigInteger.ZERO;
       BigInteger temp;
       BigInteger check;
       BigInteger modulo = new BigInteger("1000000007");
       while(i.compareTo(len) < 0)
       {
           if(i.mod(b).compareTo(BigInteger.ZERO) == 0)
           {
               i = i.add(BigInteger.ONE);
               continue;
           }
            check = i.divide(b).mod(i.mod(b));

            //if (i.divide(b).mod(i.mod(b)).compareTo(BigInteger.ZERO)!= 0) continue;
            temp = i.divide(b).divide(i.mod(b));
            if(temp.compareTo(a) <= 0 && temp.compareTo(BigInteger.ZERO) != 0 && check.compareTo(BigInteger.ZERO) == 0)
            {
                sum = sum.add(i).mod(modulo);
            }
            i = i.add(BigInteger.ONE);
       }

       System.out.println(sum);

    }

}


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

/**
 * Created by mdhawan on 6/23/2017.
 */
public class ViciousKeyboard
{
	public static void main(String args[])
	{
		BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));
		String s ="";

		try
		{
			StringTokenizer st = new StringTokenizer(br.readLine());
			s = st.nextToken();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

		int occurences = 0;
		boolean changed = false;
		int i = 0;
		while (i + 1 <= s.length() - 1)
		{
			if (changed == true && (s.charAt(i) == 'V' && s.charAt(i + 1) == 'K'))
			{
				occurences += 1;
				i = i + 2;
			}
			else if (changed == false && s.charAt(i) == 'K' && s.charAt(i + 1) == 'K')
			{
				changed = true;
				occurences += 1;
				i = i + 2;
			}
			else if (changed == false && s.charAt(i) == 'V' && s.charAt(i + 1) == 'K')
			{
				occurences += 1;
				i = i + 2;
			}
			else if (changed == false && s.charAt(i) == 'V' && s.charAt(i + 1) == 'V')
			{
				if (i - 1 >= 0 && s.charAt(i - 1) == 'V')
				{
					occurences += 1;
					changed = true;
					i += 1;
				}
			}
			else
				i += 1;
		}
		System.out.println(occurences);
		}

	}


import java.util.Scanner;
import java.util.StringTokenizer;

public class A2 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String  q = sc.nextLine();
		int m = count(q);
		System.out.println("Best: "+m);
		for (int i = 0;i < q.length();i++){
			char[] v = q.toCharArray();
			switch(q.charAt(i)){
			case 'V':
				v[i] = 'K';
				m = Math.max(m, count(String.valueOf(v)));
				break;
			case 'K':
				v[i] = 'V';
				m = Math.max(m, count(String.valueOf(v)));
				break;
			}
			//String r = v.toString();
			//System.out.println("Best: "+m);

		}
		System.out.println(m);
	}
	public static int count(String str){
		String findStr = "VK";
		int lastIndex = 0;
		int count = 0;

		while(lastIndex != -1){

		    lastIndex = str.indexOf(findStr,lastIndex);

		    if(lastIndex != -1){
		        count ++;
		        lastIndex += findStr.length();
		    }
		}
		return count;
	}
}


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

public class B_Div2_362 {
	public static void main(String[]arg)throws IOException
	{
		new B_Div2_362().solve();
	}
	public void solve()throws IOException
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String sciNot = in.readLine();
		char[]sn = sciNot.toCharArray();
		int indexPoint, indexE, e, i;
		indexPoint = sciNot.indexOf(".");
		indexE = sciNot.indexOf("e");
		e = Integer.parseInt(sciNot.substring(indexE+1, sciNot.length()));
		System.out.println(sciNot.subSequence(0, indexPoint)+getRealNumber(sn, e, indexPoint, indexE));
	}
	private String getRealNumber(char[]sn, int e, int ip, int ie)
	{
		String realNumber = "";
		int i = ip, size = sn.length-1;
		while(e > 0 && i < ie-1)
		{
			swap(sn, i, i+1);
			i++;
			e--;
		}
		for(i = ip; i < ie - 1; i++)
			realNumber += sn[i];
		if(e > 0)
		{
			while(e > 0)
			{
				realNumber += "0"; e--;
			}
		}
		else
		{
			if(sn[ie-1] != '.')
				realNumber += sn[ie-1];
		}
		return realNumber;
	}
	private void swap(char[]sn, int i, int j)
	{
		char tmp;
		tmp = sn[i];
		sn[i] = sn[j];
		sn[j] = tmp;
	}
}


import java.util.Scanner;

/**
 * 21/04/20
 * Created by Himanshu
 **/

public class IlyaAndBankAccount {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        if (n > 0) {
            System.out.println(n);
            return;
        }
        n = Math.abs(n);
        String st = "" + n;
        if (st.charAt(st.length()-1) > st.charAt(st.length()-2)) {
            System.out.println("-" + st.substring(0,st.length()-1));
        } else {
            System.out.println("-" + st.substring(0,st.length()-2) + st.substring(st.length()-1));
        }
    }
}


// package CodeForces;

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

public class Problem_712C {
	public static int get(int[]d1,int sum)
	{
		int[]d=d1.clone();
		if(d[2]==y)
		{
			return sum;
		}
//		if(sol[d[1]][d[2]]<=sum)
//			return sol[d[1]][d[2]];
		int x=Math.max(d[1]-d[0]+1,y);
		d[2]=x;
		Arrays.sort(d);
		return get(d,sum+1);
	}
	static int[][]sol;static int y;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		int x=sc.nextInt();y=sc.nextInt();
		sol=new int[x+1][x+1];
		int[]a=new int[3];
		Arrays.fill(a, x);int min=Integer.MAX_VALUE;
		while(a[0]>=y)
		{
			a[0]--;
			min=Math.min(min, get(a,0));
		}
		System.out.println(min+1);
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

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

	}
}


import java.util.Scanner;
/**
 * Created by Kafukaaa on 16/9/11.
 */
/*本题的要点：能用几个int解决的就不要用int[]*/
public class MemoryAndCrow {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int a, b = 0;
    for (int i = 0; i < n; i++) {
      a = scanner.nextInt();
      if (i > 0){
        System.out.print(a + b + " ");
      }
      b = a;
    }
    System.out.println(b);
  }
}


import java.io.*;
import java.lang.*;
import static java.lang.Math.*;
import java.lang.reflect.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.security.CodeSource;
import java.security.KeyStore;
import java.util.*;
import static java.util.Arrays.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;

// https://netbeans.org/kb/73/java/editor-codereference_ru.html#display
public class Main {
    //<editor-fold defaultstate="collapsed" desc="Your Fold Super Code">

    private void run() {
        Locale.setDefault(Locale.US);
        boolean oj = true;
        try {
            oj = System.getProperty("MYLOCAL") == null;
        } catch (Exception e) {
        }

        if (oj) {
            sc = new FastScanner(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
        } else {
            try {
                sc = new FastScanner(new FileReader("input.txt"));
                out = new PrintWriter(new FileWriter("output.txt"));
            } catch (IOException e) {
                MLE();
            }
        }
        solve();
        //if( oj )
        err.println("Time: " + (System.currentTimeMillis() - timeBegin) / 1e3);
        out.flush();
    }

    private void show(int[] arr) {
        for( int v : arr ) err.print( " " + v );
        err.println();
    }

    private boolean eq(String a, String b) {
        for( int i = 0; i < a.length(); ++i ){
            if( a.charAt(i) == '.' ) continue;
            if( b.charAt(i) == '.' ) continue;
            if( a.charAt(i) != b.charAt(i) )
                return false;
        }
        return true;
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStreamReader reader) {
            br = new BufferedReader(reader);
            st = new StringTokenizer("");
        }

        String next() {
            while (!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException ex) {
                    Main.MLE();
                }
            }
            return st.nextToken();
        }

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

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

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

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

    long timeBegin = System.currentTimeMillis();
    FastScanner sc;
    PrintWriter out;
    PrintStream err = System.err;

    // </editor-fold>

    void solve() {
        double n = sc.nextInt();
        double m = sc.nextInt();;
        out.printf( "%.10f\n", 1/n + (n-1)/n * (m-1) / (n*m-1) );
    }

}


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

public class C {

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

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		long allPairs = (long) n * m * (n * m - 1);
		long goodPairs = (long) n * m * (m - 1);
		double p2 = 1.0 * goodPairs / allPairs;
		out.println(1.0 / n + (n - 1.0) / n * p2);
	}

	C() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

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

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

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

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

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

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


import java.util.Scanner;
public class Illyaandthebank {
   public static void main(String[] args) {

    long l=new Scanner(System.in).nextLong();
    if(l>=0)
    System.out.println(l);
    else//l<0
    {
        long l1,l2;
        l1=l/10;
        l2=(l/100)*10+l%10;
        System.out.println(l1+" "+l2);
        System.out.println(l1>l2?l1:l2);    }
}
}


import java.util.Scanner;

public class CircleMetro {
    static int n,x,a,y,b;

  public static void main(String args[])
     {
      //System.out.println("Enter numbers");
      Scanner in = new Scanner(System.in);
       n = in.nextInt();
       a = in.nextInt();
       x = in.nextInt();
       b = in.nextInt();
       y = in.nextInt();
      int c = 0;
     while(c!=1){
         if (a==b){
    System.out.println("YES");
     break;
     }
     if (a == x || b == y){
     System.out.println("NO");
     break;
     }

     else if(a != n && b != 1){
     a=a + 1;
     //System.out.println("Change A ="+ a);
     b=b-1;
     //System.out.println("Change  B = " + b);
     }
     else if(a == n ){
     a = 1;
     b =b-1;}
     else if(b == 1 ){
      b = n;
      a =a+1;
     }


import java.io.*;
import java.util.*;
public class btrip
{
    public static void main(String[] args) throws java.io.IOException
    {
	BufferedReader a=new BufferedReader(new InputStreamReader(System.in));
	int k=Integer.parseInt(a.readLine());
	String b=a.readLine();
	String[] c=b.split(" ");
	int[] d=new int[12];
	List<Integer> list = new ArrayList<Integer>();
	for(int i=0;i<12;i++)
	    list.add(Integer.parseInt(c[i]));
	int sum=0;
	int count=0;
	while(sum<k)
	{
	    int max=list.get(0);
	    int maxindex=0;
	    for(int j=0;j<12;j++)
	    {
		if(list.get(j)>max)
		{
		    max=list.get(j);
		    maxindex=j;
		}
	    }
	    sum=sum+max;
	    list.set(maxindex,0);
	    count++;
	}
	System.out.println(count);
    }
}


import java.io.*;
import java.math.BigInteger;
public class flags{
public static int mod = 1000000007,modi = (mod+1)>>1;
public static BigInteger modB = new BigInteger("1000000007");
public static BigInteger modiB = new BigInteger("500000004");
public static long id[][] ={{1,0,0,0,0,0,0},{0,1,0,0,0,0,0},{0,0,1,0,0,0,0},{0,0,0,1,0,0,0},{0,0,0,0,1,0,0},{0,0,0,0,0,1,0},{0,0,0,0,0,0,1}};
public static long a[][] = {{1,0,0,0,0,0,0},{1,0,0,0,0,0,0},{1,1,0,0,1,1,0},{1,1,0,0,1,0,1},{1,0,1,1,0,0,0},{0,0,1,0,0,0,0},{0,0,0,1,0,0,0}};//adyacencia aut
public static void main(String args[]) throws IOException{
BufferedReader lector= new BufferedReader(new InputStreamReader(System.in));
//for(int n = Integer.parseInt(args[0]);n<1000000001;n++)
String tmp = lector.readLine();
int n2 = Integer.parseInt(tmp.substring(0,tmp.indexOf(" ")))-1;
int n1 = Integer.parseInt(tmp.substring(tmp.indexOf(" ")+1));
BigInteger un = f(a,n1);
BigInteger dos = f(a,n1/2+(n1&1));
un = ((un.subtract(dos).multiply(modiB)).add(dos)).mod(modB);
BigInteger un1 = f(a,n2);
BigInteger dos1 = f(a,n2/2+(n2&1));
un1 = ((un1.subtract(dos1).multiply(modiB)).add(dos1)).mod(modB);
BigInteger joder = un.subtract(un1);
System.out.println(joder);
}
public static BigInteger f(long a[][],int n){
long p[][] = exp(a,n);
BigInteger res = BigInteger.ZERO;
int ri[] = {0,1,1,1,1,1,1};//terminales de cada nodo
for(int nn = 0;nn<p.length;nn++)res=(res.add(new BigInteger(""+p[nn][0]).multiply(new BigInteger(""+ri[nn])))).mod(modB);
return res.mod(modB);
/*
//if((n&1)==1){
p = exp(a,n/2+1);
int r[] = {0,1,1,1,1,1,1};
//int r[] = {4,2,2,2,2,1,1};//terminales de cada nodo
BigInteger res2 = BigInteger.ZERO;
for(int nn = 0;nn<p.length;nn++)res2=(res2.add(new BigInteger(""+p[nn][0]).multiply(new BigInteger(""+r[nn])))).mod(modB);
return (((res.subtract(res2)).multiply(modiB)).mod(modB).add(res2)).mod(modB);
//}
//return (res.multiply(modiB)).mod(modB);
*/
}
public static long[][] mul(long[][] a,long[][] b){
long res[][] = new long[a.length][b[0].length];
for(int n = 0;n<res.length;n++)
for(int m = 0;m<res[n].length;m++){
long tal = 0;
for(int x = 0;x<res[0].length;x++)
tal = (tal+a[n][x]*b[x][m])%mod;
res[n][m]=tal;
}
return res;
}
public static long[][] exp(long[][] a,int b){
if(b==0)
return id;
if(b==1)return a;
if((b&1)==0)
return exp(mul(a,a),b/2);
return mul(exp(mul(a,a),b/2),a);
}
}


import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class CofeForces {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long n = in.nextLong(), m = in.nextLong(), a = in.nextLong(), b = in.nextLong();
        a--;
        b--;
        int ans = -1;
        if (a / m == b / m) ans = 1; else {
            a = a%m;
            if (a == 0 && b%m == (m-1)) ans = 1;
            else if (a == 0 && b == n-1) ans = 1;
            else if (a == 0 || b%m == (m-1) || b == n-1) ans = 2;
            else if ((a%m) == (b%m)+1) ans = 2;
            else ans = 3;
        }

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

}


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

public class CF {

	void realSolve() {
		int n = in.nextInt();
		int h = in.nextInt();
		long[][] dp = new long[n + 1][n + 1];
		dp[1][1] = 1;
		dp[0][0] = 1;
		for (int cn = 2; cn <= n; cn++) {
			for (int curH = 1; curH <= n; curH++) {
				for (int id  = 1; id <= cn; id++) {
					long cur = 1;
					long v1 = 0, v2 = 0;
					for (int h1 = 0; h1 <= curH - 1; h1++) {
						v1 += dp[id - 1][h1];
						v2 += dp[cn - id][h1];
					}
					cur = v1 * dp[cn - id][curH - 1] + v2 * dp[id - 1][curH - 1] - dp[cn - id][curH - 1] * dp[id - 1][curH - 1];
					dp[cn][curH] += cur;
				}
			}
		}
		long res =0;
		for (int h1 = h; h1 <= n; h1++)
			res += dp[n][h1];
		out.println(res);
	}

	private class InputReader {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

	InputReader in;
	PrintWriter out;

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

		realSolve();

		out.close();
	}

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

		realSolve();

		out.close();

	}

	public static void main(String[] args) {
		new CF().solveIO();
	}
}import java.io.*;
import java.util.*;

public class CF {

	void realSolve() {
		int n = in.nextInt();
		int h = in.nextInt();
		long[][] dp = new long[n + 1][n + 1];
		dp[1][1] = 1;
		dp[0][0] = 1;
		for (int cn = 2; cn <= n; cn++) {
			for (int curH = 1; curH <= n; curH++) {
				for (int id  = 1; id <= cn; id++) {
					long cur = 1;
					long v1 = 0, v2 = 0;
					for (int h1 = 0; h1 <= curH - 1; h1++) {
						v1 += dp[id - 1][h1];
						v2 += dp[cn - id][h1];
					}
					cur = v1 * dp[cn - id][curH - 1] + v2 * dp[id - 1][curH - 1] - dp[cn - id][curH - 1] * dp[id - 1][curH - 1];
					dp[cn][curH] += cur;
				}
			}
		}
		long res =0;
		for (int h1 = h; h1 <= n; h1++)
			res += dp[n][h1];
		out.println(res);
	}

	private class InputReader {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

	InputReader in;
	PrintWriter out;

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

		realSolve();

		out.close();
	}

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

		realSolve();

		out.close();

	}

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


import java.util.*;
/**
 *
 * @author Annie
 */
public class Game {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s = new Scanner(System.in);
        int n=s.nextInt();
        int m = s.nextInt();

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

        int mid=n/2;
       if(m==arr[1] || m==arr[n]){
       if(m==arr[1]){
        System.out.println(m+1);
       }
       if(m==arr[n]){
        System.out.println(m-1);
       }

       }

       else{
        if(m>mid){
        System.out.println(m-1);
        }
        else if(mid==m){
        int left=m-1;
        int right = n-m;
        int y =(left>=right)? m-1:m+1;
            System.out.println(y);

        }
        else{
         System.out.println(m+1);
        }
       }
    }

}


import java.util.*;

public class test{
    public static void main(String []args){
        Scanner in=new Scanner (System.in);
        int n=in.nextInt();
        boolean [] sign=new boolean [1005];
        for(int i=1;i<=n;++i) sign[i]=false;
        int step=1;
        for(int i=1;i<=n;++i){
            step+=(i-1)6;
            if(step>n) step-=n;
            sign[step]=true;
        }
        boolean flag=true;
        for(int i=1;i<=n;++i) if(!sign[i]) flag=false;
        if(flag) System.out.println("YES");
        else  System.out.println("NO");
    }
}


import java.util.Scanner;

public class LuckyYear {
    public static int isLucky(int n) {
        String bla = Integer.toString(n);

        for (int i = 1; i < bla.length(); i++) {
            if (bla.charAt(i) != '0')
                return 0;
        } return 1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt()+1;
        int count = 1;

        while (true) {
            if (isLucky(n) == 1) {
                System.out.println(count);
                break;
            }
            count++;
            n++;
        }
    }
}


public class A {

	public A () {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int [] A = sc.nextInts();

		int res = 0, j = 0;
		while (j < N) {
			int Z = M;
			while (Z >= A[j]) {
				--Z; ++j;
			}
			++res;
		}

		exit(res);
	}

	////////////////////////////////////////////////////////////////////////////////////
	private final static IOUtils.MyScanner sc = new IOUtils.MyScanner();
	private static void exit (Object o, Object ... A) { IOUtils.print(o, A); IOUtils.exit(); }
	private static class IOUtils {
		public static class MyScanner {
			public String next() { newLine(); return line[index++]; }
			public int nextInt() { return Integer.parseInt(next()); }
			public String nextLine() { line = null; return readLine(); }
			public String [] nextStrings() { return split(nextLine()); }
			public int [] nextInts() {
				String [] L = nextStrings();
				int [] res = new int [L.length];
				for (int i = 0; i < L.length; ++i)
					res[i] = Integer.parseInt(L[i]);
				return res;
			}
			//////////////////////////////////////////////
			private boolean eol() { return index == line.length; }
			private String readLine() {
				try {
					return r.readLine();
				} catch (Exception e) {
					throw new Error (e);
				}
			}
			private final java.io.BufferedReader r;
			private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
			private MyScanner (java.io.BufferedReader r) {
				try {
					this.r = r;
					while (!r.ready())
						Thread.sleep(1);
					start();
				} catch (Exception e) {
					throw new Error(e);
				}
			}
			private String [] line;
			private int index;
			private void newLine() {
				if (line == null || eol()) {
					line = split(readLine());
					index = 0;
				}
			}
			private String [] split(String s) { return s.length() > 0 ? s.split(" ") : new String [0]; }
		}
		private static String build(Object o, Object ... A) { return buildDelim(" ", o, A); }
		private static String buildDelim(String delim, Object o, Object ... A) {
			StringBuilder b = new StringBuilder();
			append(b, o, delim);
			for (Object p : A)
				append(b, p, delim);
			return b.substring(delim.length());
		}
		//////////////////////////////////////////////////////////////////////////////////
		private static void start() { if (t == 0) t = millis(); }
		private static void append(StringBuilder b, Object o, String delim) {
			if (o.getClass().isArray()) {
				int len = java.lang.reflect.Array.getLength(o);
				for (int i = 0; i < len; ++i)
					append(b, java.lang.reflect.Array.get(o, i), delim);
			} else if (o instanceof Iterable<?>)
				for (Object p : (Iterable<?>) o)
					append(b, p, delim);
			else {
				if (o instanceof Double)
					o = new java.text.DecimalFormat("#.############").format(o);
				b.append(delim).append(o);
			}
		}
		private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out);
		private static void print(Object o, Object ... A) { pw.println(build(o, A)); }
		private static void err(Object o, Object ... A) { System.err.println(build(o, A)); }
		private static void exit() {
			IOUtils.pw.close();
			System.out.flush();
			err("------------------");
			err(IOUtils.time());
			System.exit(0);
		}
		private static long t;
		private static long millis() { return System.currentTimeMillis(); }
		private static String time() { return "Time: " + (millis() - t) / 1000.0; }
	}
	public static void main (String[] args) { new A(); IOUtils.exit(); }
}


// Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

// Please name your class Main
public class Main {

	static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

    static int read() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }
    static String readString() throws IOException {
        in.nextToken();
        return in.sval;
	}

	public static void main (String[] args) throws java.lang.Exception {
	    Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		//InputReader in = new InputReader(System.in);

		int n=in.nextInt();
		int m=in.nextInt();
		Solution sol=new Solution();
		sol.solution(n,m);

	}

}

class Solution{
	//constant variable
	final int MAX=Integer.MAX_VALUE;
	final int MIN=Integer.MIN_VALUE;
	//Set<Integer>adjecent[];
	//////////////////////////////

	BigInteger fact[];
	public void solution(int n,int m){
		if(n<3||n-1>m){
			msg("0");
			return;
		}

		long mod=998244353;
		BigInteger res=BigInteger.valueOf(0);
		BigInteger sum=BigInteger.valueOf(0);

		fact=new BigInteger[m+1];
		fact[0]=BigInteger.ONE;
        fact[1]=BigInteger.ONE;
        for(int i=2;i<fact.length;i++){
            fact[i]=fact[i-1].multiply(BigInteger.valueOf(i));
        }
		//There is a peek Index
		//strict increase and strict decrease after

		//peak + (n-1)elements  => (2 of them are same) => n-2 diff

		//n-2 element, one is repeat

		BigInteger peek[]=new BigInteger[m+1]; //different peak
		BigInteger split[]=new BigInteger[n+1]; //different peak

		for(int i=n-1;i<=m;i++){//peak is i
			peek[i]=C(i-1,n-2);//.multiply(BigInteger.valueOf(n-2));
			//System.out.println(peek[i]);
			sum=sum.add(peek[i]);
		}
		//System.out.println("sum  "+sum);

		for(int i=1;i<=n-2;i++){
			split[i]=C(n-2,i).multiply(BigInteger.valueOf(i));
			//System.out.println(split[i]);
			res=res.add(sum.multiply(split[i]));
		}

		//n position, each can have different peek (n-1)->(m)

		res=res.mod(BigInteger.valueOf(mod));
		System.out.println(res);
	}

	public BigInteger C(int i,int j){ // C(20,3)=20!/(17!*3!)
		return fact[i].divide(fact[i-j].multiply(fact[j]));
	}

	//map operation
	public void put(Map<Integer,Integer>map,int i){
		if(!map.containsKey(i))map.put(i,0);
		map.put(i,map.get(i)+1);
	}

	public void delete(Map<Integer,Integer>map,int i){
		map.put(i,map.get(i)-1);
		if(map.get(i)==0)map.remove(i);
	}

	/*public void tarjan(int p,int r){
		if(cut)return;
		List<Integer>childs=adjecent[r];
		dis[r]=low[r]=time;
		time++;

		//core for tarjan
		int son=0;
		for(int c:childs){
			if(ban==c||c==p)continue;
			if(dis[c]==-1){
				son++;
				tarjan(r,c);
				low[r]=Math.min(low[r],low[c]);
				if((r==root&&son>1)||(low[c]>=dis[r]&&r!=root)){
					cut=true;
					return;
				}
			}else{
				if(c!=p){
					low[r]=Math.min(low[r],dis[c]);
				}
			}
		}

	}*/

	//helper function I would use
	public void remove(Map<Integer,Integer>map,int i){
		map.put(i,map.get(i)-1);
		if(map.get(i)==0)map.remove(i);
	}

	public int gcd(int num1, int num2) {
      if (num2 != 0){
         return gcd(num2, num1 % num2);
      } else{
         return num1;
      }
   }

	public void ascii(String s){
		for(char c:s.toCharArray()){
			System.out.print((c-'a')+" ");
		}
		msg("");
	}

	public int flip(int i){
		if(i==0)return 1;
		else return 0;
	}

	public boolean[] primes(int n){
		boolean A[]=new boolean[n+1];
		for(int i=2;i<=n;i++){
			if(A[i]==false){
				for(int j=i+i;j<=n;j+=i){
					A[j]=true;
				}
			}
		}
		return A;
	}

	public void msg(String s){
		System.out.println(s);
	}

	public void msg1(String s){
		System.out.print(s);
	}

	public int[] kmpPre(String p){
		int pre[]=new int[p.length()];
		int l=0,r=1;
		while(r<p.length()){
			if(p.charAt(l)==p.charAt(r)){
				pre[r]=l+1;
				l++;r++;
			}else{
				if(l==0)r++;
				else l=pre[l-1];
			}
		}
		return pre;
	}

	public boolean isP(String s){
		int l=0,r=s.length()-1;
		while(l<r){
			if(s.charAt(l)!=s.charAt(r))return false;
			l++;r--;
		}
		return true;
	}

	public int find(int nums[],int x){//union find => find method
		if(nums[x]==x)return x;
		int root=find(nums,nums[x]);
		nums[x]=root;
		return root;
	}

	public boolean check(int grid[][],int r,int c){
		if(r<0||c<0||r>=grid.length||c>=grid[0].length)return false;
		return true;
	}

	public int get(int A[],int i){
		if(i<0||i>=A.length)return 0;
		return A[i];
	}
	public int[] copy1(int A[]){
		int a[]=new int[A.length];
		for(int i=0;i<a.length;i++)a[i]=A[i];
		return a;
	}

	public int[] copy2(int A[]){
		int a[]=new int[A.length];
		for(int i=0;i<a.length;i++)a[i]=A[i];
		return a;
	}

	public void print1(int A[]){
		for(long i:A)System.out.print(i+" ");
		System.out.println();
	}
	public void print2(int A[][]){
		for(int i=0;i<A.length;i++){
			for(int j=0;j<A[0].length;j++){
				System.out.print(A[i][j]+" ");
			}System.out.println();
		}
	}

	public int min(int a,int b){
		return Math.min(a,b);
	}

	public int[][] matrixdp(int[][] grid) {
        if(grid.length==0)return new int[][]{};
        int res[][]=new int[grid.length][grid[0].length];
        for(int i=0;i<grid.length;i++){
            for(int j=0;j<grid[0].length;j++){
                res[i][j]=grid[i][j]+get(res,i-1,j)+get(res,i,j-1)-get(res,i-1,j-1);
            }
        }
        return res;
    }

    public int get(int grid[][],int i,int j){
        if(i<0||j<0||i>=grid.length||j>=grid[0].length)return 0;
        return grid[i][j];
    }

	public int[] suffixArray(String s){
		int n=s.length();
		Suffix A[]=new Suffix[n];

		for(int i=0;i<n;i++){
			A[i]=new Suffix(i,s.charAt(i)-'a',0);
		}

		for(int i=0;i<n;i++){
			if(i==n-1){
				A[i].next=-1;
			}else{
				A[i].next=A[i+1].rank;
			}
		}
		Arrays.sort(A);

		for(int len=4;len<A.length*2;len<<=1){
			int in[]=new int[A.length];
			int rank=0;
			int pre=A[0].rank;
			A[0].rank=rank;
			in[A[0].index]=0;
			for(int i=1;i<A.length;i++){//rank for the first two letter
				if(A[i].rank==pre&&A[i].next==A[i-1].next){
					pre=A[i].rank;
					A[i].rank=rank;
				}else{
					pre=A[i].rank;
					A[i].rank=++rank;
				}
				in[A[i].index]=i;
			}

			for(int i=0;i<A.length;i++){
				int next=A[i].index+len/2;
				if(next>=A.length){
					A[i].next=-1;
				}else{
					A[i].next=A[in[next]].rank;
				}
			}

			Arrays.sort(A);
		}

		int su[]=new int[A.length];
		for(int i=0;i<su.length;i++){
			su[i]=A[i].index;
		}
		return su;
	}

}

//suffix array Struct
class Suffix implements Comparable<Suffix>{
	int index;
	int rank;
	int next;
	public Suffix(int i,int rank,int next){
		this.index=i;
		this.rank=rank;
		this.next=next;
	}

	@Override
	public int compareTo(Suffix other) {
		if(this.rank==other.rank){
			return this.next-other.next;
		}
		return this.rank-other.rank;
	}

	public String toString(){
		return this.index+"   "+this.rank+"   "+this.next+"  ";
	}
}

class Wrapper implements Comparable<Wrapper>{
	int spf;int cnt;
	public Wrapper(int spf,int cnt){
		this.spf=spf;
		this.cnt=cnt;
	}

	@Override
	public int compareTo(Wrapper other) {
		return this.spf-other.spf;
	}
}

    class Node{//what the range would be for that particular node
		boolean state=false;
        int l=0,r=0;
		int ll=0,rr=0;
        public Node(boolean state){
            this.state=state;
        }
    }

	class Seg1{
			int A[];
			public Seg1(int A[]){
				this.A=A;
			}

			public void update(int left,int right,int val,int s,int e,int id){
				if(left<0||right<0||left>right)return;
				if(left==s&&right==e){

					A[id]+=val;
					return;
				}
				int mid=s+(e-s)/2; //[s,mid] [mid+1,e]

				if(left>=mid+1){
					update(left,right,val,mid+1,e,id*2+2);
				}else if(right<=mid){
					update(left,right,val,s,mid,id*2+1);
				}else{
					update(left,mid,val,s,mid,id*2+1);
					update(mid+1,right,val,mid+1,e,id*2+2);
				}
			}

			public int query(int i,int add,int s,int e,int id){

				if(s==e&&i==s){
					return A[id]+add;
				}

				int mid=s+(e-s)/2; //[s,mid] [mid+1,e]

				if(i>=mid+1){
					return query(i,A[id]+add,mid+1,e,id*2+2);
				}else{
					return query(i,A[id]+add,s,mid,id*2+1);
				}
			}
	}


public class A664 {

	public static boolean reachedResult = false;

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

		String value = scanner.nextLine();
		String[] values = value.split(" ");

		BigInteger numberOne = new BigInteger(values[0]);
		BigInteger numberTwo = new BigInteger(values[1]);

		String result;

		if (numberOne.toString() == numberTwo.toString())
			result = numberOne.toString();
		else
			result = "1";

		System.out.print(result);
	}
}


import java.util.*;

public class soliders
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		long k = sc.nextInt();
		long n = sc.nextInt();
		long w = sc.nextInt();
		long i=1,x=0;
		long temp = n;
		if(w == 1 && n >= k)
		{
			System.out.print("0");
			return;
		}
		while((temp -= i*k) > 0)
		{
			n -= i*k;
			i++;
			w--;
		}
		while(w != 0)
		{
			x += i*k;
			i++;
			w--;
		}
		if(x-n >= 0)
		{
			System.out.print(x-n);
			return;
		}
		else
		{
			System.out.print("0");
			return;
		}
	}
}


import java.io.*;
import java.util.*;
import java.lang.*;
public class Sold{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int n=sc.nextInt();
        int w=sc.nextInt();
        int c=k;
        int i=2;
        int count=1;
        while(n!=0)
        {
            c=c+i*k;
            count++;
        }
        int o=w-count;
        int d=0;
        for(int j=1;j<=o;j++)
        {
            d=d+j*k;
        }
        System.out.println(d);
    }
}


import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

import static java.util.Collections.*;

/**
 * Created by u616 on 3/19/2017.
 */
public class DiceRoll {
    public static void main(String[] args) {
        int num1;
        int num2;
        try (Scanner scanner = new Scanner(System.in)) {
            num1 = scanner.nextInt();
            num2 = scanner.nextInt();
        }
        int num = (6 - (Math.max(num1, num2) - 1));
        int denum = 6;
        if (num == 6)
            System.out.println("1/1");
        else if (denum % num == 0) {
            denum = denum / num;
            num /= num;
            if(n % 2 == 0 && denum %2 ==0)
            System.out.println(num/2 + "/" + denum/2);
            else
            System.out.println(num + "/" + denum);
        }else
            System.out.println(num + "/" + denum);

    }
}


/**
 * Created by Shadow on 1/17/2017.
 */
import java.util.Scanner;

public class Main {
    public static void main(String [] args)
    {
        Scanner in = new Scanner(System.in);
        int players, bottles, towels, totBottles = 0, contests = 0;
        players = in.nextInt();
        bottles = in.nextInt();
        towels = in.nextInt();

        towels *= players;
        int k = 2;
        while(k < players)
        {
            k *= 2;
        }
        if(k > players)
        {
            k /= 2;
        }

        while(players != 1)
        {
            contests += k/2;
            totBottles += k*bottles;
            players -= k/2;
            k = k/2;
        }
        totBottles += contests;

        System.out.print(totBottles + " " + towels);
    }
}


/**
 *
 @Author : CHIMA VICTOR
 @Date   : 15 avr. 2014
 @Time   : 19:19:59
 *
 */

import java.util.Scanner;

public class Kicker {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int[] a = new int[4];
		int[] b = new int[4];
		for (int i = 0; i < 4; i++) {
			a[i] = in.nextInt();
			b[i] = in.nextInt();
		}

		int[] choices = new int[4];
		if (a[0] - a[2] > 0 && b[1] - b[3] > 0) {
			choices[0] = 1;
		} else if (a[0] - a[2] < 0 && b[1] - b[3] < 0) {
			choices[0] = 2;
		}
		if (a[0] - a[3] > 0 && b[1] - b[2] > 0) {
			choices[1] = 1;
		} else if (a[0] - a[3] < 0 && b[1] - b[2] < 0) {
			choices[1] = 2;
		}
		if ((a[1] - a[2] > 0 && b[0] - b[3] > 0)) {
			choices[2] = 1;
		} else if (a[1] - a[2] < 0 && b[0] - b[3] < 0) {
			choices[2] = 2;
		}
		if (a[1] - a[3] > 0 && b[0] - b[2] > 0) {
			choices[3] = 1;
		} else if (a[1] - a[3] < 0 && b[0] - b[2] < 0) {
			choices[3] = 2;
		}
		if ((choices[0] == 1 && choices[1] == 1) || (choices[2] == 1
				&& choices[3] == 1)) {
			System.out.println("Team 1");
		} else if ((choices[0] == 2 || choices[1] == 2) && (choices[2] == 2
				|| choices[3] == 2)) {
			System.out.println("Team 2");
		} else {
			System.out.println("Draw");
		}
	}

}


import java.io.*;
import java.util.*;
public class NextRound{
	public static void main (String args[]){
	Scanner scnr = new Scanner (System.in);
	int n,k;
	n=scnr.nextInt();
	k=scnr.nextInt();
	int point[]= new int[n];
	for (int i=0;i<n;i++){ //filling the array for analyse
	point[i]=scnr.nextInt();}
	for (int i=0;i<k;i++){
	if (point[i]==0) {System.out.println(i);break;}
	else {
		for (i=k;i<n;i++){
			if (point[i]==point[i-1]) k++;
			else {System.out.println(k);break;}
		}
	    }
	}
    }
}


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

	// 1 2 3 4 5
	// 2 3 5 8 13
	// 1 1
	void solve()
	{
		int K = ni();
		long[][] co = new long[K+3][K+3];
		long[] F = new long[300];
		F[0] = 0; F[1] = 1;
		int mod = 1000000007;
		for(int i = 2;i < 300;i++){
			F[i] = F[i-1] + F[i-2];
			if(F[i] >= mod)F[i] -= mod;
		}
		long ret = 0;

		long invf = 1;
		for(int i = 1;i <= K;i++)invf = invf * i % mod;

		long[] cok = new long[K+1];
		cok[0] = invl(invf, mod);
		for(int i = 0;i < K;i++){
			for(int j = i;j >= 0;j--){
				cok[j+1] += cok[j];
				if(cok[j+1] >= mod)cok[j+1] -= mod;
				cok[j] = -cok[j] * i;
				cok[j] %= mod;
				if(cok[j] < 0)cok[j] += mod;
			}
		}

		long L = nl(), R = nl();
		long[] hi = new long[K+3];
		Arrays.fill(hi, 1);

		for(int i = 0;i < K+2;i++){
			for(int j = 0;j <= i;j++){
				if(i == j || j == 0){
					co[i][j] = 1;
					continue;
				}
				co[i][j] = F[i-j-1] * co[i-1][j-1] + F[j+1] * co[i-1][j];
				co[i][j] %= mod;
			}
			if(i >= 1){
				long[] f = new long[i+2];
				for(int j = 0;j < i+1;j++){
					f[i-j] = (j&3) == 0 || (j&3) == 3 ? co[i][j] : mod-co[i][j];
				}
				for(int j = i;j >= 0;j--){
					f[j+1] += f[j];
					if(f[j+1] >= mod)f[j+1] -= mod;
					f[j] = mod-f[j];
					if(f[j] == mod)f[j] = 0;
				}

				long[] xo = new long[f.length-1];
				for(int j = 0;j < f.length-1;j++){
					xo[j] = mod-f[j];
				}
				long[] cum = new long[xo.length];
				for(int j = 0;j < xo.length;j++){
					cum[j] += hi[j];
					if(cum[j] >= mod)cum[j] -= mod;
					if(j+1 < xo.length){
						cum[j+1] += cum[j];
						if(cum[j+1] >= mod)cum[j+1] -= mod;
					}
				}

				ret += (f(cum, lrx(xo, R+2, mod)) - f(cum, lrx(xo, L+1, mod))) * cok[i-1];
				ret %= mod;
				for(int j = 0;j <= K+2;j++){
					hi[j] = hi[j] * F[j] % mod;
				}
			}
		}
		if(ret < 0)ret += mod;
		out.println(ret);
	}

	public static long f(long[] a, long[] co)
	{
		long big = 8L*mod*mod;
		long s = 0;
		for(int i = 0;i < co.length;i++){
			s += co[i] * a[i];
			if(s >= big)s -= big;
		}
		return s % mod;
	}

	public static int mod = 1000000007;

	public static long[] lrx(long[] co, long n, long mod)
	{
		long BIG = (Long.MAX_VALUE - 2L*mod*mod)/mod*mod;
		int m = co.length;
		if(m == 1){
			long ret = 1;
			long mul = co[0];
			for(;n > 0;n >>>= 1){
				if((n&1)==1){
					ret = ret * mul % mod;
				}
				mul = mul * mul % mod;
			}
			return new long[]{ret};
		}

		long[][] m2 = new long[m-1][m];
		for(int j = 0;j < m;j++){
			m2[0][j] = co[j];
		}
		for(int i = 1;i < m-1;i++){
			for(int j = 0;j < m;j++){
				long x = m2[i-1][m-1] * co[j];
				if(j-1 >= 0)x += m2[i-1][j-1];
				m2[i][j] = x % mod;
			}
		}

		long[] ret = new long[m];
		ret[0] = 1;
		long[] temp = new long[2*m];
		for(int l = 62;l >= 0;l--){
			if(n<<~l<0){
				for(int i = 0;i < m;i++)temp[i] = ret[m-1] * co[i];
				for(int i = 1;i < m;i++)temp[i] += ret[i-1];
				for(int i = 0;i < m;i++)ret[i] = temp[i] % mod;
			}
			if(l > 0){
				Arrays.fill(temp, 0L);
				for(int i = 0;i < m;i++){
					for(int j = 0;j < m;j++){
						temp[i+j] += ret[i] * ret[j];
						if(temp[i+j] >= BIG)temp[i+j] -= BIG;
					}
				}
				for(int i = 0;i < 2*m-1;i++)temp[i] %= mod;
				for(int i = 0;i < m;i++){
					long s = temp[i];
					for(int j = m;j < 2*m-1;j++){
						s += temp[j] * m2[j-m][i];
						if(s >= BIG)s -= BIG;
					}
					ret[i] = s % mod;
				}
			}
		}
		return ret;
	}

	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;
	}

	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 A3().run(); }

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

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

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

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

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

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

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

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

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

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

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

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

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


import java.util.Scanner;

public class File1 {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int MOD = 1000000007;
		int k = in.nextInt();
		long l = in.nextLong();
		long r = in.nextLong();
		long m = r-l+1;
		int n = (int)m;
		long pow[] = new long[n+1];
		pow[0] = 1;
		for(int i=1;i<=n;i++){
			pow[i] = 2*pow[i-1];
			pow[i]%=MOD;
		}
		long numPoss[] = new long[n];
		numPoss[0] = 2;
		numPoss[1] = 3;
		for(int i=2;i<n;i++){
			numPoss[i] = pow[(i+1)/2]+pow[i-(i+1)/2]-1;
			numPoss[i]%=MOD;
		}
		long ans = 0;
		for(int i=0;i<n;i++){
			if(k>numPoss[i])
				continue;
			if(k==numPoss[i]){
				ans+=1;
				ans%=MOD;
				continue;
			}
			long temp = 1;
			for(int j=0;j<k;j++){
				temp*=(numPoss[i]-j);
				temp%=MOD;
			}
			ans+=temp;
			ans%=MOD;
		}
		System.out.println(ans);
	}
}


import java.util.*;

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

		int a, b, c;
		int way1, way2, way3;

		a = stdin.nextInt();
		b = stdin.nextInt();
		c = stdin.nextInt();

		way1 = a+b+c;
		way2 = (2*a) + (2*c);
		way3 = (2*b) + (2*c);

		if(way1 <way2 &&way1 <way3)
			System.out.println(way1);
		else if(way2 < way3)
			System.out.println(way2);
		else
			System.out.println(way3);

	}
}


import java.util.Scanner;

public class E {

    static double e = 1e-8, R, phi0;
    static int x,y,r,v,vp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int xp = sc.nextInt();
        int yp = sc.nextInt();
        vp = sc.nextInt();
        x = sc.nextInt();
        y = sc.nextInt();
        v = sc.nextInt();
        r = sc.nextInt();
        R = Math.sqrt(xp*xp+yp*yp);
        phi0 = Math.acos(xp / R);
        double left = 0, right = 1e9;
        for(;;) {
            double middle = (left+right) / 2;
            if (reache(middle) && !reache(middle-e)) {
                System.out.println(middle);
                return;
            }
            if (reache(middle))
                right = middle-e;
            else
                left = middle+e;
        }
    }

    private static boolean reache(double t) {
        double x2 = R*Math.cos(vp/R*t+phi0);
        double y2 = R*Math.sin(vp/R*t+phi0);
        double x1 = x, y1 = y;
        double a = y1-y2, b = x2-x1, c = x1*y2-x2*y1;
        double d = Math.abs(c)/Math.sqrt(a*a+b*b);
        double reach_time = 0;
        a = dis(x1, y1, 0, 0);
        b = dis(x2, y2, 0, 0);
        c = dis(x1, y1, x2, y2);
        if (d >= r || Math.abs(Math.sqrt(a*a-d*d)+Math.sqrt(b*b-d*d)-c) > e) {
            reach_time = c / v;
        }
        else {
            double alfa = Math.acos((x1*x2+y1*y2) / (a*b))-Math.acos(r/a)-Math.acos(r/b);
            reach_time = (r*alfa+Math.sqrt(a*a-r*r)+Math.sqrt(b*b-r*r)) / v;
        }
        return reach_time <= t;
    }

    private static double dis(double x1, double y1, double x2, double y2) {
        return Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    }
}


import java.util.*;
public class a336
{
		public static void main(String ar[])
		{
				Scanner ob=new Scanner(System.in);
				int x=ob.nextInt();
				int y=ob.nextInt();
				int sum=Math.abs(x)+ Math.abs(y);
				int x1=0,y1=0,x2=0,y2=0;
				if(x>0 && y>0)
				{
						x1=0; y1=sum; x2=sum; y2=0;
				}
				else if(x<0 && y<0)
				{
						x1=0; y1=-sum; x2=-sum; y2=0;
				}
				else if(x<0)
				{
						x1=-sum; y1=0; x2=0; y2=sum;
				}
				else if(y<0)
				{
						x1=0; y1=-sum; x2=sum; y2=0;
				}
				System.out.println(x1+" "+y1+" "+x2+" "+y2);
		}
}


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

public class Main {
	public static void main(String[] args) {
	    BigInteger t[] = new BigInteger[100000];
	    t[0] = BigInteger.valueOf(100);
	    for(int i=1; i<t.length; ++i) {
	        t[i] = t[i-1].multiply(BigInteger.valueOf(i));
	    }
		Scanner in = new Scanner(System.in);
		BigDecimal a = in.nextBigDecimal();
		BigDecimal b = in.nextBigDecimal();
		int c = in.nextInt();
		BigDecimal res = a.divide(b, 100000, BigDecimal.ROUND_HALF_UP);
		res = res.setScale(100000, BigDecimal.ROUND_HALF_UP);
		String s = res.toString();
		int idx = s.indexOf(".");
		s = s.substring(idx+1);
		char ch[] = s.toCharArray();
		int ans = -1;
		for(int i=0; i<ch.length-1; ++i) {
			if(ch[i]-'0' == c) {
				ans = i+1;
				ans += t[i].toString().length()*0;
				break;
			}
		}
		System.out.println(ans);
	}
}


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

public class Main {
	public static void main(String[] args) {
	    BigInteger t[] = new BigInteger[20000];
	    t[0] = BigInteger.valueOf(10);
	    for(int i=1; i<t.length; ++i) {
	        t[i] = t[i-1].multiply(BigInteger.valueOf(i)).add(t[i-1]);
	    }
		Scanner in = new Scanner(System.in);
		BigDecimal a = in.nextBigDecimal();
		BigDecimal b = in.nextBigDecimal();
		int c = in.nextInt();
		BigDecimal res = a.divide(b, 100000, BigDecimal.ROUND_HALF_UP);
		res = res.setScale(100000, BigDecimal.ROUND_HALF_UP);
		String s = res.toString();
		int idx = s.indexOf(".");
		s = s.substring(idx+1);
		char ch[] = s.toCharArray();
		int ans = -1;
		for(int i=0; i<ch.length-1; ++i) {
			if(ch[i]-'0' == c) {
				ans = i+1;
				ans += t[i].toString().length()*0;
				break;
			}
		}
		System.out.println(ans);
	}
}


import java.io.IOException;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.io.InputStream;

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

class TaskC {
    public void solve(int testNumber, InputReader jin, PrintWriter jout) {
        int ways = jin.int32();

        int cnt = 0;
        long n = 0;

        PriorityQueue<Pair> que = new PriorityQueue<>(ways, new Comparator<Pair>() {
            @Override
            public int compare(Pair p1, Pair p2) {
                long t1 = p1.x * (long) Math.pow(p1.k, 3);
                long t2 = p2.x * (long) Math.pow(p2.k, 3);
                if(t1 == t2) {
                    return 0;
                } else {
                    return (int)((t1 - t2) / Math.abs(t1 - t2));
                }
            }
        });

        Set<String> seen = new HashSet<>();
        que.add(new Pair(1, 2));
        while(cnt <= ways) {
            Pair cp = que.poll();
            long tn = cp.x * (long) Math.pow(cp.k, 3);
            if(seen.contains(cp.toStr()))
                continue;
            if(cnt == ways) {
                if(tn == n) {
                    jout.println(-1);
                } else {
                    jout.println(n);
                }
                break;
            } else {
                n = tn;

                cnt++;
                que.add(new Pair(cp.x + 1, cp.k));
                que.add(new Pair(cp.x, cp.k + 1));
            }
            seen.add(cp.toStr());
        }
    }
}

class Pair {
    public long x;
    public long k;

    public String toStr() {
        return x + " " + k;
    }

    public Pair(long a, long b) {
        x = a;
        k = b;
    }
}

class InputReader {
    private static final int bufferMaxLength = 1024;
    private InputStream in;
    private byte[] buffer;
    private int currentBufferSize;
    private int currentBufferTop;
    private static final String tokenizers = " \t\r\f\n";

    public InputReader(InputStream stream) {
        this.in = stream;
        buffer = new byte[bufferMaxLength];
        currentBufferSize = 0;
        currentBufferTop = 0;
    }

    private boolean refill() {
        try {
            this.currentBufferSize = this.in.read(this.buffer);
            this.currentBufferTop = 0;
        } catch(Exception e) {}
        return this.currentBufferSize > 0;
    }

    public String line() {
        StringBuffer tok = new StringBuffer();
        Byte first;
        while((first = readChar()) != null) {
            tok.append((char)first.byteValue());
            if((char)first.byteValue() == '\n')
                break;
        }
        return tok.toString();
    }

    public Byte readChar() {
        if(currentBufferTop < currentBufferSize) {
            return this.buffer[this.currentBufferTop++];
        } else {
            if(!this.refill()) {
                return null;
            } else {
                return readChar();
            }
        }
    }

    public String token()  {
        StringBuffer tok = new StringBuffer();
        Byte first;
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) != -1));
        if(first == null) return null;
        tok.append((char)first.byteValue());
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) == -1)) {
            tok.append((char)first.byteValue());
        }
        return tok.toString();
    }

    public String next() {
        return token();
    }

    public Integer int32() throws NumberFormatException {
        String tok = token();
        return tok == null? null : Integer.parseInt(tok);
    }

    public Long int64() throws NumberFormatException {
        String tok = token();
        return tok == null? null : Long.parseLong(tok);
    }
}


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

public class A {
    public static void main(String[] args) throws Exception {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int n = fs.nextInt();
        n++;
        int cnt = 1;
        while(!lucky(n)) {
            cnt++;
            n++;
        }

        out.println(cnt);

        out.close();
    }

    static boolean lucky (int n) {
        int res = 0;
        while(n > 0) {
            if(n%10 != 0) res++;
            n/=10;
        }
        return res <= 1;
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try	{
                br = new BufferedReader(new InputStreamReader(System.in));
//                br = new BufferedReader(new FileReader("testdata.out"));
                st = new StringTokenizer("");
            } catch (Exception e){e.printStackTrace();}
        }

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

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

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

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

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

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

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

        public char[] nextCharArray() {
            return nextLine().toCharArray();
        }
    }
}


package codeforces;
import java.util.Scanner;

public class LoveA {

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

		int counter = 0;

		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'a') {
				counter++;
			}
		}
		System.out.println(counter);
		if (counter > s.length()/2) {
			System.out.println(s.length());
			return;
		}
		else
			System.out.println(counter*2 - 1);

	}

}


import java.util.*;
public class Main
{
public static void main(String ar[])
{
Scanner s=new Scanner(System.in);
int c=0;
String str=s.nextLine();
StringBuilder sb=new StringBuilder(str);
for(int i=0;i<sb.length();i++)
{
if(sb.charAt(i)=='a')
{
c++;
}

}
if(c>sb.length()/2)
{
System.out.println(sb.length());
System.exit(0);
}
for(int i=0;c<=sb.length();i++)
{
if(sb.charAt(i)!='a')
{
sb.deleteCharAt(i);
i--;
}

}
if(c>sb.length()/2)
{
System.out.println(sb.length());
System.exit(0);
}

}
}


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

public class java2 {
	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		for(int i=1;a!=0||b!=0;i++) {
			a=a-i;
			b=b-(i+1);
			if(a==0) {
				System.out.print("Valera");break;
			}else if(b==0) {
				System.out.print("Valdik");break;
			}
		}
	}

}


import com.google.common.collect.Sets;

import java.util.Scanner;
import java.util.Set;

public class Problem938A {
    static Set<Character> vowels = Sets.newHashSet('a', 'e', 'i', 'o', 'u', 'y');
    static Scanner scanner;

    public static void main(String[] argv) {
        scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        System.out.println(correct(s));
    }

    private static String correct(String s) {
        boolean meetVowel = false;
        StringBuilder builder = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (meetVowel && vowels.contains(c)) {
                continue;
            }
            meetVowel = vowels.contains(c);
            builder.append(c);
        }
        return builder.toString();
    }
}


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

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

/**
 *
 * @author Andy Phan
 */
public class p1096g {
    static long MOD = 998244353;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        long[] base = new long[10];
        for(int i = 0; i < k; i++) base[in.nextInt()] = 1;
        long[] res = expo(base, n>>1);
        long tot = 0;
        for(long e : res) tot = (tot+(e*e)%MOD)%MOD;
        System.out.println(tot);
    }

    static long[] expo(long[] orig, long pow) {
        if(pow == 1) return orig;
        if((pow&1) != 0) return FFT.multiplyPrecise(orig, expo(orig, pow-1));
        long[] tmp = expo(orig, pow>>1);
        return FFT.multiplyPrecise(tmp, tmp);
    }

    // SET maxk appropriately!!! ~log(maxn) //%
    static class FFT {
        static final int maxk = 23, maxn = (1 << maxk) + 1;
        // Init: wR, wI, rR, rI, aR, aI   to   new double[maxn] !!!
        //#
        static double[] wR = new double[maxn],
                wI = new double[maxn],
                rR = new double[maxn],
                rI = new double[maxn],
                aR  = new double[maxn],
                aI  = new double[maxn]; //$
        static int n, k, lastk = -1, dp[] = new int[maxn];

        static void fft(boolean inv) {
            if (lastk != k) {
                lastk = k;  dp[0] = 0;
                for (int i = 1, g = -1; i < n; i++) {
                    if ((i & (i - 1)) == 0) g++;
                    dp[i] = dp[i ^ (1 << g)] ^ (1 << (k - 1 - g));
                }
                wR[1] = 1;
                wI[1] = 0;
                for (int t = 0; t < k - 1; t++) {
                    double a = Math.PI / n * (1 << (k - 1 - t));
                    double curR = Math.cos(a), curI = Math.sin(a);
                    int p2 = (1 << t), p3 = p2 * 2;
                    for (int j = p2, k = j * 2; j < p3; j++, k += 2) {
                        wR[k] = wR[j];
                        wI[k] = wI[j];
                        wR[k + 1] = wR[j] * curR - wI[j] * curI;
                        wI[k + 1] = wR[j] * curI + wI[j] * curR;
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                int d = dp[i];
                if (i < d) {
                    double tmp = aR[i];
                    aR[i] = aR[d];
                    aR[d] = tmp;
                    tmp = aI[i];
                    aI[i] = aI[d];
                    aI[d] = tmp;
                }
            }
            if (inv) for (int i = 0; i < n; i++) aI[i] = -aI[i];
            for (int len = 1; len < n; len <<= 1) {
                for (int i = 0; i < n; i += len) {
                    int wit = len;
                    for (int it = 0, j = i + len; it < len; it++, i++, j++) {
                        double tmpR = aR[j] * wR[wit] - aI[j] * wI[wit];
                        double tmpI = aR[j] * wI[wit] + aI[j] * wR[wit];
                        wit++;
                        aR[j] = aR[i] - tmpR;
                        aI[j] = aI[i] - tmpI;
                        aR[i] += tmpR;
                        aI[i] += tmpI;
                    }
                }
            }
        }

        static long[] multiply(long[] a, long[] b) {
            int na = a.length, nb = b.length;
            for (k = 0, n = 1; n < na + nb - 1; n <<= 1, k++) {}
            for (int i = 0; i < n; ++i) {
                aR[i] = i < na ? a[i] : 0;
                aI[i] = i < nb ? b[i] : 0;
            }
            fft(false);
            aR[n] = aR[0];
            aI[n] = aI[0];
            double q = -1.0 / n / 4.0;
            for (int i = 0; i <= n - i; ++i) {
                double tmpR = aR[i] * aR[i] - aI[i] * aI[i];
                double tmpI = aR[i] * aI[i] * 2;
                tmpR -= aR[n - i] * aR[n - i] - aI[n - i] * aI[n - i];
                tmpI -= aR[n - i] * aI[n - i] * -2;
                aR[i] = -tmpI * q;
                aI[i] = tmpR * q;
                aR[n - i] = aR[i];
                aI[n - i] = -aI[i];
            }
            fft(true);
            long[] ans = new long[n = na + nb - 1]; // ONLY MOD IF NEEDED
            for (int i = 0; i < n; i++) ans[i] = Math.round(aR[i]) % MOD;
            return ans;
        }
        static void fft2(double[][] xr, double[][] xi, boolean inv) {
            n = xr[0].length;
            k = Integer.numberOfTrailingZeros(n);
            for (int i = 0; i < xr.length; i++) {
                for (int j = 0; j < n; j++) { aR[j] = xr[i][j];  aI[j] = xi[i][j]; }
                fft(inv);
                for (int j=0;j<n;j++){xr[i][j] = aR[j] / (inv ? n : 1);  xi[i][j] = aI[j] / (inv ? -n : 1);}
            }
            n = xr.length;
            k = Integer.numberOfTrailingZeros(n);
            for (int j = 0; j < xr[0].length; j++) {
                for (int i = 0; i < n; i++) { aR[i] = xr[i][j];  aI[i] = xi[i][j]; }
                fft(inv);
                for (int i=0;i<n;i++){xr[i][j] = aR[i] / (inv ? n : 1);  xi[i][j] = aI[i] / (inv ? -n : 1);}
            }
        }
        static long[][] multiply2(long[][] a, long[][] b) {
            int n1, n2;
            for (n1 = 1; n1 < a.length + b.length - 1; n1 <<= 1) {}
            for (n2 = 1; n2 < a[0].length + b[0].length - 1; n2 <<= 1) {}
            double[][] ar = new double[n1][n2], ai = new double[n1][n2];
            double[][] br = new double[n1][n2], bi = new double[n1][n2];
            for (int i = 0; i < a.length; i++) for(int j=0;j<a[i].length;j++) ar[i][j] = a[i][j];
            for (int i = 0; i < b.length; i++) for(int j=0;j<b[i].length;j++) br[i][j] = b[i][j];
            fft2(ar,ai,false); fft2(br,bi,false);
            for (int i = 0; i < n1; i++) {
                for(int j = 0; j < n2; j++) {
                    double r1 = ar[i][j], r2 = br[i][j];
                    double i1 = ai[i][j], i2 = bi[i][j];
                    double real = r1 * r2 - i1 * i2;
                    ai[i][j] = i1 * r2+ i2*r1;
                    ar[i][j] = real;
                }
            }
            fft2(ar,ai,true);  long[][] result = new long[n1=a.length+b.length-1][n2=a[0].length+b[0].length-1];
            for (int i = 0; i < n1; i++)
                for(int j = 0; j < n2; j++) result[i][j] = Math.round(ar[i][j]);
            return result;
        }
        //#
        static long[] multiplyPrecise(long[] a, long[] b) {
            long k = (long)(Math.sqrt(MOD));
            long[] a1 = new long[a.length], a2 = new long[a.length];
            long[] b1 = new long[b.length], b2 = new long[b.length];
            for(int i=0;i<a.length;i++) {
                a1[i] = a[i] % k;
                a2[i] = a[i] / k;
            }
            for(int i=0;i<b.length;i++) {
                b1[i] = b[i] % k;
                b2[i] = b[i] / k;
            }
            long[] r11 = multiply(a1, b1), r12 = multiply(a1, b2), r21 = multiply(a2, b1), r22 = multiply(a2, b2);
            long[] res = new long[r11.length];
            for(int i=0;i<res.length;i++)
                res[i] = (k*k*r22[i] + k*(r12[i] + r21[i]) + r11[i]) % MOD;
            return res;
        }
        //$
        //#
        static long[] multiplyOr(long[] eq1, long[] eq2) {
            int n = Math.max(eq1.length, eq2.length);
            if((n & (n-1)) != 0)
                n = Integer.highestOneBit(n)*2;
            eq1 = fftOr(eq1, n, false);
            eq2 = fftOr(eq2, n, false);
            for(int i=0;i<eq1.length;i++)
                eq1[i] *= eq2[i];
            eq1 = fftOr(eq1, n, true);
            return eq1;
        }
        //$
        // To use: FFT both, product, iFFT (n is next power of 2)
        static long[] fftOr(long[] arr, int n, boolean invert) {
            long[] ans = Arrays.copyOf(arr, n);
            for (int b = 1; b < n; b <<= 1)
                for (int i = 0; i < n; i++) {
                    if ((i & b) != 0) continue;
                    ans[i + b] += invert ? -ans[i] : ans[i];
                }
            return ans;
        }
        static long[] fftXor(long[] arr, int n, boolean invert) {
            long[] ans = Arrays.copyOf(arr, n);
            for (int b = 1; b < n; b <<= 1)
                for (int i = 0; i < n; i++) {
                    if((i & b) != 0) continue;
                    long u = ans[i], v = ans[i+b];
                    ans[i] = u + v;  ans[i + b] = u - v;
                }
            if (invert) for (int i = 0; i < n; i++) ans[i] /= n;
            return ans;
        }
    }

}


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

public class LuckyTickets {

    // 2^23*7*17+1
    private static final int MOD = 998244353;

    //highest power of 2 that is a factor of MOD-1
    private static final int twoPow = 23;

    // any number such that ROOT^(2^twoPow)=1 & ROOT^(2^(twoPow-1))!=1
    private static final int ROOT = 15311432;

    // flip first k bits
    private static int bitReverse(int n, int k) {
        return Integer.reverse(n) >>> (32 - k);
    }

    private static long modPow(long a, long p) {
        if (p == 0) {
            return 1;
        }
        long half = modPow(a, p / 2);
        long ans = (half * half) % MOD;
        if (p % 2 == 1) {
            ans = (ans * a) % MOD;
        }
        return ans;
    }

    private static long modInv(long a) {
        return modPow(a, MOD - 2);
    }

    /**
     * calculate roots of unity for ntt
     */
    private static long[] calcRoots(int k, boolean inverse) {
        long root = modPow(ROOT, modPow(2, twoPow - k));
        if (inverse) {
            root = modInv(root);
        }
        long[] roots = new long[k];
        roots[k - 1] = root;
        for (int i = k - 1; i > 0; i--) {
            roots[i - 1] = (roots[i] * roots[i]) % MOD;
        }
        return roots;
    }

    /**
     * Change the indicies of an array, putting them into bit-reverse order.
     * array should have length 2^k
     */
    private static long[] reorderArray(long[] a, int k) {
        long[] ans = new long[a.length];
        for (int i = 0; i < a.length; i++) {
            ans[bitReverse(i, k)] = a[i];
        }
        return ans;
    }

    /**
     * coef.length = 2^k
     * Note: When computing the inverse, this function will return 2^k times the
     * correct answer. Please divide as needed.
     */
    private static long[] numberTheoreticTransform(long[] coef, int k, boolean inverse) {
        coef = reorderArray(coef, k);
        long[] roots = calcRoots(k, inverse);
        for (int s = 0; s < k; s++) {
            int len = 1 << s;
            for (int st = 0; st < coef.length; st += 2 * len) {
                // combine the vectors starting at st and st + len
                long curRoot = 1;
                for (int j = st; j < st + len; j++) {
                    long t = (curRoot * coef[j + len]) % MOD;
                    long u = coef[j];
                    coef[j] = (u + t) % MOD;
                    coef[j + len] = (u - t) % MOD;
                    curRoot = (roots[s] * curRoot) % MOD;
                }
            }
        }
        return coef;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt() / 2;
        int m = sc.nextInt();
        int[] nums = new int[m];
        int max = 0;
        for (int i = 0; i < m; i++) {
            nums[i] = sc.nextInt();
            max = Math.max(max, nums[i]);
        }
        int min_size = n * max + 1;
        int k = 0;
        int size = 1;
        while (size < min_size) {
            size *= 2;
            k++;
        }
        long[] a = new long[size];
        for (int i = 0; i < nums.length; i++) {
            a[nums[i]] = 1;
        }
        a = numberTheoreticTransform(a, k, false);
        for (int i = 0; i < size; i++) {
            a[i] = modPow(a[i], n);
        }
        a = numberTheoreticTransform(a, k, true);
        long ans = 0;
        for (int i = 0; i < size; i++) {
            ans = (ans + a[i] * a[i]) % MOD;
        }
        long multiplier = modInv(size);
        System.out.println((((ans * multiplier) % MOD) * multiplier) % MOD);
    }
}


import java.util.*;

public class Solution{
    public static void main(Sritng[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n == 2){
            System.out.println(1);
        }else{
            int k = (n/3)*2;
            int rest = n%3;
            if(rest == 0 || rest == 2){
                System.out.println(k);
            }else{
                System.out.println(k+1);
            }
        }
    }
}


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

public class Main {
    public static long MOD = 1000000007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();

        final ArrayList<Integer> values = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            values.add(scanner.nextInt());
        }

        int zeroCount = values.stream().filter(integer -> integer.equals(0)).mapToInt(i -> 1).sum();
        final long[][] table = new long[k + 1][n];

        int initZeroCount = values.subList(0, zeroCount).stream().filter(integer -> integer.equals(0)).mapToInt(i -> 1).sum();
        table[0][initZeroCount] = 1L;

        for (int i = 1; i < k + 1; i++) {
            for (int j = 0; j < n; j++) {
                final int zeroInPrefix = j;
                final int zeroOutPrefix = getZeroOutPrefix(zeroCount, zeroInPrefix);
                final int oneInPrefix = getOneInPrefix(zeroCount, zeroInPrefix);
                final int oneOutPrefix = getOneOutPrefix(n, zeroCount, zeroInPrefix);

                final long sameZero = table[i - 1][j]
                        * (zeroInPrefix * zeroOutPrefix
                        + zeroInPrefix * oneInPrefix
                        + zeroOutPrefix * oneOutPrefix
                        + oneInPrefix * oneOutPrefix
                        + countPair(oneInPrefix)
                        + countPair(zeroInPrefix)
                        + countPair(oneOutPrefix)
                        + countPair(zeroOutPrefix));
                final long plusZero = (j == 0 ? 0 : table[i - 1][j - 1]) *
                        (getOneInPrefix(zeroCount, zeroInPrefix - 1) * getZeroOutPrefix(zeroCount, zeroInPrefix - 1));
                final long minusZero = (j == n - 1 ? 0 : table[i - 1][j + 1]) *
                        ((zeroInPrefix + 1) * getOneOutPrefix(n, zeroCount, zeroInPrefix + 1));

                table[i][j] = sameZero + plusZero + minusZero;
            }
        }
        final long count = table[k][zeroCount];
        final long sum = Arrays.stream(table[k]).reduce((left, right) -> (left + right) % MOD).orElse(0);

        System.out.println((binPow(sum, MOD - 2) * count) % MOD);
    }

    private static int getOneInPrefix(int zeroCount, int zeroInPrefix) {
        return zeroCount - zeroInPrefix;
    }

    private static int getOneOutPrefix(int allCount, int zeroCount, int zeroInPrefix) {
        return allCount - zeroCount - getOneInPrefix(zeroCount, zeroInPrefix);
    }

    private static int getZeroOutPrefix(int zeroCount, int zeroInPrefix) {
        return zeroCount - zeroInPrefix;
    }

    private static long countPair(int count) {
        return (count * (count - 1)) / 2;
    }

    private static long binPow(long n, long count) {
        if (count == 0) {
            return 1L;
        }

        long temp = binPow(n, count / 2);
        temp = (temp * temp) % MOD;
        if (count % 2 != 0) {
            temp = (temp * n) % MOD;
        }

        return temp % MOD;
    }
}