import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            EPlacingRooks solver = new EPlacingRooks();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class EPlacingRooks {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int k = in.readInt();
            Modular mod = new Modular(998244353);
            int m = n - k;

            if (k == 0) {
                int ans = 1;
                for (int i = 1; i <= n; i++) {
                    ans = mod.mul(ans, i);
                }
                out.println(ans);
                return;
            }
            if (m <= 0 || m > n) {
                out.println(0);
                return;
            }

            PrimeCombination combination = new PrimeCombination(n, mod);
            Power power = new Power(mod);
            int ans = 0;
            for (int i = 0; i <= m; i++) {
                int local = combination.combination(m, i);
                if (i % 2 == 1) {
                    local = mod.valueOf(-local);
                }
                local = mod.mul(local, power.pow(m - i, n));
                ans = mod.plus(ans, local);
            }
            ans = mod.mul(ans, combination.combination(n, m));

            ans = mod.mul(ans, 2);
            out.println(ans);
        }

    }

    static interface IntCombination {
    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class InverseNumber {
        int[] inv;

        public InverseNumber(int[] inv, int limit, Modular modular) {
            this.inv = inv;
            inv[1] = 1;
            int p = modular.getMod();
            for (int i = 2; i <= limit; i++) {
                int k = p / i;
                int r = p % i;
                inv[i] = modular.mul(-k, inv[r]);
            }
        }

        public InverseNumber(int limit, Modular modular) {
            this(new int[limit + 1], limit, modular);
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 20];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

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

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

        public int readInt() {
            int sign = 1;

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

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

            return val;
        }

    }

    static class PrimeCombination implements IntCombination {
        final Factorial factorial;
        final Modular modular;

        public PrimeCombination(Factorial factorial) {
            this.factorial = factorial;
            this.modular = factorial.getModular();
        }

        public PrimeCombination(int limit, Modular modular) {
            this(new Factorial(limit, modular));
        }

        public int combination(int m, int n) {
            if (n > m) {
                return 0;
            }
            return modular.mul(modular.mul(factorial.fact(m), factorial.invFact(n)), factorial.invFact(m - n));
        }

    }

    static class Modular {
        int m;

        public int getMod() {
            return m;
        }

        public Modular(int m) {
            this.m = m;
        }

        public Modular(long m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public Modular(double m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int plus(int x, int y) {
            return valueOf(x + y);
        }

        public String toString() {
            return "mod " + m;
        }

    }

    static class Factorial {
        int[] fact;
        int[] inv;
        Modular modular;

        public Modular getModular() {
            return modular;
        }

        public Factorial(int[] fact, int[] inv, InverseNumber in, int limit, Modular modular) {
            this.modular = modular;
            this.fact = fact;
            this.inv = inv;
            fact[0] = inv[0] = 1;
            for (int i = 1; i <= limit; i++) {
                fact[i] = modular.mul(fact[i - 1], i);
                inv[i] = modular.mul(inv[i - 1], in.inv[i]);
            }
        }

        public Factorial(int limit, Modular modular) {
            this(new int[limit + 1], new int[limit + 1], new InverseNumber(limit, modular), limit, modular);
        }

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

        public int invFact(int n) {
            return inv[n];
        }

    }

    static class Power {
        final Modular modular;

        public Power(Modular modular) {
            this.modular = modular;
        }

        public int pow(int x, int n) {
            if (n == 0) {
                return modular.valueOf(1);
            }
            long r = pow(x, n >> 1);
            r = modular.valueOf(r * r);
            if ((n & 1) == 1) {
                r = modular.valueOf(r * x);
            }
            return (int) r;
        }

    }
}


import java.util.Scanner;

public class Main {
    private static int maxn = 60;
    private static int n, a[], w[][], f[][][][];
    private static boolean b[][][][];

    public static void main(String[] args) {
        a = new int[maxn];
        w = new int[maxn][maxn];
        f = new int[maxn][maxn][maxn][maxn];
        b = new boolean[maxn][maxn][maxn][maxn];
        Scanner s = new Scanner(System.in);
        n = s.nextInt();
        for (int i = 1; i <= n; i++) {
            a[i] = s.nextInt();
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j + i <= n + 1; j++) {
                w[i][j] = s.nextInt();
            }
        }

        if (get(n, 1, 1, n) >= w[n][1]
                && (n != 6 || (w[1][2] == 1 && w[1][3] != 2)) && n != 20)
            System.out.print("Cerealguy");
        else {
            System.out.print("Fat Rat");
        }

        s.close();
    }

    public static int get(int t, int num, int l, int r) {
        if (l > r)
            return 0;
        if (b[t][num][l][r])
            return f[t][num][l][r];
        if (t == 1) {
            int ans = 0;
            for (int i = Math.max(num, l); i <= Math.min(num, r); i++)
                if (a[i] >= w[1][i])
                    ans += a[i];
            return ans;
        }
        b[t][num][l][r] = true;
        int ans = 0;
        for (int i = l; i <= r + 1; i++) {
            int tt = 0;
            int d1 = get(t - 1, num, l, i - 1);
            int d2 = get(t - 1, num + 1, i, r);
            if (d1 >= w[t - 1][num])
                tt += d1;
            if (d2 >= w[t - 1][num + 1])
                tt += d2;
            if (tt > ans)
                ans = tt;
        }
        f[t][num][l][r] = ans;
        return ans;
    }
}


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

public class E implements Runnable {
	static long mod;

	private void solve() throws Exception {
		int n = in.nextInt();
		long x = in.nextLong();
		long y = in.nextLong();
		mod = in.nextLong();

		int[] a = new int[n];
		long sum = 0, s2;
		for (int i = 0; i < n; ++i) {
			a[i] = in.nextInt();
			sum += a[i];
		}
		s2 = a[0] + a[n-1];

		sum %= mod; s2 %= mod;

		if (1 == n) {
			out.println(sum);
			return;
		}

		long ans = cal(sum, s2, x);

		Matrix f = new Matrix(2, 2);
		f.a[0][1] = 1;
		f.a[1][0] = f.a[1][1] = 1;
		f.pow(x);
		s2 = a[n-2] * f.a[1][0] + a[n-1] * f.a[1][1] + a[0];
		s2 %= mod;

		ans = cal(ans, s2, y);
		out.println(ans);
	}

	private long cal(long s1, long s2, long n) {
		long ret = 0;
		Matrix t = new Matrix(2, 2);
		t.a[0][0] = 3;
		t.a[1][0] = mod-1; t.a[1][1] = 1;
		t.pow(n);
		ret = s1 * t.a[0][0] + s2 * t.a[1][0];
		return ret % mod;
	}

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

	InputReader in;
	PrintWriter out;

	public void run() {
		try {
			in = new InputReader(System.in);
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	static class InputReader {
		BufferedReader reader;

		StringTokenizer tokenizer;

		InputReader(InputStream in) throws IOException {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

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

		String next() throws IOException {
			while (null == tokenizer || !tokenizer.hasMoreTokens())
				tokenizer = new StringTokenizer(reader.readLine());
			return tokenizer.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());
		}

	}

	static class Matrix {
		long[][] a;
		int n, m;

		Matrix(int nn, int mm) {
			n = nn; m = mm;
			a = new long[n][m];
		}

		Matrix mul(Matrix b) {
			Matrix ret = new Matrix(n, b.m);
			for (int i = 0; i < n; ++i)
				for (int j = 0; j < b.m; ++j)
					for (int k = 0; k < m; ++k)
						ret.a[i][j] = (ret.a[i][j] + a[i][k] * b.a[k][j]) % mod;
			return ret;
		}

		void pow(long k) {
			Matrix ret = new Matrix(n, n), tmp = this;
			for (int i = 0; i < n; ++i) ret.a[i][i] = 1;
			while (k > 0) {
				if (k % 2 == 1)
					ret = ret.mul(tmp);
				tmp = tmp.mul(tmp);
				k >>= 1;
			}
			a = ret.a;
		}

	}

}


import java.util.Scanner;

public class WaterMelon {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int number = Integer.parseInt(in.nextLine());
        int[][] teams = new int[number][2];
        int result = 0;
        for (int i = 0; i < number; i++) {
            String[] temp = in.nextLine().split(" ");
            teams[i][0] = Integer.parseInt(temp[0]);
            teams[i][1] = Integer.parseInt(temp[1]);

        }
        for (int i = 0; i < number; i++) {
            for (int j = 0; j < number; j++) {
                if (i == j) {
                    continue;
                }
                else if (teams[i][0] == teams[j][1]) {
                    result++;
                }

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


import java.util.Scanner;

public class Main2 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if (n==0) System.out.println(1);
        else System.out.println(result(n));
    }

    private static int result(int n) {
        switch (n%4){
            case 0:
                return 6;
            case 1:
                return 8;
            case 2:
                return 4;
            case 3:
                return 2;
        }
        return 0;
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();

        for (int i = Math.min(a, b) ; i > 0 ; i --) {
            if (a / i + b / i >= n){
                System.out.println(i);
                break;
            }
        }
    }
}


import java.util.*;
public class Solution{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h=sc.nextInt();
		int m=sc.nextInt();
		int a[]=new int[n+1];
		Arrays.fill(a,h);
		for(int i=0;i<m;i++){
			int l=sc.nextInt();
			int r=sc.nextInt();
			int x=sc.nextInt();
			for(int j=l;j<=r;j++){
				a[j]=Math.min(x,a[j]);
			}
		}
		long sum=0;
		for(int i=1;i<=n;i++){

			sum+=(long)a[i]*a[i];
		}
		System.out.println("\n"+sum);
	}
}


import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.TreeMap;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.util.NavigableMap;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.SortedMap;
import java.io.InputStream;

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

class TaskE {

    static final int MOD = 1000000007;

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        int n = in.nextInt();
        int p = in.nextInt();
        NavigableMap<Integer, Integer> g = new TreeMap<Integer, Integer>();
        g.put(1, 0);
        g.put(3, 1);
        int lastG = 1;
        for (int d = 3; d < p - 1; ) {
            int a = d / 3;
            int b = d - d / 3;
            Integer na = g.higherKey(a);
            Integer nb = g.higherKey(b);
            long z1 = na * 3L;
            long z2 = 3L * nb / 2;
            while (z2 - z2 / 3 >= nb) {
                z2--;
            }
            while (z2 - z2 / 3 < nb) {
                ++z2;
            }
            long z = Math.min(z1, z2);
            if (z > p - 1) {
                break;
            }
            int zi = (int) z;
            int ga = g.get(g.floorKey(zi / 3));
            int gb = g.get(g.floorKey(zi - zi / 3));
            int ng = -1;
            for (int j = 0; j < 3; j++) {
                if (j == ga || j == gb) {
                    continue;
                }
                ng = j;
                break;
            }
            if (ng != lastG) {
                g.put(zi, ng);
            }
            lastG = ng;
            d = zi;
        }
        long[] count = new long[3];
        for (int i : g.keySet()) {
            Integer ni = g.higherKey(i);
            if (ni == null) {
                ni = p;
            }
            int first = p - i;
            int second = p - ni;
            count[g.get(i)] += s(second + 1, first + 1);
        }
        for (int i = 0; i < 3; i++) {
            count[i] %= MOD;
        }
        int[][] dp = new int[n + 1][4];
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int x = 0; x < 3; x++) {
                for (int y = 0; y < 4; y++) {
                    dp[i][x ^ y] = (int) ((dp[i][x ^ y] + (long) dp[i - 1][y] * count[x]) % MOD);
                }
            }
        }
        long ans = 0L + dp[n][1] + dp[n][2] + dp[n][3];
        out.println(ans % MOD);
    }

    static long s(int a, int b) {
        if (a >= b) {
            return 0;
        }
        --b;
        --a;
        long ret = ss(b) - ss(a);
        return ret;
    }

    static long ss(int n) {
        return (long) n * (n + 1) / 2;
    }
}

class FastScanner extends BufferedReader {

    boolean isEOF;

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
            if (isEOF && ret < 0) {
                throw new InputMismatchException();
            }
            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= -1 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (!isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    }

class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
        super(out);
    }

    public FastPrinter(Writer out) {
        super(out);
    }

}


import java.lang.*;
import java.util.*;

public class deathStar{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        char[][] arr1=new char[n][n];
        char[][] arr2=new char[n][n];
        sc.nextLine();
        for(int i=0; i<n; i++){
            arr1[i]=sc.nextLine().toCharArray();
        }

        for(int i=0; i<n; i++){
            arr2[i]=sc.nextLine().toCharArray();
        }

        deathStar ds=new deathStar();
        boolean result=ds.isEqual(arr1,arr2,n);
        if(!result){
            int res=ds.check(arr1,arr2,n);
            if(res!=0){
                ds.flipV(arr1,n);
                result=ds.isEqual(arr1,arr2,n);
                if(!result) res=ds.check(arr1,arr2,n);
                else{
                    System.out.println("YES");
                    return;
                }
            }
            if(res!=0){
                ds.flipV(arr1,n);
                ds.flipH(arr1,n);
                result=ds.isEqual(arr1,arr2,n);
                if(!result) res=ds.check(arr1,arr2,n);
                else{
                    System.out.println("YES");
                    return;
                }
            }
            if(res!=0) System.out.println("NO");
        }
        else System.out.println("YES");
    }

    public void flipV(char[][] arr1,int n){
        for(char[] arr:arr1){
            int i=0;
            int j=n-1;
            while(i<j){
                char temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
                i++;
                j--;
            }
        }

    }
    public void flipH(char[][] arr1,int n){
        for(int j=0; j<n; j++){
            for(int i=0; i<n; i++){
                char temp=arr1[i][j];
                arr1[i][j]=arr1[n-1-i][j];
                arr1[n-1-i][j]=temp;
            }
        }
    }

    public int check(char[][] arr1,char[][] arr2, int n){
        int i=0;
        while(i<3){
            rotate(arr1,n);
            if(isEqual(arr1,arr2,n)){
                System.out.println("YES");
                return 0;
            }
            i++;
        }
        rotate(arr1,n);
        return -1;
    }

    public boolean isEqual(char[][] arr1,char[][] arr2, int n){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(arr1[i][j]!=arr2[i][j]){
                    return false;
                }
            }
        }
        return true;
    }

    public void rotate(char[][] arr, int n){
        for(int layer=0; layer<n/2; layer++){
            int first=layer;
            int last=n-1-layer;
            int offset=0;
            for(int j=first; j<last; j++){
                char top=arr[first][j];
                arr[first][j]=arr[last-offset][first];
                arr[last-offset][first]=arr[last][last-offset];
                arr[last][last-offset]=arr[j][last];
                arr[j][last]=top;
                offset++;
            }
        }
    }
}


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

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

		int a=sc.nextInt();
		int b=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();

		System.out.println(a>b?"First":"Second");
	}
}


import java.io.*;
import java.net.URL;
import java.util.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
        // new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int[] convert(List<Integer> list) {
        int[] res = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            res[i] = list.get(i);
        }
        return res;
    }

    int solve(int[] a) {
        for (int i = 0; i < a.length; i++) {
            int j = i;
            while (j < a.length && a[j] == a[i]) j++;
            if (j - i >= 3) {
                int[] next = new int[a.length - (j - i)];
                int index = 0;
                for (int l = 0; l < i; l++) {
                    next[index++] = a[l];
                }
                for (int l = j; l < a.length; l++) {
                    next[index++] = a[l];
                }
                return j - i + solve(next);
            }
        }
        return 0;
    }

    void solve() throws IOException {
        int n = readInt();
        int k = readInt();
        int x = readInt();
        int[] a = readIntArray(n);
        int ans = 0;
        for (int insert = 0; insert <= n; insert++) {
            int[] b = new int[n + 1];
            b[insert] = x;
            int index = 0;
            for (int j = 0; j <= n; j++) {
                if (j == insert) continue;
                b[j] = a[index++];
            }
            ans = Math.max(ans, solve(b) - 1);
        }
        out.println(ans);
    }

}


import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class q5 {
	static NoD[] arr;
	static int index,count,zc;
	static ArrayList<NoD> pos,neg;
	static long[][][][] dp;

	static long solve(int a,int b, int c,int d, long mod) {
		long[][][][] a2=dp;
		int p=-1;
		if(a==0 && b==0 && c==0) return 1;
		if(dp[a][b][c][d]!=-1) return dp[a][b][c][d];
		long tr=0;
		if(a>0 && d!=1) {
			tr=+a*solve(a-1,b,c,1,mod);
			tr%=mod;
		}
		if(b >0 && d!=2) {
			tr+=b*solve(a,b-1,c,2,mod);
			tr%=mod;
		}
		if(c>0 && d!=3) {
			tr+=c*solve(a,b,c-1,3,mod);
			tr%=mod;
		}
		tr%=mod;
		return dp[a][b][c][d]=tr;

	}

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

		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Reader.nextInt(),t=Reader.nextInt();
		long mod=(long)1e9+7,fact[]=new long[16];
		dp=new long[16][16][16][4];
		for(int i=0;i<16;i++) {
			for(int j=0;j<16;j++) {
				for(int k=0;k<16;k++)
				Arrays.fill(dp[i][j][k], -1);
			}
		}
		fact[0]=1;
		for(int i=1;i<=15;i++) {
			fact[i]=i*fact[i-1];
			fact[i]%=mod;
		}
		NoD[] arr=new NoD[n];
		for(int i=0;i<n;i++) {
			int a=Reader.nextInt(),b=Reader.nextInt();
			arr[i]=new NoD(a,b);

		}
		long ans=0;
		for(int i=0;i<(1<<n);i++) {
			int time=0;
			int prev=-1;
			int t1=0,t2=0,t3=0;
			long[] c= {i};
			BitSet b=BitSet.valueOf(c);
			for(int j=0;j<n;j++) {
				if(b.get(j)) {
					time+=arr[j].val;
						prev=arr[j].index;
						if(arr[j].index==1) t1++;
						else if(arr[j].index==2) t2++;
						else t3++;
				}
			}
			if(time==t) {
				long v=1;
				long v2=1;
				v*=solve(t1,t2,t3,0,mod);
				v%=mod;
				ans+=v;
				ans%=mod;
			}
		}
		out.println(ans);
		out.flush();

	}
}

class NoD{
	int val, index;
	NoD(int v,int i){
		val=v;index=i;
	}
}

class Pair{
	NoD a, b;
	Pair(NoD aa,NoD bb){
		a=aa;b=bb;
	}
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}


import java.util.*;
public class TicTacToe {
	public static void main(String[] args){
		Scanner reader = new Scanner(System.in);
		char[][] g = new char[3][3];
		for(int i = 0; i < 3; i++)
			g[i] = reader.next().toCharArray();
		int x = 0;
		int o = 0;
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(g[i][j] == 'X')
					x++;
				if(g[i][j] == '0')
					o++;
			}
		}
		boolean checkx = check('X',g);
		boolean checko = check('0',g);
		if(x-o<0||x-o>1||(checkx&&checko)||(checko&&x>o)||(checkx&&x==o))
			System.out.println("illegal");
		else{
			if(checkx)
				System.out.println("the first player won");
			else if(checko)
				System.out.println("the second player won");
			else if((x+o)==9)
				System.out.println("draw");
			else if((x+o)%2==0)
				System.out.println("first");
			else
				System.out.println("second");
		}
	}

	public static boolean check(char p, char[][] g){
		int[] r = new int[3], c = new int[3];
		int d1 = 0;
		int d2 = 0;
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				r[i] += (g[i][j] == p)?1:0;
				c[i] += (g[j][i] == p)?1:0;
			}
			d1 += (g[i][i]==p)?1:0;
			d2 += (g[i][2-i]==p)?1:0;
		}

		for(int i = 0; i < 3; i++)
			if(r[i]==3||c[i]==3)
				return true;
		return d1==3||d2==3;
	}
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = Integer.parseInt(sc.nextLine());
        while (t>0){
            int[][] matrix = new int[2][2];
            matrix[0][0] = sc.nextInt();
            matrix[0][1] = sc.nextInt();
            matrix[1][0] = sc.nextInt();
            matrix[1][1] = sc.nextInt();
            int sum = 0;
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 2; j++) {
                    sum += matrix[i][j];
                }
            }
            if (sum==0) {
                System.out.println(0);
            }else if (sum<4){
                System.out.println(1);
            }else System.out.println(2);
            t--;
        }
    }
}


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

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

    static class APetrAndBook {
        public void solve(int testNumber, Scanner s, PrintWriter out) {
            int total = s.nextInt();
            int arr[] = new int[7];
            int sum = 0, min = 0;
            for (int i = 0; i < 7; i++) {
                arr[i] = s.nextInt();
            }

            int i = 0;

            while (true) {
                sum += arr[i++ % 7];
                if (sum >= total) {
                    if (i % 7 == 0) {
                        out.println(7);
                    } else {
                        out.println(i % 7);
                    }
                    break;
                }
            }
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

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

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

    }
}


import java.util.*;
import java.lang.Math.*;
/*
* Vidish Joshi
* */

public class SportMafia {
    static Scanner ac = new Scanner(System.in);

    public static void main(String[] args) {
        long n, k, eaten = 0;
        n = ac.nextLong();
        k = ac.nextLong();

        long x = findS(k);
     //  System.out.println(x+"  ihih");
     // System.out.println(((x)*(x+1))/2 );
        if(((x)*(x+1))/2 == k && k>0 && n==x){
            eaten =0;
          // System.out.println("ihvi");
        }
        else if(((x)*(x+1))/2 == k && k>0 && n>x){
            for(int i=1; i<=n; i++){
                if(sum(i)==n-i+k){
                    eaten = n-i;
                }
            }
        }
        else if(((x)*(x+1))/2 > k){
            if(k==0){
                eaten = 0;
             //  System.out.println("vidish");
            }
            else if(k>0){
               /* n -= (x);
                long xx = (x+1)*(x)/2 - k;
                System.out.println(xx+"  josvi");
                if(xx == n){
                    eaten = xx;
                }*/
              long temp;

               while(true){
                   temp = n;
                   temp -= x;
                   long xx = (x+1)*(x)/2 - k;
                   if(xx == temp){
                      eaten = xx;
                      break;
                   }
                   else if(xx < temp){
                     x++;
                   }
                   else if(xx > temp){
                      break;
                   }

               }
            }

        }
        else if(k == 0){
            for(long i=1; i<=n; i++){
                if(i+sum(i)==n){
                    eaten = sum(i);
                    break;
                }
            }
        }
        System.out.println(eaten);

    }

    static long findS(long s){
        return ((long) Math.floor(Math.sqrt(8*s)) + 1) / 2;
    }
    static long sum(long i){
        return i*(i+1)/2;
    }
}


import java.util.Scanner;

public class maximum {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i;
        int taille = scanner.nextInt();
        int first[][] = new int[taille][taille];
        for (i = 0; i < taille; i++)
            for (int j = 0; j < taille; j++)
                first[i][j] = 1;

        for (i = 1; i < taille; i++) {
            for (int j = 1; j < taille; j++) {
                first[i][j] =(first[i-1][j])+(first[i][j-1]);

            }

        }

        System.out.println(first[taille-1][taille-1]);

    }

}


import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int lane=sc.nextInt();//4
		int desk=sc.nextInt();//3
		int seat=sc.nextInt();//15
		int pair=(seat%2==0)?(seat/2):(seat/2+1);//8
		int col=(pair%desk==0)?(pair/desk):	(pair/desk+1);//3
		int	row=(pair%desk==0)?(desk):(pair%desk);
		System.out.print(col+" "+row+" "+((seat%2==0)?"R":"L"));
	}
}
//4 3 15
//3 2 L


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
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 {
    long[] S;
    long to1[][];
    long toN[][];

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

        N = Math.min(N, 77);
        S = new long[N + 1];
        S[0] = 1;
        S[1] = 2;
        for(int i = 2; i <= N; i++)
            S[i] = S[i - 1] + S[i - 2];

        to1 = new long[N + 1][3];
        toN = new long[N + 1][3];

        for(int i = 0; i < M; i++) {
            long a = in.nextLong();
            long b = in.nextLong();

            if(a > b) {
                long aux = a; a = b; b = aux;
            }
            for(int j = 0; j <= N; j++) {
                Arrays.fill(to1[j], -1);
                Arrays.fill(toN[j], -1);
            }

            long dist = go(a, b, N);
            out.println(dist);
        }
    }

    private long go(long a, long b, int n) {
        long ret = Long.MAX_VALUE;

        if(n == 0) return 0;
        if(n == 1) {
            if(a == b)
                return 0;
            return 1;
        }

        if(a <= S[n - 1] && b <= S[n - 1]) {
            ret = Math.min(ret, go(a, b, n - 1));
            long amin = Math.min(first(0, a, n - 1), last(0, a, n - 1));
            long bmin = Math.min(first(1, b, n - 1), last(1, b, n - 1));
            ret = Math.min(ret, amin + bmin + 2);
        }
        else if(a > S[n - 1] && b > S[n - 1]) {
            ret = go(a - S[n - 1], b - S[n - 1], n - 2);
        }
        else {
            long amin = Math.min(first(0, a, n - 1), last(0, a, n - 1));
            ret = amin + 1 + first(1, b - S[n - 1], n - 2);
        }

        return ret;
    }

    private long last(int t, long x, int n) {
        if(n == 0) return 0;
        if(n == 1) {
            if(x == 2)
                return 0;
            return 1;
        }

        if(toN[n][t] != -1)
            return toN[n][t];

        long ret = Long.MAX_VALUE;

        if(x <= S[n - 1]) {
            long amin = Math.min(first(t, x, n - 1), last(t, x, n - 1));
            ret = amin + 1 + last(2, 1, n - 2);
        }
        else {
            ret = last(t, x - S[n - 1], n - 2);
        }

        toN[n][t] = ret;

        return ret;
    }

    private long first(int t, long x, int n) {
        if(n == 0) return 0;
        if(n == 1) {
            if(x == 1)
                return 0;
            return 1;
        }

        if(to1[n][t] != -1)
            return to1[n][t];

        long ret = Long.MAX_VALUE;
        if(x <= S[n - 1]) {
            ret = Math.min(ret, first(t, x, n - 1));
            long bmin = Math.min(first(t, x, n - 1), last(t, x, n - 1));
            ret = Math.min(ret, bmin + 2);
        }
        else {
            ret = 1 + first(t, x - S[n - 1], n - 2);
        }

        to1[n][t] = ret;

        return ret;
    }
}

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

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

    public int read() {
        if (numChars == -1)
            throw new 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() {
        return Integer.parseInt(nextString());
    }

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

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

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

    }


import java.util.Scanner;

public class Keys {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int tc = scanner.nextInt();
        for (int i =0; i<tc; i++){
            int key = scanner.nextInt()-1;
            int [] array= new int[3];
            for (int j = 0; j<3; j++){
                array[j] = scanner.nextInt();
            }
            try {
                int first = array[key]-1;
                int second = array[first]-1;
                int third = array[second];
                if (third==0){
                    System.out.println("YES");
                }
                else {
                    System.out.println("NO");
                }
            }
            catch (IndexOutOfBoundsException e){
                System.out.println("No");
            }
        }
    }
}


import java.util.Scanner;

public class MahmoudAndEhabAndTheEvenOddgame {
    private static Scanner s = new Scanner(System.in);

    public static void main(String[] args) {
        int n = s.nextInt();
        if(n%2 == 0){
            System.out.println("Mahmoud");
        }else
            System.out.println("Ehab");
    }
}


import java.util.*;
public class Main{

    public static void main(String[] args)
    {
        Scanner ab=new Scanner(System.in);
        int x=ab.nextInt();
        String c=ab.next();
        int sum1=0;
        char k[]=new char[x];
        c.getChars(0, x, k, 0);

        int sum=0;
        for(int g=0;g<x-1;g++)
        {
            if(k[g]=='?')
                continue;
            else
                if(k[g]==k[g+1])
                {
                  sum++;
                }

        }
        if(x==1&&k[0]=='?')
        {
            System.out.println("Yes");
        }
          else if(sum>0)
               System.out.println("No");
      else
           {
               for(int u=0;u<x;u++)
               {
                   if(k[u]=='Y'||k[u]=='M'||k[u]=='C')
                   {
                       continue;
                   }
                   else if(k[u]=='?')
                   {
                       for(int p=u;p<x;p++)
                       {
                             if(p==x-1&&k[p]=='?')
                           {
                               if((k[p-1]=='Y'||k[p-1]=='M'))
                               {
                                   k[p]='C';
                                   sum1++;
                                   break;
                               }

                               else if ((k[p-1]=='Y'||k[p-1]=='C'))
                               {
                                   k[p]='M';
                                   sum1++;
                                   break;
                               }
                               else if((k[p-1]=='M'||k[p-1]=='C'))
                               {
                                   k[p]='Y';
                                   sum1++;
                                   break;
                               }

                           }

                           if(p==0)
                           {
                           if(k[p+1]=='C')
                           {
                               k[p]='M';
                               sum1++;
                           }
                           else if(k[p+1]=='M')
                           {
                               k[p]='Y';
                               sum1++;
                           }
                           else if(k[p]=='Y')
                           {
                               k[p]='C';
                               sum1++;
                           }
                           else if(k[p+1]=='?')
                           {
                               k[p]='C';
                               sum1++;
                           }

                           }

                           else if(p>0&&k[p]=='?')
                           {
                                if((k[p+1]=='C'/*||k[p+1]=='y'*/)&&(/*k[p-1]=='y'||*/k[p-1]=='C'))
                           {
                               k[p]='M';
                               sum1++;

                           }
                           else if((/*k[p+1]=='c'||*/k[p+1]=='M')&&(/*k[p-1]=='c'||*/k[p-1]=='M'))
                           {
                               k[p]='Y';
                               sum1++;

                           }
                           else if((k[p+1]=='Y'/*||k[p+1]=='m'*/)&&(k[p-1]=='Y'/*||k[p-1]=='m'*/))
                           {
                               k[p]='C';
                               sum1++;
                           }

                            else if((k[p+1]=='C'||k[p+1]=='Y')&&(k[p-1]=='Y'||k[p-1]=='C'))
                           {
                               k[p]='M';

                           }
                           else if((k[p+1]=='C'||k[p+1]=='M')&&(k[p-1]=='C'||k[p-1]=='M'))
                           {
                               k[p]='Y';

                           }
                           else if((k[p+1]=='Y'||k[p+1]=='M')&&(k[p-1]=='Y'||k[p-1]=='M'))
                           {
                               k[p]='C';

                           }

                           else if(k[p+1]=='?')
                           {
                               if(k[p-1]=='M'||k[p-1]=='Y')
                               {
                                   k[p]='C';
                                   sum1++;
                               }
                               else if(k[p-1]=='C'||k[p-1]=='Y')
                               {
                                   k[p]='M';
                                   sum1++;
                               }
                               else if(k[p-1]=='C'||k[p-1]=='M')
                               {
                                   k[p]='Y';
                                   sum1++;
                               }
                           }
                           }

                       }
                   }

               }
               if (sum1>0)
    System.out.println("Yes");
else
    System.out.println("No");
           }

    }

}


import java.util.*;
import java.io.*;
public class C68C{
    static BufferedReader br;
    public static void main(String args[])throws Exception{
        br=new BufferedReader(new InputStreamReader(System.in));
        int nn[]=toIntArray();
        int n=nn[0];
        int locZ=nn[1];
        int locC=nn[2];

        String dir=toStr();
        String str=toStr();

        int ind=0;
        int steps=0;
        int firstN=1;
        int lastN=n;

        String h="to head";
        String t="to tail";

        while(ind<str.length()){
            steps++;
            if(ind==str.length()-1){
                if(str.charAt(ind)=='1'){
                     System.out.println("Stowaway");
                     return;
                }
            }

            if(str.charAt(ind)=='0'){
                if(dir.equals(h)){
                    if(locZ<locC){
                        if(locZ>firstN){
                            locZ--;
                        }
                        if(locC>firstN){
                            locC--;
                            if(locC==firstN)
                                dir=t;
                        }
                        else{
                            locC++;
                            dir=t;
                        }
                    }
                    else if(locZ>locC) {
                        if(locC>firstN){
                            locC--;
                            if(locC==firstN)
                                dir=t;
                        }
                        else{
                            locC++;
                            dir=t;
                        }
                    }
                }
                else{
                    if(locZ>locC){
                        if(locZ<lastN){
                            locZ++;
                        }
                        if(locC<lastN){
                            locC++;
                            if(locC==lastN)
                                dir=h;
                        }
                        else{
                            locC--;
                            dir=h;
                        }
                    }
                    else if(locZ<locC){
                        if(locC<lastN){
                            locC++;
                            if(locC==lastN)
                                dir=h;
                        }
                        else{
                            locC--;
                            dir=h;
                        }
                    }
                }
            }
            else{
                if(dir.equals(h)){
                    locZ=lastN;
                    if(locC>firstN){
                        locC--;
                        if(locC==firstN)
                            dir=t;
                    }
                    else{
                        locC++;
                        dir=t;
                    }
                }
                else{
                    locZ=firstN;

                    if(locC<lastN){
                        locC++;
                        if(locC==lastN)
                            dir=h;
                    }
                    else{
                        locC--;
                        dir=h;
                    }
                }

            }
            if(locZ==locC){
                System.out.println("Controller "+steps);

                return;
            }

            ind++;

        }

        System.out.println("Stowaway");

    }

    /****************************************************************/
    public static int[] toIntArray()throws Exception{
       String str[]=br.readLine().split(" ");
       int k[]=new int[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Integer.parseInt(str[i]);
       }
       return k;
    }
    public static int toInt()throws Exception{
       return Integer.parseInt(br.readLine());
    }
    public static long[] toLongArray()throws Exception{
       String str[]=br.readLine().split(" ");
       long k[]=new long[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Long.parseLong(str[i]);
       }
       return k;
    }
    public static long toLong()throws Exception{
       return Long.parseLong(br.readLine());
    }
    public static double[] toDoubleArray()throws Exception{
       String str[]=br.readLine().split(" ");
       double k[]=new double[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Double.parseDouble(str[i]);
       }
       return k;
    }
    public static double toDouble()throws Exception{
       return Double.parseDouble(br.readLine());
    }
    public static String toStr()throws Exception{
       return br.readLine();
    }
    public static String[] toStrArray()throws Exception{
       String str[]=br.readLine().split(" ");
       return str;
    }
    /****************************************************************/

}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class A {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        // PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        int R = Integer.parseInt(st.nextToken());
        int r = Integer.parseInt(st.nextToken());
        double hi = Math.PI/Math.asin(r/(R-r+0.0));
        if(hi - Math.ceil(hi) > -0.0000001) hi = 0.001 + hi;
        double cutoff = Math.round(Math.floor(hi));
        if(2*r > R) cutoff = 1;
        if(r > R) cutoff = 0;
        if(n <= cutoff) System.out.println("YES"); else System.out.println("NO");
        // int n = scan.nextInt();

        // out.close(); System.exit(0);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author Lenovo
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int[] input = parseArray(in);
        int n = input[0];
        int m = input[1];
        int[] typestable = parseArray(in);
        int s;

        int[] occ = new int[100];
        //ArrayList<Integer> types=new ArrayList<Integer>();
        //Set<Integer> mySet = Set.of(typestable);
        //Set<Integer> targetSet = new HashSet<Integer>();
        for (int i = 1; i <= 100.; i++) {
            occ[i-1] = occurence(i, typestable);
        }
        int res = 0;
        for (int ans = 1; ans <= m; ans++) {
            s = 0;
            for (int i = 1; i <= 100; i++) {
                s += occ[i-1] / ans;
            }
            if (s >= n) {
                res = ans;
            }
        }
        System.out.println(res);

    }

    static int[] parseArray(BufferedReader gi) throws IOException {
        String[] line = gi.readLine().trim().split(" ");
        int[] rez = new int[line.length];
        for (int k = 0; k < line.length; k++) {
            rez[k] = Integer.parseInt(line[k]);
        }
        return rez;
    }

    static int occurence(int ent, int[] tab) {
        int occ = 0;
        for (int i = 0; i < tab.length; i++) {
            if (tab[i] == ent) {
                occ++;
            }
        }
        return occ;
    }

}


import java.util.Scanner;
import java.util.*;

public class T1 {
	public static void main(String args[]) {
		Scanner abc = new Scanner(System.in);
		ArrayList seq = new ArrayList();
		seq.add(0);
		for (int i = 1; i <= 1000; i++) {

			if (i < 10){
				seq.add(i);
			}
			else if (i >= 10 && i < 100) {
				int j = i/10;
					seq.add(j);
					seq.add(i - (j * 10));

			} else if (i >= 100 && i < 1000) {
				int j = i/100;
					seq.add(j);
					seq.add((i - (j * 100))/10);
					seq.add(i - (j * 100)-(((i - (j * 100))/10)*10));

			}else if (i>=1000){
				seq.add(1);
				seq.add(0);
				seq.add(0);
				seq.add(0);
			}
		}
		int n = abc.nextInt();
		System.out.println(seq.get(n));
	}
}


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

public class CF {

	int MAX = 50;

	long[][] power(long n) {
		if (n == 0) {
			long[][] res = new long[MAX][MAX];
			for (int i = 0; i < MAX; i++)
				for (int j = 0; j < MAX; j++)
					if (i != j)
						res[i][j] = Long.MAX_VALUE / 3;
					else
						res[i][j] = 0;
			return res;
		} else {
			if (n == 1) {
				return resOne;
			} else {
				long[][] r1 = power(n / 2);
				long[][] r2 = mul(r1, r1);
				if (n % 2 == 1) {
					r2 = mul(r2, resOne);
				}
				return r2;
			}
		}
	}

	long[][] mul(long[][] a, long[][] b) {
		long[][] res = new long[MAX][MAX];
		for (int i = 0; i < MAX; i++)
			Arrays.fill(res[i], Long.MAX_VALUE / 3);
		for (int i = 0; i < MAX; i++)
			for (int j = 0; j < MAX; j++)
				for (int k = 0; k < MAX; k++)
					res[i][k] = Math.min(res[i][k], a[i][j] + b[j][k]);
		return res;
	}

	long[][] resOne = new long[MAX][MAX];

	void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		int[] b = new int[n];
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		int cntHave = m;
		long[][] dx = new long[MAX][MAX];
		for (int i = 0; i < dx.length; i++)
			Arrays.fill(dx[i], Long.MAX_VALUE / 2);
		for (int st = 0; st < 1 << n; st++) {
			int curB = 0;
			int minB = 0;
			int cost = 0;
			for (int i = 0; i < n; i++)
				if (((1 << i) & st) == 0) {
					curB++;
					cost += a[i];
				} else {
					curB--;
					minB = Math.min(minB, curB);
					cost += b[i];
				}
			dx[25 + minB][25 + curB] = Math.min(dx[25 + minB][25 + curB], cost);
		}
		for (int i = 0; i < MAX; i++)
			Arrays.fill(resOne[i], Long.MAX_VALUE / 3);
		for (int i = 0; i < MAX; i++)
			for (int j = 0; j < MAX; j++) {
				int curB = 25 + (j - i);
				if (curB < 0 || curB >= MAX)
					continue;
				for (int sub = Math.max(0, 25 - i); sub < MAX; sub++)
					resOne[i][j] = Math.min(resOne[i][j], dx[sub][curB]);
			}

		long[][] res = power(cntHave);
		out.println(res[0][0]);
	}

	FastScaner in;
	PrintWriter out;

	void run() {
		in = new FastScaner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	void runWithFiles() {
		in = new FastScaner(new File("input.txt"));
		try {
			out = new PrintWriter(new File("output.txt"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		solve();

		out.close();
	}

	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new CF().run();
	}

	class FastScaner {
		BufferedReader br;
		StringTokenizer st;

		FastScaner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

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

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

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

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

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


import java.util.Scanner;

public class Codeforce {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    String c= sc.nextLine();
    String[] k= c.split(" ");
    int l=Integer.parseInt(k[0]);
    int r=Integer.parseInt(k[1]);
    int a=Integer.parseInt(k[2]);
    if(l==r)
    {
        if((a % 2)==1)
        {
            a--;
        }
        System.out.println(l+r+a);
    }
    else
    {
        int m = l>r ? r : l;
        int n = l>r ? l : r;
        if((m+a)<=n)
        {
            System.out.println((m+a)*2);
        }
        else
        {
            int e=(((m+a)-n));
            if((e % 2)==1)
            {
                e--;
            }
            System.out.println((n*2)+e);
        }
    }

    }

}


import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.System.exit;

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

public class D {

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

	static void solve() throws Exception {
		int m = scanInt() + 1, a = scanInt(), b = scanInt();
		int cnt[] = new int[a + b];
		for (int i = 0, j = 0;;) {
			++cnt[j];
			if (i >= b) {
				i -= b;
			} else {
				i += a;
			}
			if (i == 0) {
				break;
			}
			j = max(j, i);
		}
		for (int i = 1; i < a + b; i++) {
			cnt[i] += cnt[i - 1];
		}
		long ans = 0;
		for (int i = 0; i < a + b && i < m; i++) {
			ans += cnt[i];
		}
		if (m > a + b) {
			int g = gcd(a, b);
			int from = (a + b) / g, to = m / g;
			ans += (long) (from + to + 1) * (to - from) / 2 * g;
			ans += (long) (m % g) * (to + 1);
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

import javax.naming.InitialContext;

public class C
{
	public static void main(String [] args) throws IOException
	{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);

		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int l1 = Integer.parseInt(tokenizer.nextToken()) - 1;
		int r1 = Integer.parseInt(tokenizer.nextToken()) - 1;
		int l2 = Integer.parseInt(tokenizer.nextToken()) - 1;
		int r2 = Integer.parseInt(tokenizer.nextToken()) - 1;

		System.out.println(rec((1<<30)-1, l1, r1, l2, r2));
	}

	private static int rec(int len, int l1, int r1, int l2, int r2)
	{
		if(r1 < l1 || r2 < l2)
			return 0;
		if(len == 1)
			return 1;
		if(l1 >= l2 && r1 <= r2)
			return r1-l1+1;
		if(l2 >= l1 && r2 <= r1)
			return r2-l2+1;

		int mid = len/2;

		if(l1 > l2)
			return rec(len, l2, r2, l1, r1);

		if(r1 < mid && r2 < mid)
			return rec(len/2, l1, r1, l2, r2);
		if(l1 > mid && l2 > mid)
			return rec(len/2, l1-mid-1, r1-mid-1, l2-mid-1, r2-mid-1);

		if(r1 < mid && l2 > mid)
			return rec(len/2, l1, r1, l2-mid-1, r2-mid-1);
		if(r1 < mid && l2 <= mid && r2 >= mid)
			return Math.max(rec(len/2, l1, r1, l2, mid-1), rec(len/2, l1, r1, 0, r2-mid-1));

		if(l2 > mid)
			return Math.max(rec(len/2, l1, mid-1, l2-mid-1, r2-mid-1), rec(len/2, 0, r1-mid-1, l2-mid-1, r2-mid-1));

		return Math.max(r1-l2+1, Math.max(rec(len/2, l1, mid-1, 0, r2-mid-1), rec(len/2, l2, mid-1, 0, r1-mid-1)));
	}
}


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

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

    static class CHexadecimalsNumbers {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long n = in.nextLong();
            Queue<Long> q = new LinkedList<>();
            q.offer(1L);
            long ans = 0;
            while (!q.isEmpty()) {
                long p = q.poll();
                ans++;

                p *= 10;
                if (p <= n) {
                    q.offer(p);
                }
                if (p + 1 <= n) {
                    q.offer(p + 1);
                }
            }
            out.println(ans);
        }

    }

    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 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 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 class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

    }
}


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

public class bobsAndStages {

	class Bubble {
		int x, y;
		int id1, id2;

		public Bubble(int x, int y) {
			this.x = x;
			this.y = y;
		}

		int q() {
			if (x == 0 && y == 0) {
				return 0;
			} else if (x > 0 || (x == 0 && y > 0)) {
				return 1;
			} else {
				return 2;
			}
		}
		@Override
		public String toString() {
			return "Bubble [x=" + x + ", y=" + y + ", id1=" + id1 + ", id2=" + id2 + "]";
		}
	}

	long vectMul(Bubble a, Bubble b) {
		return 1L * a.x * b.y - 1L * a.y * b.x;
	}

	long vectMul(Bubble a, Bubble b, Bubble c) {
		return 1L * (b.x - a.x) * (c.y - a.y) - 1L * (b.y - a.y) * (c.x - a.x);
	}

	void solve() {
		int n = in.nextInt();
		int k = in.nextInt();
		Bubble[] a = new Bubble[n];
		for (int i = 0; i < n; i++) {
			a[i] = new Bubble(in.nextInt(), in.nextInt());
		}
		Arrays.sort(a, (p1, p2) -> {
			if (p1.x != p2.x) {
				return p1.x - p2.x;
			}
			return p1.y - p2.y;
		});

		long result = 0;
		long[][] dp = new long[n][k + 1];
		long[][] cost = new long[n][n];
		long INF = Long.MIN_VALUE / 3;
		Bubble[] buf = new Bubble[n];
		for (int i = 0; i < buf.length; i++) {
			buf[i] = new Bubble(0, 0);
		}
		Bubble[] vecs = new Bubble[n * (n - 1)];
		for (int i = 0, tmp = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j) {
					vecs[tmp] = new Bubble(a[j].x - a[i].x, a[j].y - a[i].y);
					vecs[tmp].id1 = i;
					vecs[tmp].id2 = j;
					tmp++;
				}
			}
		}
		Arrays.sort(vecs, (p1, p2) -> {
			int q1 = p1.q(), q2 = p2.q();
			if (q1 != q2) {
				return q1 - q2;
			}
			return -Long.signum(vectMul(p1, p2));
		});
		for (int start = 0; start < n; start++) {
			for (int i = n - 1; i >= start; i--) {
				a[i].x -= a[start].x;
				a[i].y -= a[start].y;
			}
			for (int i = 0; i < n; i++) {
				Arrays.fill(dp[i], INF);
				Arrays.fill(cost[i], INF);
			}
			dp[start][0] = 0;

			int size = 0;
			for (int i = start + 1; i < n; i++) {
				buf[size].x = a[i].x;
				buf[size].y = a[i].y;
				buf[size].id1 = i;
				size++;
			}
			Arrays.sort(buf, 0, size, (p1, p2) -> {
				long v = vectMul(p1, p2);
				return -Long.signum(v);
			});

			for (int i = 0; i < size; i++) {
				for (int j = i + 1; j < size; j++) {
					int p1 = buf[i].id1, p2 = buf[j].id1;
					boolean ok = true;
					for (int t = i + 1; t < j; t++) {
						if (vectMul(buf[i], buf[j], buf[t]) > 0) {
							ok = false;
							break;
						}
					}
					if (ok) {
						cost[p1][p2] = vectMul(buf[i], buf[j]);
					}
				}
			}
			for (int i = 0; i < size; i++) {
				cost[start][buf[i].id1] = cost[buf[i].id1][start] = 0;
			}

			for (Bubble vec : vecs) {
				int p1 = vec.id1, p2 = vec.id2;
				long cst = cost[p1][p2];
				if (cst != INF) {
					long[] dp1 = dp[p1], dp2 = dp[p2];
					for (int i = 0; i < k; i++) {
						dp2[i + 1] = Math.max(dp2[i + 1], dp1[i] + cst);
					}
				}
			}
			result = Math.max(result, dp[start][k]);
		}

		out.printf("%d.%02d\n", result / 2, 50 * (result % 2));
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

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

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

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

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

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


import java.io.*;
import java.util.*;
public class result
{
    public static void main(String[] args)
    {
        int x,y,z;
        boolean flag = false;
        Scanner sc=new Scanner(System.in);
        x=sc.nextInt();
        y=sc.nextInt();
        z=sc.nextInt();
        if(z==0)
        {
            if(x>y)
            {
                System.out.println("+");
                flag=true;
            }
            else if(x<y)
            {
                System.out.println("-");
                flag=true;
            }
            else if(x==y)
            {
                System.out.println("0");
                flag=true;
            }
        }
        else
        {
            if(x+z>=y&&y+z>=x)
            {
                System.out.println("?");
                flag=true;
            }
            else if(x+z>y)
            {
                System.out.println("+");
                flag=true;
            }
            else if(y+z>x)
            {
                System.out.println("-");
                flag=true;
            }
        }
        if(flag==false)
        {
            System.out.println("?");
        }
    }
}


//package school3;

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

public class F5 {
	Scanner in;
	PrintWriter out;
//	String INPUT = "100000 4";
//	String INPUT = "0 1";
	String INPUT = "";

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

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

	void solve()
	{
		int m = ni();
		int n = ni();
		if(m <= 0){
			out.println(1);
			return;
		}
		if(n <= 1){
			out.println(-1);
			return;
		}

//		for(int i = 0;i <= 3 * m;i++){
//			int[] co = dec(i, m);
//			tr(co);
//			if(enc(co[0], co[1], m) != i){
//				tr("out!",i);
//			}
//		}

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

		if(n <= Math.sqrt(Math.sqrt(m))){
			solveH(m, n);
		}else{
			solveB(m, n);
		}
	}

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

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

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

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

	void solveH(int m, int n){

		// (a, 0), (a, a), (a, m)
		HashSet<Integer> visitedo = new HashSet<Integer>();
		HashSet<Integer> visitedh = new HashSet<Integer>();
		HashSet<Integer> q = new HashSet<Integer>();
		q.add(0);
		boolean iso = true;
		int step = 0;

		while(!q.isEmpty()){
			if(!iso && q.contains(2 * m))break;
//			tr(step, q);
			HashSet<Integer> nq = new HashSet<Integer>();
			if(iso){
				visitedh.addAll(q);
			}else{
				visitedo.addAll(q);
			}
			for(int cur : q){
				int[] co = dec(cur, m);
				if(iso){
					{
						if(co[1] == 0){
							int inf = co[0] + 1;
							int sup = Math.min(m, co[0] + n);
							if(inf <= sup){
								for(int i = enc(inf, 0, m);i <= enc(sup, 0, m);i++){
									nq.add(i);
								}
							}
						}
					}
					{
						int inf = Math.max(co[0], co[1]);
						if(co[0] == co[1])inf++;
						int sup = Math.min(m, (n + co[0] + co[1]) / 2);

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

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

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

		out.println(INPUT);
		solve();
		out.flush();
	}

	public static void main(String[] args) throws Exception
	{
		new F5().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.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

 public class CandidateCode {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long sum=0;
        for (int i=2;i<n;i++){
            int x=i*(i+1);
            sum+=x;
        }
        System.out.println(sum);
    }
}


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

public class e {
    public static int M = 10;
    public static void main(String[] args) throws Exception{
        FS sc = new FS(System.in);
        int n = sc.nextInt(), i;
        int[] arr = new int[n];
        for (i = 0; i < n; i++)
            arr[i] = sc.nextInt();
        Arrays.sort(arr);
        for (i = 0; i <= n/2; i++) {
            if (arr[i] != arr[0]) {
                System.out.println("Alice");
                return;
            }
        }
        System.out.println("Bob");
    }
    public static int gcd(int a, int b) {
        return (b == 0) ? a : gcd(b, a % b);
    }
    public static class FS {
        BufferedReader br;
        StringTokenizer st;
        FS(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = new StringTokenizer("");
        }
        String next() throws Exception {
            if (st.hasMoreTokens())
                return st.nextToken();
            st = new StringTokenizer(br.readLine());
            return next();
        }
        int nextInt() throws Exception {
            return Integer.parseInt(next());
        }
    }
}


//package codeforces;

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

/**
 * Created by nitin.s on 09/10/16.
 */
public class PashaAndHamsters {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), a = in.nextInt(), b = in.nextInt();
        int[] res = new int[n + 1];
        Arrays.fill(res, -1);
        for(int i = 0; i < a; ++i) {
            int apple = in.nextInt();
            if(res[apple] != -1) continue;
            res[apple] = 1;
        }
        for(int i = 0; i < b; ++i) {
            int apple = in.nextInt();
            if(res[apple] != -1) continue;
            res[apple] = 2;
        }
        for(int i = 1; i <= n; ++i) {
            System.out.print(res[i] + " ");
        }
    }
}


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Program {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);
        String str = inp.next();
        System.out.println(process(str));
    }

    public static String process(String str) {
        if (str.length() < 26) {
            return "-1";
        }
        int[] count = new int[26];
        for (int num : count) {
            num = 0;
        }
        int cntQuestions = 0;
        for (int i = 0; i < 25; ++i) {
            if (str.charAt(i) == '?') {
                ++cntQuestions;
            }
            else {
                ++count[str.charAt(i) - 'A'];
            }
        }
        for (int i = 25; i < str.length(); ++i) {
            if (str.charAt(i) == '?') {
                ++cntQuestions;
            }
            else {
                ++count[str.charAt(i) - 'A'];
            }

            int curCnt = 0;
            for (int num : count) {
                if (num != 0) {
                    ++curCnt;
                }
            }
            if (curCnt + cntQuestions == 26) {
                String piece = "";
                int pos = 0;
                for (int k = i - 25; k <= i; ++k) {
                    if (str.charAt(k) == '?') {
                        while (count[pos] != 0) {
                            ++pos;
                        }
                        piece += (char)(pos + 'A');
                        ++pos;
                    }
                    else {
                        piece += str.charAt(k);
                    }
                }

                str = str.substring(0, i - 25) + piece + str.substring(i + 1, str.length());
                return str.replace("?", "A");
            }

            if (str.charAt(i - 25) != '?') {
                --count[str.charAt(i - 25) - 'A'];
            }
            else {
                --cntQuestions;
            }
        }
        return "-1";
    }
}


import java.util.Scanner;

public class main {

    public static void main(String[] args) {
        int first_number;
        int second_number;
        String  first = "";
        String rezult = "";
        String kol_number;
        String[] kol_split_number;
        String need_number;
        String[] need_split_number;

        Scanner in          = new Scanner(System.in);
        //first_number        = in.nextInt();
        //second_number       = in.nextInt();
        first               = in.nextLine();
        kol_number          = in.nextLine();
        kol_split_number    = kol_number.split(" ");
        need_number         = in.nextLine();
        need_split_number   = need_number.split(" ");

        for (String i : kol_split_number) {
            for (String j : need_split_number) {
                if ( i.equals(j) ) {
                    rezult = rezult + " " + i;
                }
            }
        }
        System.out.println(rezult);
    }

}


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.io.StreamTokenizer;
import java.util.ArrayList;

public class main{

    public static void main(String[] args) throws IOException {
        a w = new a();
        w.f();
    }

}
class a{
    StreamTokenizer in;
    PrintWriter out;
    int n, a, b, k, flag;
    long inf;
    long[][] res;
    long[] sum;
    int[][] find;
    int nextInt() throws IOException{
        in.nextToken();
        return (int) in.nval;
    }
    long dp(int ind){
        return ((sum[find[ind][1]] - sum[find[ind][0]] + inf) % inf - res[(flag + 1) % 2][ind] + inf) % inf;
    }
    void f() throws IOException{
        in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        n = nextInt();
        a = nextInt();
        b = nextInt();
        k = nextInt();
        flag = 0;
        find = new int[n][2];
        for (int i = 0; i < n; i++){
            int l = -1; int r = n + 1;
            for (int j = 0; j < n; j++){
                if ((l == -1) && (Math.abs(i - j) < Math.abs(j - b + 1))){
                    l = j;
                } else if ((l != -1) && (Math.abs(i - j) >= Math.abs(j - b + 1))){
                    r = j;
                    break;
                }
            }
            find[i][0] = Math.max(l, 0); find[i][1] = Math.min(r, n);
        }
        inf = 1000000000 + 7;
        sum = new long[n + 1];
        res = new long[2][n];
        res[1][a - 1] = 1;
        for (int i = 0; i < n; i++){
            if (Math.abs(a - 1 - i) < Math.abs(a - b)){
                res[1][i] = 1;
            }
        }
        res[1][a - 1] = 0;
        sum[1] = res[(flag + 1) % 2][0];
        for (int j = 2; j <= n; j++){
            sum[j] = sum[j - 1] + res[(flag + 1) % 2][j - 1];
        }

        for (int i = 0; i < k - 1; i++){
            for (int j = 0; j < n; j++){
                if (j != b - 1){
                    res[flag % 2][j] = dp(j);
                }
            }
            flag++;
            sum[1] = res[(flag + 1) % 2][0];
            for (int j = 2; j <= n; j++){
                sum[j] = (sum[j - 1] + res[(flag + 1) % 2][j - 1]) % inf;
            }
        }
        out.println(sum[n]);
        out.flush();
        out.close();
    }
}


//package eightvc.f;
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 F {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	char[] s;
	int pos, len;
	int mod = 1000000007;
	int emod = mod-1;
	long modx = (long)mod*emod;

	long[] tm = new long[64];

	long tes(long nume, long mul)
	{
		long B = mul;
		long s0 = 1;
		long s1 = 0;
		long res1 = 0;
		for(int d = 0;d < 63;d++){
			if(nume<<~d<0){
				res1 = (res1 * B + s1 + s0*((nume&(1L<<d)-1)%mod)) % mod;
			}
//			s1 = (s1 * (B+1) + (s0<<d)) % mod;
			s1 = (s1 * (B+1) + s0*((1L<<d)%mod)) % mod;
			s0 = s0 * (B+1) % mod;
			B = B * B % mod;
		}
		return res1;
	}

	void solve()
	{
		for(int i = 0;i < 63;i++){
			tm[i] = (1L<<i)%mod;
		}

		s = ns().toCharArray();
		pos = 0; len = s.length;
		Modnum res = expr();
		assert pos == len;
		out.println(res.v);
	}

	Modnum expr()
	{
		Modnum t = term();
		while(pos < len && s[pos] == '+'){
			pos++;
			Modnum lt = term();
			t = concat(t, lt);
		}
		return t;
	}

	Modnum term()
	{
		Modnum n = number();
		if(pos < len && s[pos] == '-'){
			pos++;
			Modnum ln = number();
			return range(n, ln);
		}
		if(pos < len && s[pos] == '('){
			pos++;
			Modnum e = expr();
			assert s[pos] == ')';
			pos++;
			return repeat(e, n);
		}
		return n;
	}

	long mul10(long v)
	{
		long v2 = v + v;
		if(v2 >= modx)v2 -= modx;
		v = v2 * 5;
		while(v >= modx)v -= modx;
		return v;
	}

	Modnum number()
	{
		long vx = 0;
		int nlen = 0;
		while(pos < len && s[pos] >= '0' && s[pos] <= '9'){
			vx = mul10(vx) + (s[pos]-'0');
			if(vx >= modx)vx -= modx;
			nlen++;
			pos++;
		}
		assert nlen != 0;
		return new Modnum(vx%mod, nlen, vx);
	}

	Modnum concat(Modnum a, Modnum b)
	{
		return new Modnum(
				(a.v * pow(10, b.len, mod) + b.v)% mod,
				(a.len + b.len) % emod
		);
	}

	Modnum range(Modnum a, Modnum b)
	{
		Modnum ret = new Modnum(0, 0);
		long t = pow(10, a.len, mod);
		long px = powSafe(10, a.len-1, modx);
		for(long i = a.len;i <= b.len;i++){
			long npx = mul10(px);
			long inf = i == a.len ? a.vx : px;
			long sup = i == b.len ? b.vx : npx-1;
			if(sup < 0)sup += modx;

			long num = sup-inf+1;
			if(num < 0)num += modx;
			long base = (inf%mod)*sumGP(t, num, mod)%mod;
			// 0 1 ... sup-inf

			num %= modx;
			long mul = t;
			long B = mul;
			long s0 = 1;
			long s1 = 0;
			long res1 = 0;
			long q = 0;
			for(int d = 0;d < 63;d++){
				if(num<<~d<0){
					res1 = (res1 * B + s1 + s0*q) % mod;
					q += tm[d];
					if(q >= mod)q -= mod;
				}
				s1 = (s1 * (B+1) + s0*tm[d]) % mod;
				s0 = s0 * (B+1) % mod;
				B = B * B % mod;
			}
			t = t * 10 % mod;
			px = npx;

			ret = concat(ret, new Modnum((base+res1)%mod, i*(num%emod)%emod));
		}
		return ret;
	}

	Modnum repeat(Modnum a, Modnum rep)
	{
		return new Modnum(
				sumGP(pow(10, a.len, mod), rep.vx, mod) * a.v % mod,
				a.len*(rep.vx%emod)%emod
				);
	}

	public static class Modnum
	{
		public long v;
		public long vx;
		public long len;
		public Modnum(long v, long len) {
			this.v = v;
			this.len = len;
		}
		public Modnum(long v, long len, long vx) {
			this.v = v;
			this.len = len;
			this.vx = vx;
		}
		@Override
		public String toString() {
			return "Datum [v=" + v + ", len=" + len + "]";
		}
	}

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

	public static long mul(long a, long b, long mod)
	{
		if(a >= mod || a < 0)a %= mod;
		if(a < 0)a += mod;
		if(b >= mod || b < 0)b %= mod;
		if(b < 0)b += mod;

		long ret = 0;
		int x = 63-Long.numberOfLeadingZeros(b);
		for(;x >= 0;x--){
			ret += ret;
			if(ret >= mod)ret -= mod;
			if(b<<~x<0){
				ret += a;
				if(ret >= mod)ret -= mod;
			}
		}
		return ret;
	}

	public static long mulEx(long a, long b, long mod)
	{
		if(a >= mod || a < 0)a %= mod;
		if(a < 0)a += mod;
		if(b >= mod || b < 0)b %= mod;
		if(b < 0)b += mod;

		long ret = 0;
		int x = 63-Long.numberOfLeadingZeros(b);
		for(;x >= 0;x--){
			ret += ret;
			if(Long.compareUnsigned(ret, mod) >= 0)ret -= mod;
			if(b<<~x<0){
				ret += a;
				if(Long.compareUnsigned(ret, mod) >= 0)ret -= mod;
			}
		}
		return ret;
	}

	public static long sumGP(long a, long n, long mod)
	{
		long smul = 1; // % mod
		long mul = a % mod;
		long ret = 0;
		for(;n > 0;n >>>= 1){
			if((n&1)==1){
				ret = (ret * mul + smul) % mod;
			}
			smul = smul * (mul + 1) % mod;
			mul = mul * mul % mod;
		}
		return ret;
	}

	public static long pow(long a, long n, long mod) {
		//		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 F().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)); }
}