import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Iterator;
import java.io.IOException;
import java.util.Arrays;
import java.io.InputStream;
import java.util.Random;
import java.util.Map;
import java.io.OutputStreamWriter;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Set;

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

class TaskE {
    private int count;
    private int k;
    private long S;
    private int[] A;
    private long[] factor;
    private Counter<Long>[] total;
    private long answer = 0;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        count = in.readInt();
        k = in.readInt();
        S = in.readLong();
        A = IOUtils.readIntArray(in, count);
        factor = IntegerUtils.generateFactorial(19, Long.MAX_VALUE);
        total = new Counter[k + 1];
        for (int i = 0; i <= k; i++) {
            total[i] = new Counter<Long>();
        }

        int mid = count / 2;
        dfs(0, mid, 0, 0L);
        dfs2(mid, count, 0, 0L);
        out.printLine(answer);
    }

    private void dfs2(int cur, int target, int use, long sum) {
        if (sum > S) {
            return;
        }
        if (cur >= target) {
            for (int i = use; i <= k; i++) {
                answer += total[i - use].get(S - sum);
            }
            return;
        }
        dfs2(cur + 1, target, use, sum);
        dfs2(cur + 1, target, use, sum + A[cur]);
        if (A[cur] < 19 && use < k) {
            dfs2(cur + 1, target, use + 1, sum + factor[A[cur]]);
        }
    }

    private void dfs(int cur, int target, int use, long sum) {
        if (sum > S) {
            return;
        }
        if (cur >= target) {
            total[use].add(sum);
            return;
        }
        dfs(cur + 1, target, use, sum);
        dfs(cur + 1, target, use, sum + A[cur]);
        if (A[cur] < 19 && use < k) {
            dfs(cur + 1, target, use + 1, sum + factor[A[cur]]);
        }
    }
}

class Counter<K> extends EHashMap<K, Long> {
    public Counter() {
        super();
    }

    public long add(K key) {
        long result = get(key);
        put(key, result + 1);
        return result + 1;
    }

    public Long get(Object key) {
        if (containsKey(key))
            return super.get(key);
        return 0L;
    }
}

class InputReader {

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

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

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

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

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

class OutputWriter {
    private final PrintWriter writer;

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

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

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

}

class IOUtils {

    public static int[] readIntArray(InputReader in, int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++)
            array[i] = in.readInt();
        return array;
    }

}

class IntegerUtils {

    public static long[] generateFactorial(int count, long module) {
        long[] result = new long[count];
        if (module == -1) {
            if (count != 0)
                result[0] = 1;
            for (int i = 1; i < count; i++)
                result[i] = result[i - 1] * i;
        } else {
            if (count != 0)
                result[0] = 1 % module;
            for (int i = 1; i < count; i++)
                result[i] = (result[i - 1] * i) % module;
        }
        return result;
    }

}

class EHashMap<E, V> extends AbstractMap<E, V> {
    private static final int[] shifts = new int[10];

    private int size;
    private HashEntry<E, V>[] data;
    private int capacity;
    private Set<Entry<E, V>> entrySet;

    static {
        Random random = new Random(System.currentTimeMillis());
        for (int i = 0; i < 10; i++)
            shifts[i] = 1 + 3 * i + random.nextInt(3);
    }

    public EHashMap() {
        this(4);
    }

    private void setCapacity(int size) {
        capacity = Integer.highestOneBit(4 * size);
        //noinspection unchecked
        data = new HashEntry[capacity];
    }

    public EHashMap(int maxSize) {
        setCapacity(maxSize);
        entrySet = new AbstractSet<Entry<E, V>>() {
            public Iterator<Entry<E, V>> iterator() {
                return new Iterator<Entry<E, V>>() {
                    private HashEntry<E, V> last = null;
                    private HashEntry<E, V> current = null;
                    private HashEntry<E, V> base = null;
                    private int lastIndex = -1;
                    private int index = -1;

                    public boolean hasNext() {
                        if (current == null) {
                            for (index++; index < capacity; index++) {
                                if (data[index] != null) {
                                    base = current = data[index];
                                    break;
                                }
                            }
                        }
                        return current != null;
                    }

                    public Entry<E, V> next() {
                        if (!hasNext())
                            throw new NoSuchElementException();
                        last = current;
                        lastIndex = index;
                        current = current.next;
                        if (base.next != last)
                            base = base.next;
                        return last;
                    }

                    public void remove() {
                        if (last == null)
                            throw new IllegalStateException();
                        size--;
                        if (base == last)
                            data[lastIndex] = last.next;
                        else
                            base.next = last.next;
                    }
                };
            }

            public int size() {
                return size;
            }
        };
    }

    public Set<Entry<E, V>> entrySet() {
        return entrySet;
    }

    public void clear() {
        Arrays.fill(data, null);
        size = 0;
    }

    private int index(Object o) {
        return getHash(o.hashCode()) & (capacity - 1);
    }

    private int getHash(int h) {
        int result = h;
        for (int i : shifts)
            result ^= h >>> i;
        return result;
    }

    public V remove(Object o) {
        if (o == null)
            return null;
        int index = index(o);
        HashEntry<E, V> current = data[index];
        HashEntry<E, V> last = null;
        while (current != null) {
            if (current.key.equals(o)) {
                if (last == null)
                    data[index] = current.next;
                else
                    last.next = current.next;
                size--;
                return current.value;
            }
            last = current;
            current = current.next;
        }
        return null;
    }

    public V put(E e, V value) {
        if (e == null)
            return null;
        int index = index(e);
        HashEntry<E, V> current = data[index];
        if (current != null) {
            while (true) {
                if (current.key.equals(e)) {
                    V oldValue = current.value;
                    current.value = value;
                    return oldValue;
                }
                if (current.next == null)
                    break;
                current = current.next;
            }
        }
        if (current == null)
            data[index] = new HashEntry<E, V>(e, value);
        else
            current.next = new HashEntry<E, V>(e, value);
        size++;
        if (2 * size > capacity) {
            HashEntry<E, V>[] oldData = data;
            setCapacity(size);
            for (HashEntry<E, V> entry : oldData) {
                while (entry != null) {
                    HashEntry<E, V> next = entry.next;
                    index = index(entry.key);
                    entry.next = data[index];
                    data[index] = entry;
                    entry = next;
                }
            }
        }
        return null;
    }

    public V get(Object o) {
        if (o == null)
            return null;
        int index = index(o);
        HashEntry<E, V> current = data[index];
        while (current != null) {
            if (current.key.equals(o))
                return current.value;
            current = current.next;
        }
        return null;
    }

    public boolean containsKey(Object o) {
        if (o == null)
            return false;
        int index = index(o);
        HashEntry<E, V> current = data[index];
        while (current != null) {
            if (current.key.equals(o))
                return true;
            current = current.next;
        }
        return false;
    }

    public int size() {
        return size;
    }

    private static class HashEntry<E, V> implements Entry<E, V> {
        private final E key;
        private V value;
        private HashEntry<E, V> next;

        private HashEntry(E key, V value) {
            this.key = key;
            this.value = value;
        }

        public E getKey() {
            return key;
        }

        public V getValue() {
            return value;
        }

        public V setValue(V value) {
            V oldValue = this.value;
            this.value = value;
            return oldValue;
        }
    }
}


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

public class codeforce519A {

    static PrintWriter out;
    static StreamTokenizer sin;
    static BufferedReader bin;

    static void setupOut() {
        out = new PrintWriter(System.out);
    }

    static void setupString() {
        bin = new BufferedReader(new InputStreamReader(System.in));
    }

    public static void main(String[] args) throws IOException {
        setupOut();
        setupString();
        Scanner in = new Scanner(System.in);
        int x = 0;
        int y = 0;

        for (int i = 0; i < 8; i++) {
            String s = in.next();
            for (int j = 0; j < 8; j++) {
                char c = s.charAt(j);
                if (c=='Q')
                    x+=9;
                if (c=='R')
                    x+=5;
                if (c=='B')
                    x+=3;
                if (c=='N')
                    x+=3;
                if (c=='P')
                    x+=1;
                if (c=='q')
                    y+=9;
                if (c=='r')
                    y+=5;
                if (c=='n')
                    y+=3;
                if (c=='p')
                    y+=1;
                if (c=='b'){
                    y+=3;
                }

            }
        }
        if (x==y)
            out.print("Draw");
        if (x>y)
            out.print("White");
        if (x<y)
            out.print("Black");
        out.flush();
    }

}


import java.util.*;
public class a {
public static void main(String[] args)
{
  Scanner input = new Scanner(System.in);
  int n = input.nextInt();
  int[] mins = new int[3], maxs = new int[3];
  for(int  i= 0; i<3; i++)
  {
    mins[i] = input.nextInt();
    maxs[i] = input.nextInt();
  }
  int[] res = new int[3];
  res[0] = Math.min(n - mins[1] - mins[2], maxs[0]);
  n -= res[0];
  res[1] = Math.min(n - mins[2], maxs[1]);
  n -= res[1];
  res[2] = n;
  System.out.println(res[0]+" "+res[1]+" "+res[2]);
}
}


import java.util.*;
public class untitled {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong(), m = in.nextLong(), a = in.nextLong(), b = in.nextLong();
		long price1, price2;

		if(n%m == 0)
		{
			System.out.println(0);
			return;
		}

		price1 = n%m * b;
		price2 = (m - n%m) * a;

		System.out.println(price1 < price2 ? price1:price2);
	}
}


import java.util.Scanner;

public class MainB {
	Scanner sc = new Scanner(System.in);

	void run() {
		int v1 = sc.nextInt();
		int v2 = sc.nextInt();
		int t = sc.nextInt();
		int d = sc.nextInt();

		int now = v1;
		int max = now;
		for (int i = 1; i < t; i++) {
			for (int j = d; j >= -d; j--) {
				int next = now + j;
				int remmin = (t - i - 1) * d;
				if (next - remmin > v2) {
					continue;
				}
				now = next;
				break;
			}
			max += now;
		}
		System.out.println(max);
	}

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


//package cf589d2;
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class E {
	static long MOD = 1000000007;
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[][] choose = new long[n + 1][n + 1];
		long[][] pow = new long[n + 1][2];
		for(int i = 0; i <= n; i++) {
			choose[i][0] = 1;
			choose[i][i] = 1;
		}
		for(int i = 2; i <= n; i++)
			for(int j = 1; j < i; j++)
				choose[i][j] = (choose[i - 1][j] + choose[i - 1][j - 1]) % MOD;
		for(int i = 0; i <= n; i++)
			for(int j = 0; j < 2; j++)
				pow[i][j] = pMod(k - j, i);
		long[][] dp = new long[n + 1][n + 1];
		dp[0][n] = 1;
		for(int i = 1; i <= n; i++)
			for(int j = 0; j <= n; j++)
				for(int l = 0; l <= j; l++) {
					long del = dp[i - 1][j] * choose[j][l] % MOD * pow[l][1] % MOD;
					if(l < j)
						del = del * pow[n - j][0] % MOD;
					else
						del = del * (pow[n - j][0] - pow[n - j][1] + MOD) % MOD;
					dp[i][l] = (dp[i][l] + del) % MOD;
				}
		out.println(dp[n][0]);
		out.close();
	}
	public static long pMod(long x, long p) {
		if(p == 0)
			return 1;
		long l = pMod(x, p / 2);
		return l * l % MOD * (p % 2 == 1 ? x : 1) % MOD;
	}
	public static PrintWriter out  = new PrintWriter(new BufferedOutputStream(System.out));
	public static class MyScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


import java.util.*;
public class b {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int n = input.nextInt(), d = input.nextInt();
    boolean[] possible = new boolean[1000000];
    possible[0] = true;
    int[] data = new int[n];
    for(int i = 0; i<n; i++) data[i] = input.nextInt();
    for(int i = 0; i<n; i++)
    {
        for(int j = 600000; j>=0; j--)
            if(possible[j])
                possible[j+data[i]] = true;
    }
    Queue<Integer> good = new LinkedList<Integer>();
    for(int i = 0; i<possible.length; i++) if(possible[i]) good.add(i);
    good.poll();
    int ans = 0, count = 0;
    while(!good.isEmpty())
    {
        if(good.peek() - ans > d) break;
        int next = good.poll();
        while(!good.isEmpty() && good.peek() - ans <= d)
        {
            next = good.poll();
        }
        ans = next;
        count++;
    }
    System.out.println(ans+" "+count);
}
}


import java.util.Scanner;

public class a {
	public static void main(String[]args) {
		Scanner input=new Scanner (System.in);
		int n=input.nextInt();
	    int b=0;
	    int c=0;
	    int []x=new int [101];
	    int k=0;
	    while (k<n) {
	    	 x[k]=input.nextInt();
	    	 k=k+1;
	    }
	    int y=x[0];
	    for (int t=1;t<n;t++) {
	    	if(x[t]<y)
	    		y=x[t];
	    }
	    if (y>=0) {
	    	for (int q=0;q<n;q++) {
	    	     b=b+x[q];
	    	}
	    	c=0;
	    }
	    else {
	    	for (int w=0;w<n;w++) {
	    		if (x[w]>=0)
	    			b=b+x[w];
	    		else c=c+x[w];
	    	}

	    }
	    System.out.print(b-c);
	}

}


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

public class B {
	static Scanner scan = new Scanner (System.in);
	static PrintStream out = System.out;

	public static void main (String[] args) {
		TreeMap<Integer, HashSet<Integer>> tm1 = new TreeMap<Integer, HashSet<Integer>>();
		TreeMap<Integer, HashSet<Integer>> tm2 = new TreeMap<Integer, HashSet<Integer>>();
		for (int i = 0; i < 8; ++i) {
			int d1 = scan.nextInt(), d2 = scan.nextInt();
			if (!tm1.containsKey(d1))
				tm1.put(d1, new HashSet<Integer>());
			tm1.get(d1).add(d2);
			if (!tm2.containsKey(d2))
				tm2.put(d2, new HashSet<Integer>());
			tm2.get(d2).add(d1);

		}
		if (tm1.size() != 3 || tm2.size() != 3) {
			out.println("ugly");
			return;
		}
		int index = 0;
		for (Integer i : tm1.keySet()) {
			++index;
			int c = tm1.get(i).size();
			if (index != 2 && c != 3) {
				out.println ("ugly");
				return;
			}
			if (index == 2 && c != 2) {
				out.println ("ugly");
				return;
			}
		}
		index = 0;
		for (Integer i : tm2.keySet()) {
			++index;
			int c = tm2.get(i).size();
			if (index != 2 && c != 3) {
				out.println ("ugly");
				return;
			}
			if (index == 2 && c != 2) {
				out.println ("ugly");
				return;
			}
		}
		out.println("respectable");
		return;
	}
}


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

public class utkarsh {

    InputStream is;
    PrintWriter out;

    long maxl = 1234567890987654321L, mod = 1000000007L;
    int p[], maxi = 1234567890, sz, np = 20000000;
    boolean b[];    // = isPrime();

    boolean check(int pos, int j){
        int i;
        j = (j / 50) % 475;
        for(i = 0; i < 25; i++){
            j = (j * 96 + 42) % 475;
            //out.print(26 + j +" ");
            if((26 + j) == pos){
                return true;
            }
        }
        return false;
    }

    void solve(){
        //Enter code here utkarsh
        //sz=sieve(); //sz=1270607;
        //out.println(sz);
        int pos, x, y, ans, i, j, k;
        pos = ni();
        x = ni();
        y = ni();
        ans = 0;
        k = 0;
        i = x;
        while(i >= y){
            if(check(pos, i)){
                out.println(0);
                return;
            }
            i -= 50;
        }
        if(x < y){
            j = (y - x + 99) / 100;
            ans += j;
            x += 100 * j;
            if((x - 50) >= y){
                x -= 50;
                k++;
            }
        }
        while(true){
            if(check(pos, x)){
                out.println(ans);
                break;
            }
            x += 50;
            k++;
            if(k % 2 == 1){
                ans++;
            }
        }
    }

    int sieve(){ int i, j, n = np; b = new boolean[n]; for(i = 3; i < n; i += 2){ b[i] = true; } b[2] = true; for(i = 3; i * i <= n; i += 2){ if(b[i]){ for(j = 2 * i; j < n; j += i){ b[j] = false; } } } p = new int[n]; p[0] = 2; j = 1; for(i = 3; i < n; i += 2){ if(b[i]){ p[j++] = i; } } p=Arrays.copyOf(p,j); return j;
    }
    long modpow(long base, long exp, long modulus) { base %= modulus; long result = 1L; while (exp > 0) { if ((exp & 1)==1) result = (result * base) % modulus; base = (base * base) % modulus; exp >>= 1; } return result;
    }

    public static void main(String[] args) { new utkarsh().run();
    }
    void run(){ is = System.in; out = new PrintWriter(System.out); solve(); out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte(){ if(ptr >= len){ ptr = 0; try{ len = is.read(input); }catch(IOException e){ throw new InputMismatchException(); } if(len <= 0){ return -1; } } return input[ptr++];
    }
    boolean isSpaceChar(int c){ return !( c >= 33 && c <= 126 );
    }
    int skip(){ int b = readByte(); while(b != -1 && isSpaceChar(b)){ b = readByte(); } return b;
    }

    char nc(){ return (char)skip();
    }
    String ns(){ int b = skip(); StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString();
    }
    int ni(){ int n = 0,b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } if(b == -1){ return -1; } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    long nl(){ long n = 0L; int b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    double nd(){ return Double.parseDouble(ns());
    }
    float nf(){ return Float.parseFloat(ns());
    }
    int[] na(int n){ int a[] = new int[n]; for(int i = 0; i < n; i++){ a[i] = ni(); } return a;
    }
    char[] ns(int n){ char c[] = new char[n]; int i,b = skip(); for(i = 0; i < n; i++){ if(isSpaceChar(b)){ break; } c[i] = (char)b; b = readByte(); } return i == n ? c : Arrays.copyOf(c,i);
    }
}


import java.util.Scanner;

public class Main
{
    private final static Main main = new Main();

    public static void main(String[] args)
    {
        long l = System.currentTimeMillis();
        main.answer();
        //System.err.println("経過時間：" + (System.currentTimeMillis() - l));
    }

    private void answer()
    {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        sc.close();
        int n = 0;
        for(int i=0; i<s1.toCharArray().length; ++i)
        {
            n += s1.charAt(i) == '+' ? 1 : -1;
        }
        int hatenaNum = 0;
        int position = 0;
        for(int i=0; i<s2.toCharArray().length; ++i)
        {
            char c = s2.charAt(i);
            if(c == '?')
            {
                ++hatenaNum;
            }
            else
            {
                position += c == '+' ? 1 : -1;
            }
        }
        if(position-hatenaNum <= n && n <= position+hatenaNum)
        {
            double success = 0.0;
            int count = 0;
            for(int i=0; i<1<<hatenaNum; ++i)
            {
                ++count;
                String binary = Integer.toBinaryString(i);
                for(int j=binary.length(); j<hatenaNum; ++j)
                {
                    binary = "0" + binary;
                }
                int p = position;
                char[] array = binary.toCharArray();
                for(char c : array)
                {
                    p += c == '0' ? 1 : -1;
                }
                success += p == n ? 1 : 0;
            }
            System.out.println(hatenaNum == 0 ? position == n ? 1.0 : 0.0 : success/count);
        }
        else
        {
            System.out.println(0.0);
        }
    }
}


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

public class JzzhuandChocolate {

	public static void main(String[] args) throws IOException {
		JzzhuandChocolate main = new JzzhuandChocolate();
		main.solve();
	}

	void solve() throws IOException {
		ReaderJzzhuandChocolate reader = new ReaderJzzhuandChocolate();
		reader.Init(System.in);
		long n = reader.NextLong();
		long m = reader.NextLong();
		long k = reader.NextLong();
		long res = 0;
		long smallest = 0;

		if (k > m + n - 2) {
			System.out.print(-1);
			return;
		}
		long temp = 0;
		long tempRes = 0;
		for (int i = 0; i < 2; i++) {
			if (k <= m - 1) {
				tempRes = n * (m / (k + 1));
			} else {
				tempRes = n / (k - (m -1) + 1);
			}
			temp = n;
			n = m;
			m = temp;
			res = Math.max(res, tempRes);
		}
		System.out.print(res);
	}
}

class ReaderJzzhuandChocolate {
	static BufferedReader reader;
	static StringTokenizer tokenizer;

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

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

	static int NextInt() throws IOException {
		return Integer.parseInt(Next());
	}

	static long NextLong() throws IOException {
		return Long.parseLong(Next());
	}

	static Double NextDouble() throws IOException {
		return Double.parseDouble(Next());
	}
}


import java.io.IOException;
import java.util.Scanner;

public class Main
{

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

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt(), b = sc.nextInt();
        System.out.println(remove(a + b) == remove(a) + remove(b) ?"YES":"NO");

}

    static int remove(int x)
    {
        int y = 0, f = 1;
        while(x > 0)
        {
            if(x%10 != 0)
            {
                y +=  x%10 * f;
                f *= 10;
            }

            x /= 10;
        }
        return y;
    }

}


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

public class GGWPLivaem implements Runnable{
    boolean withFiles = false;
    class cc implements Comparable<cc>{
        public int x, y;
        cc(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public int compareTo(cc other) {
            if (this.x == other.x) {
                return Integer.compare(this.y, other.y);
            }
            return Integer.compare(this.x, other.x);
        }
    }
    int n, k;
    int p[];
    long ans = 0;
    int anss[];
    int used[];
    boolean get_ans(int ind) {
        if (ind == 1 || anss[ind] == 1) {
            return true;
        }
        if (used[ind] == 1) {
            return false;
        }
        used[ind] = 1;
        if (get_ans(p[ind])) {
            anss[ind] = 1;
            return true;
        }
        else {
            return false;
        }
    }
    void check() {
        for (int i = 1; i <= k; ++i) {
            anss[i] = 0;
            used[i] = 0;
        }
        for (int i = 1; i <= k; ++i) {
            if (get_ans(i) == false) {
                return;
            }
        }
        ++ans;
    }
    void dfs(int pos) {
        if (pos == k + 1) {
            check();
            return;
        }
        for (int i = 1; i <= k; ++i) {
            p[pos] = i;
            dfs(pos + 1);
        }
    }
    private void solve() throws IOException {
        p = new int[10];
        anss = new int[10];
        used = new int[10];
        n = in.nextInt();
        k = in.nextInt();
        dfs(1);
        long mod = 1000 * 1000 * 1000 + 7;
        long an = 1;
        for (int i = 1; i <= n - k; ++i) {
            an *= n - k;
            an %= mod;
        }
        ans *= an;
        ans %= mod;
        out.println(ans);
    }

    private static class FastScanner{
        private BufferedReader reader;
        private StringTokenizer tokenizer;
        String cache;
        int cur;

        FastScanner(Reader r) throws IOException{
            reader = new BufferedReader(r);
            tokenizer = new StringTokenizer("");
            cache = null;
            cur = 0;
        }

        public boolean hasNext(){
            if (cache != null && cur < cache.length())
                return true;
            try {
                while (!tokenizer.hasMoreTokens()){
                    String line = reader.readLine();
                    if (line == null)
                        return false;
                    tokenizer = new StringTokenizer(line);
                }
                cache = tokenizer.nextToken();
                cur = 0;
            }
            catch(IOException e) {
                return false;
            }
            return true;
        }

        public char nextChar() throws IOException{
            if (!hasNext())
                throw new EOFException();
            return cache.charAt(cur++);
        }

        public String next() throws IOException{
            if (!hasNext())
                throw new EOFException();
            String result = (cur == 0) ? cache : cache.substring(cur);
            cache = null;
            return result;
        }

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

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

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

        public BigInteger nextBigInteger() throws IOException{
            return new BigInteger(this.next());
        }

        public void close() throws IOException{
            reader.close();
            tokenizer = new StringTokenizer("");
        }
    }

    public static void main(String args[]) throws IOException{
        new Thread(null, new GGWPLivaem(), "Thread #228", 64 * 1024 * 1024).start();
    }

    public void run(){
        try{
            if (withFiles) {
                in = new FastScanner(new FileReader("input.txt"));
                out = new PrintWriter(new FileWriter("output.txt"));
            }
            else {
                in = new FastScanner(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            }
            solve();
            in.close();
            out.close();
        }
        catch(IOException e){
            e.printStackTrace();
        }
    }

    FastScanner in;
    PrintWriter out;
}


import java.util.*;

public class Watermelon
{
    public static void main(String[] args)
    {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int a[] = new int[n];
    	int c[] = new int[101];
    	for(int i=0; i<n; i++)
    	{
    		a[i] = sc.nextInt();
    		c[a[i]]++;
    	}
    	int max = 0;
    	for(int i=0; i<101; i++)
    	{
    		if(c[i]>max)
    			max = c[i];
    	}
    	System.out.println(max);
    }
}


import java.util.*;
import java.io.*;
public class BearandThreeBalls
{

    /************************ SOLUTION STARTS HERE ***********************/

    private static void solve(FastScanner s1, PrintWriter out){

	int n = s1.nextInt();
	TreeSet<Integer> set = new TreeSet<>();
	while(n-->0){set.add(s1.nextInt());}
	if(set.size() < 3)
	{
	    out.print("NO");
	    return;
	}
	int arr[] = new int[set.size()];
	for(int i=0;!set.isEmpty();i++)
	    arr[i] = set.pollFirst();
	boolean flag = false;
	for(int i=2;i<arr.length;i++)
	    flag |= (arr[i] == arr[i-2]+2);
	out.print(flag?"YES":"NO");
    }

    /************************ SOLUTION ENDS HERE ************************/

    /************************ TEMPLATE STARTS HERE *********************/

    public static void main(String []args) throws IOException {
	FastScanner in  = new FastScanner(System.in);
	PrintWriter out =
		new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
	solve(in, out);
	in.close();
	out.close();
    }

    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next()
	    {while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }

    /************************ TEMPLATE ENDS HERE ************************/
}


import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
    static final long MOD = 1_000_000_007 , INF = 1_000_000_000_000_000L;
    static final int INf = 1_000_000_000;
    static FastReader reader;
    static PrintWriter writer;
    public static void main(String[] args) {
        Thread t = new Thread(null, new O(), "Integer.MAX_VALUE", 100000000);
        t.start();
    }
    static class O implements Runnable {
        public void run() {
            try {
                magic();
            }
            catch (Exception e) {
                e.printStackTrace();
                System.exit(1);
            }
        }
    }
    static class FastReader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

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

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

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

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

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

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

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

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

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

    static void magic() throws IOException {
        reader = new FastReader();
        writer = new PrintWriter(System.out, true);
        int a = reader.nextInt(), b = reader.nextInt();
        if(a==b) {
            writer.println(0);
            System.exit(0);
        }
        int d = abs(a-b);
        HashSet<Integer> candidates = new HashSet<>();
        for(int i=1;i*i<=d;++i) {
            if(d%i==0) {
                candidates.add(i);
                candidates.add(d/i);
            }
        }
        long min = Long.MAX_VALUE, at = -1;
        for(int e : candidates) {
            int k;
            if(a%e==0) {
                k = 0;
            }
            else {
                k = e - a%e;
            }
            long ispe = lcm(a+k, b+k);
            if(ispe<min) {
                min = ispe;
                at = k;
            }
            else if(ispe==min) {
                if(at>k) {
                    at = k;
                }
            }
        }
        writer.println(at);
    }
    static long gcd(long a, long b) {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    static long lcm(long a, long b) {
        return (a*b)/gcd(a,b);
    }
}


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

public class Main {

    public static void main(String[] args) throws Exception
    {
        Scanner in = new Scanner(System.in);
        OutputWriter out = new OutputWriter(System.out);
        int n = in.nextInt();
        int v = in.nextInt();
        if (v>=n-1)
            out.printLine(n-1);
        else
        {
            int ans = v;
            int cur = 1;
            while (cur+v<n)
            {
                cur++;
                ans+=cur;
            }
            out.printLine(ans);
        }
        out.flush();
    }
   public static int maxDiv(int a)
   {
       int ans =1;
       for (int i =2;i<=Math.sqrt(a);i++)
       {
           if (a%i==0)
           {
               int u = a/i;
               ans=Math.max(ans,u);
           }
       }
       return ans;
   }
}
class Graph {

    int n;
    ArrayList<Integer>[] adjList;

    public Graph(int n) {
        this.n = n;
        adjList = new ArrayList[n];
        for (int i = 0; i < n; i++)
            adjList[i] = new ArrayList<>();
    }

}
class pair  implements Comparable
{

    int key;
    int value;
    int id;
    public pair(Object key, Object value,Object id) {

        this.key = (int)key;
        this.value=(int)value;
        this.id=(int)id;
    }

    @Override
    public int compareTo(Object o) {
        pair temp =(pair)o;
        if (key!=temp.key)
            return  key-temp.key;
        else return id-temp.id;
    }
}
class Scanner {

    StringTokenizer st;
    BufferedReader br;

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

    public Scanner (FileReader f) {
        br = new BufferedReader(f);
    }

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

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

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

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

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

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

    public boolean nextEmpty() throws IOException {
        String s = nextLine();
        st = new StringTokenizer(s);
        return s.isEmpty();
    }
}
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 print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

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

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

}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
    public static int gcd(int a, int b) {
        if (b==0) return a;
        return gcd(b,a%b);
    }
    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 l_a = Integer.parseInt(st.nextToken());
        int r_a = Integer.parseInt(st.nextToken());
        int t_a = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(bf.readLine());
        int l_b = Integer.parseInt(st.nextToken());
        int r_b = Integer.parseInt(st.nextToken());
        int t_b = Integer.parseInt(st.nextToken());

        int g = gcd(t_a, t_b);
        int c_mod = (g + ((l_b - l_a) % g)) % g;
        //out.println(c_mod);
        long ov_1 = overlap(0L, 0L+r_a - l_a, 0L+c_mod, 0L+ c_mod + r_b - l_b);
        long ov_2 = overlap(0L+g, 0L+g+ r_a - l_a, 0L+c_mod, 0L+ r_b - l_b+c_mod);

        out.println(Math.max(ov_1, ov_2));

        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = scan.nextInt();

        out.close(); System.exit(0);
    }
    public static long overlap(long low1, long high1, long low2, long high2) {
      if(high1 < low2) {
        return 0;
      }
      if(high2 < low1) return 0;
      long min = Math.max(low1, low2);
      long max = Math.min(high1, high2);
      return max-min+1;
    }
}


import java.util.*;
import java.io.*;
public class A538
{
    public static void main(String [] args)
    {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int x = sc.nextInt(); int y = sc.nextInt(); int z = sc.nextInt();
        int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt();
        boolean ans = true;
        if (x > a) {
            ans = false;
        } else {
            a -= x;
            if (a + b < y) {
                ans = false;
            } else {
                if (a + b + c - y < z) ans = false;
            }
        }
        out.println(ans ? "YES" : "NO");
        out.close();
    }

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    }

}


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

public class cf93{
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int pos = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
        int t=0;
        int flag=0;
		int diff= Math.abs(pos-l);
	    int diff2 = Math.abs(r-pos);

	    if(l==1 && r==n){
	    	System.out.println("0");
	    }
	    else if(l!=1 && r==n){
            System.out.println(Math.abs(pos-l)+1);
	    }
	    else if(l==1 && r!=n){
            System.out.println(Math.abs(pos-r)+1);
	    }
	    else{
	    	System.out.println(r-l + Math.min(Math.abs(pos-l),Math.abs(pos-r))+2);
	    }

        //boolean flag1 = false;
        //boolean flag2 = false;

       // if(flag1 && flag2){

	}
}


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

public class Main
{
    public static long fun( long x )
    {
        String s = Long.toString(x);
        long sum = 0;
        for( int i =0; i < s.length() ; i++ ) sum += (long) ( s.charAt(i) - '0');
        return sum;
    }
    public static void main(String args[]) throws Exception
    {
        MyScanner scanner = new MyScanner();
        long n = scanner.nextLong(), d = scanner.nextLong(), val = 0, place = 1;
        while ( d > 0 && n > place )
        {
            val = n % ( place  * 10 ) ;
            val = val / place;
            if( val == 9 )
            {
                place *= 10;
                continue;
            }
            val += 1;
            val *= place;
            d -= val;
            if( d >= 0 )
                n -= val;
            place *=10;
        }
        System.out.println(n);
    }
}

class MyScanner {
    BufferedReader br;
    StringTokenizer st;

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

    public MyScanner(InputStreamReader inputStreamReader) {
        br = new BufferedReader(inputStreamReader);
    }

    public int mod(long x) {
        // TODO Auto-generated method stub
        return (int) x % 1000000007;
    }

    public int mod(int x) {
        return x % 1000000007;
    }

    boolean hasNext() {
        if (st.hasMoreElements())
            return true;
        try {
            st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return st.hasMoreTokens();
    }

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

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

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

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

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


import java.util.*;
public class OneDJapaneseCrosswordPuzzle {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String  s = sc.next();
		s = s.replace('W', ' ');
		int sum = 0;
		String[] x= s.split(" ");
		for(String t : x) {
			if(t.length() > 0)
				sum++;
		}
		System.out.println(sum);
		for(String t:x) {
			if(t.length() > 0)
				System.out.print(t.length() + " ");
		}
	}

}


import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;

public class Main implements Runnable {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Thread(new Main()).start();
	}

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			run1();
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}

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

	private List<Integer> kmp(String x, String a) {
		String s = a + "$" + x;
		int[] oppa = new int[s.length()];
		oppa[0] = 0;
		int tmp = 0;
		List<Integer> res = new ArrayList<Integer>();
		for (int i = 1; i < s.length(); i++) {
			while (tmp != 0 && s.charAt(tmp) != s.charAt(i)) {
				// System.out.println(i + " " + tmp);
				tmp = oppa[tmp - 1];
			}
			if (s.charAt(tmp) == s.charAt(i))
				tmp++;
			oppa[i] = tmp;
			if (tmp == a.length()) {
				res.add(i - a.length() - a.length());
			}
		}
		return res;
	}

	double nextDouble(StreamTokenizer st) throws IOException {
		st.nextToken();
		return st.nval;
	}

	String nextLine(StreamTokenizer st) throws IOException {
		st.nextToken();
		return st.sval;
	}

	int cnt = 0;
	int[] col;

	void unite(int a, int b) {
		if (cnt % 2 == 0)
			col[getCol(a)] = getCol(b);
		else
			col[getCol(b)] = getCol(a);
		cnt++;
	}

	int getCol(int a) {
		return a == col[a] ? a : (col[a] = getCol(col[a]));
	}

	public void run1() throws IOException {
		// Scanner sc = new Scanner(new FileReader("input.txt"));
		Scanner sc = new Scanner(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new
		// InputStreamReader(System.in));
		// PrintWriter pw = new PrintWriter(new FileWriter("output.txt"));
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int res = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++)
				if (i % 2 == j % 2) {
					int di = Math.min(i, n - 1 - i);
					int dj = Math.min(j, m - 1 - j);
					if (Math.min(di, dj) == k - 1)
						res++;
				}
		}
		System.out.println(res);
	}
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc. nextInt();
        int res1;
        int res2;
        int res11 = (3*a) / 10;
        int res21 = (3 * b) / 10;
        int res12 = a - (a / 250) * c;
        int res22 = b - (b / 250) * d;
        if (res11 >res12){
            res1 = res11;
        } else {
            res1 = res12;
        }
        if (res21 > res22){
            res2 = res21;
        } else {
            res2 = res22;
        }
        if (res1 > res2){
            System.out.println("Misha");
        }
        if (res1 < res2){
            System.out.println("Vasya");
        }
        if (res1 == res2){
            System.out.println("Tie");
        }
    }
}


import java.util.*;

public class A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String a = ""+in.nextInt();

        boolean result = false;

        if(isPali(a)){
            result = true;
        }
        while(a.charAt(a.length()-1)=='0'){
            a=a.substring(0,a.length()-1);
            if(isPali(a)){
                result = true;
            }
        }

        System.out.println(result?"YES":"NO");
    }

    public static boolean isPali(String a){
        for(int i = 0; i<a.length()/2; i++){
            if(a.charAt(i)!=a.charAt(a.length()-i-1)){
                return false;
            }
        }
        return true;
    }

}


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

public class D {
    static long min = Long.MAX_VALUE;
    static long max = Long.MIN_VALUE;
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        long cycle = (long)N*K;
        //seem to have 4 options
        //between k-a, k+a, k+b, k-b
        //k-a to k-b
        long v2 = K-b;
        long v1 = K-a;
        long dist = ((v2-v1)%K)+K;
        compute(dist, cycle, K);
        v2 = K-b;
        v1 = a;
        dist = ((v2-v1)%K)+K;
        compute(dist, cycle, K);
        v2 = b;
        v1 = a;
        dist = ((v2-v1)%K)+K;
        compute(dist, cycle, K);
        v2 = b;
        v1 = K-a;
        dist = ((v2-v1)%K)+K;
        compute(dist, cycle, K);
        out.println(min + " " + max);
        out.flush();
    }

    public static void compute(long dist, long cycle, long K) {
        while (dist <= cycle) {
            long gcd = gcd(dist, cycle);
            long val = cycle/gcd;
            min = Math.min(val, min);
            max = Math.max(val, max);
            dist += K;
        }
    }

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

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

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

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

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

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

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

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


import java.util.Scanner;

public class A {
	public static void main(String args[]) {
		 Scanner input = new Scanner(System.in);
		 int n,a,x,b, y = 0;
		 n=input.nextInt();
		 a=input.nextInt();
		 x=input.nextInt();
		 b=input.nextInt();
		 y=input.nextInt();
		 int limit = 1;
		 for(int i=0;i<limit;i++) {
			 if(a==b) {
				 System.out.println("YES");
				 break;
			 }
			 a++;
			 b--;
			 if(a>n) {
				 a=1;
			 }
			 if(b<1) {
				 b=n;
			 }
			 limit++;
			 if(a==b) {
				 System.out.println("YES");
				 break;
			 }
			 if(a==x || b ==y) {
				 System.out.println("NO");
				 break;
			 }
		 }

	 }
}


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

public class Minimum{

    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[]tab = new int [n];
        /*
        BufferedReader br = new BufferedReader(
                            new InputStreamReader(System.in));
        //int a=Integer.parseInt(br.readLine()) ;

        StringTokenizer st = new StringTokenizer(br.readLine());
        */
        for (int i = 0; i<n;i++){
            tab[i] = sc.nextInt();
        }
        int x;
        int max = Math.abs(tab[0]-tab[n-1]);

        for (int j = 1;j<n-1;j++){
            int tre = 0;
            for (int l =0;l<n-1;l++){

                x = tab[l+1]-tab[l];

                if (l+1==j){
                    x=tab[l+2]-tab[l];
                }
                else if (l==j){
                    x = tab[l+1]-tab[l-1];
                }

                tre = Math.max(x,tre);

                /*

                if(l!=j&&l+1!=j&&tab[l+1]-tab[l]>tre){
                    tre= tab[l+1]-tab[l];
                }
                else if (l==j&&tab[l+1]-tab[l-1]>tre){
                    tre= tab[l+1]-tab[l-1];
                }
                else if (l+1==j&&tab[l+2]-tal[l]>tre){
                    tre = tab[l+2]-tab[l];
                }
                */

            }

            if (tre<max){
                max= tre;
            }
        }

        System.out.print(max);
    }
}


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

						public class Practice {
							private static InputStream stream;
							private static byte[] buf = new byte[1024];
							private static int curChar;
							private static int numChars;
							private static SpaceCharFilter filter;
							private static PrintWriter pw;
							private static long mod=1000000007;

						    public static void main(String[] args) {
						    	InputReader(System.in);
								pw = new PrintWriter(System.out);
						        new Thread(null ,new Runnable(){
						           public void run(){
						               try{
						                   solve();//This is solution method
					               pw.close();
					           } catch(Exception e){
					               e.printStackTrace();
					           }
					       }
					   },"1",1<<26).start();
						    				   }
						    public static void Merge(long a[],int p,int r){
					            if(p<r){
					                int q = (p+r)/2;
					                Merge(a,p,q);
					                Merge(a,q+1,r);
					                Merge_Array(a,p,q,r);
					            }
					        }
					        public static void Merge_Array(long a[],int p,int q,int r){
					           long b[] = new long[q-p+1];
					            long c[] = new long[r-q];
					            for(int i=0;i<b.length;i++)
					                b[i] = a[p+i];
					            for(int i=0;i<c.length;i++)
					                c[i] = a[q+i+1];
					            int i = 0,j = 0;
					            for(int k=p;k<=r;k++){
					                if(i==b.length){
					                    a[k] = c[j];
					                    j++;
					                }
					                else if(j==c.length){
					                    a[k] = b[i];
					                    i++;
					                }
					                else if(b[i]<c[j]){
					                    a[k] = b[i];
					                    i++;
					                }
					                else{
					                    a[k] = c[j];
					                    j++;
					                }
					            }
					        }
					        public static void test(){
					        	int t=nextInt();
					        	while(t-->0){
					        		solve();

					        	}
					        }

				    					public static void solve() {

				    						 long t=nextLong();
				    				            int l=nextInt();
				    				            int r=nextInt();
				    				            long[] ans=new long[r+1];
				    				            Arrays.fill(ans, -1);
				    				            long[] min=new long[r+1];
				    				            Arrays.fill(min, -1);
				    				            int sqr=(int)Math.sqrt(r);
				    				            for(int i=2;i<=sqr;i++){
				    				                if(min[i]==-1){
				    				                    min[i]=i;
				    				                    for(int j=i*i;j<=r;j+=i){
				    				                        if(min[j]==-1){
				    				                            min[j]=i;
				    				                        }
				    				                    }
				    				                }
				    				            }
				    				            ans[1]=0;
				    				            for(int i=2;i<=r;i++){
				    				                if(min[i]==-1)
				    				                    min[i]=i;
				    				                long x=((long)i/min[i])*(min[i]*(min[i]-1))/2;
				    				                ans[i]=(x+ans[(int) (i/min[i])])%mod;
				    				            }
				    				            //for(int i=2;i<=r;i++)
				    				                //System.out.println(ans[i]);
				    				            long ans1=0;
				    				            long pow=1;
				    				            for(int i=l;i<=r;i++){
				    				                //System.out.println(ans[i]);
				    				                ans1=(ans1+(pow*ans[i])%mod)%mod;
				    				                pow=(pow*t)%mod;
				    				            }
				    				            pw.println(ans1);
				    					}

				    					public static long pow(long n, long p,long mod) {
				        					if(p==0)
				        						return 1;
				        					if(p==1)
				        						return n%mod;
				        					if(p%2==0){
				        						long temp=pow(n, p/2,mod);
				        					return (temp*temp)%mod;
				        					}else{
				        						 	long temp=pow(n,p/2,mod);
				        						 	temp=(temp*temp)%mod;
				        						 	return(temp*n)%mod;

				        					}
				        				}

					public static boolean isVowel(char c){
						if(c=='a' || c=='i'|| c=='e' || c=='o' || c=='u')
								return true;
							return false;
						}

					    public static String reverseString(String s) {
							StringBuilder sb = new StringBuilder(s);
							sb.reverse();
							return (sb.toString());
						}
					    private static BigInteger ncr(int n,int k){
					    	if (k < 0 || k > n) return BigInteger.ZERO;
					        if (n-k < k) k = n-k;

					        BigInteger x = BigInteger.ONE;
					        for (int i = 1; i <= k; i++) {
					            x = x.multiply(new BigInteger(""+(n-i+1)));
					x = x.divide(new BigInteger(""+i));
					        }

					return x;
					    }
					    static long fact[];
					private static void factmod(int n,int mod){
						fact=new long[n+1];
						fact[0]=1;
						for(int i=1;i<=n;i++){
							fact[i]=i*fact[i-1];
							//fact[i]%=mod;

						}

					}
					private static long phi(long n){
						long ans=n;
						if(n%2==0)
							ans-=(ans/2);
						while(n%2==0)
						{
							n/=2;

						}
						for(int i=3;i*i<=n;i+=2){
							if(n%i==0){
							while(n%i==0){
								n/=i;
							}
							ans-=(ans/i);
							}
						}
						if(n>2)
							ans-=(ans/n);

						return ans;
					}
					static long d,x,y;
					static long modInverse(long A, long M)
					{
					extendedEuclid(A,M);
					return (x%M+M)%M;    //x may be negative
					}
					static void extendedEuclid(long A, long B) {
					if(B == 0) {
					d = A;
					x = 1;
					y = 0;
					}
					else {
					extendedEuclid(B, A%B);
					long temp = x;
					x = y;
					y = temp - (A/B)*y;
					}
					}
					static boolean prime[];
					static int spf[];
					public static void sieve(int n){
						prime=new boolean[n+1];
						spf=new int[n+1];

						Arrays.fill(spf, 1);
						Arrays.fill(prime, true);
					prime[1]=false;
						spf[2]=2;

					for(int i=3;i<=n;i+=2){
						if(prime[i]){
							spf[i]=i;
							for(int j=2*i;j<=n;j+=i){

								prime[j]=false;
							if(spf[j]==1){
								spf[j]=i;
							}
							}
						}
					}

					}
					public static boolean isPrime(long n) {

						if (n <= 1)
							return false;
						if (n <= 3)
							return true;

						if (n % 2 == 0 || n % 3 == 0)
							return false;

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

						return true;
					}

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

						public static void InputReader(InputStream stream1) {
							stream = stream1;
						}

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

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

						private static 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++];
						}

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

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

						private static String nextToken() {
							int c = read();
							while (isSpaceChar(c))
								c = read();
							StringBuilder res = new StringBuilder();
							do {
								res.appendCodePoint(c);
								c = read();
							} while (!isSpaceChar(c));
							return res.toString();
						}
						private static double[] nextDoubleArray(int n) {
							double arr[]=new double[n];
							String a[]=nextLine().split(" ");
							for(int i=1;i<n;i++){
								arr[i]=Double.parseDouble(a[i-1]);
							}
							return arr;
						}
						private static String nextLine() {
							int c = read();
							while (isSpaceChar(c))
								c = read();
							StringBuilder res = new StringBuilder();
							do {
								res.appendCodePoint(c);
								c = read();
							} while (!isEndOfLine(c));
							return res.toString();
						}

						private static int[] nextIntArray(int n) {
							int[] arr = new int[n];
							for (int i = 0; i < n; i++) {
								arr[i] = nextInt();
							}
							return arr;
						}

						private static int[][] next2dArray(int n, int m) {
							int[][] arr = new int[n][m];
							for (int i = 0; i < n; i++) {
								for (int j = 0; j < m; j++) {
									arr[i][j] = nextInt();
								}
							}
							return arr;
						}
						private static char[][] nextCharArray(int n,int m){
							char [][]c=new char[n][m];
							for(int i=0;i<n;i++){
								String s=nextLine();
								for(int j=0;j<s.length();j++){
									c[i][j]=s.charAt(j);
								}
							}
							return c;
						}

						private static long[] nextLongArray(int n) {
							long[] arr = new long[n];
							for (int i = 0; i < n; i++) {
								arr[i] = nextLong();
							}
							return arr;
						}

						private static void pArray(int[] arr) {
							for (int i = 0; i < arr.length; i++) {
								pw.print(arr[i] + " ");
							}
							pw.println();
							return;
						}

						private static void pArray(long[] arr) {
							for (int i = 0; i < arr.length; i++) {
								pw.print(arr[i] + " ");
							}
							pw.println();
							return;
						}

						private static void pArray(boolean[] arr) {
							for (int i = 0; i < arr.length; i++) {
								pw.print(arr[i] + " ");
							}
							pw.println();
							return;
						}

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

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

					}
						 class Hashing {

							  static final int multiplier = 43;
							  static final Random rnd = new Random();
							  static final int mod1 = BigInteger.valueOf((int) (1e9 + rnd.nextInt((int) 1e9))).nextProbablePrime().intValue();
							  static final int mod2 = BigInteger.valueOf((int) (1e9 + rnd.nextInt((int) 1e9))).nextProbablePrime().intValue();
							  static final int invMultiplier1 = BigInteger.valueOf(multiplier).modInverse(BigInteger.valueOf(mod1)).intValue();
							  static final int invMultiplier2 = BigInteger.valueOf(multiplier).modInverse(BigInteger.valueOf(mod2)).intValue();

							  long[] hash1, hash2;
							  long[] inv1, inv2;
							  int n;

							  public Hashing(String s) {
							    n = s.length();
							    hash1 = new long[n + 1];
							    hash2 = new long[n + 1];
							    inv1 = new long[n + 1];
							    inv2 = new long[n + 1];
							    inv1[0] = 1;
							    inv2[0] = 1;

							    long p1 = 1;
							    long p2 = 1;
							    for (int i = 0; i < n; i++) {
							      hash1[i + 1] = (hash1[i] + s.charAt(i) * p1) % mod1;
							      p1 = p1 * multiplier % mod1;
							      inv1[i + 1] = inv1[i] * invMultiplier1 % mod1;
							      hash2[i + 1] = (hash2[i] + s.charAt(i) * p2) % mod2;
							      p2 = p2 * multiplier % mod2;
							      inv2[i + 1] = inv2[i] * invMultiplier2 % mod2;
							    }
							  }

							  public long getHash(int i, int r) {
								//  i--;
							    return (((hash1[r] - hash1[i] + mod1) * inv1[i] % mod1) << 32)
							        + (hash2[r] - hash2[i] + mod2) * inv2[i] % mod2;
							  }
						}


import java.util.Scanner;

public class NextRound2 {
    public static void main(String[] args){
        Scanner scan  = new Scanner(System.in);
        int n,k,score=-1,count=0;
        n = scan.nextInt();
        k = scan.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        scan.close();
        if(a[0]==0){
            k=0;
        }else{
            //6 2
            //3 0 0 0 0 0
            while(a[k-1]==0)k--;
            //non-incresing, next number from (k-1) must be the same (k).
            while(k<n && a[k-1]==a[k])k++;
        }
        System.out.println(k);
    }
}


import java.util.*;

public class Main {

    private static final long MOD = 1000000007;

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

        int[] dx = new int[]{0, 0, -1, 1};
        int[] dy = new int[]{1, -1, 0, 0};
        HashMap<Character, Integer> map = new HashMap<Character, Integer>();
        map.put('U', 0);
        map.put('D', 1);
        map.put('L', 2);
        map.put('R', 3);

        int a = scan.nextInt();
        int b = scan.nextInt();
        scan.nextLine();
        char[] command = scan.nextLine().toCharArray();
        int N = command.length;

        int[] x = new int[N + 1];
        int[] y = new int[N + 1];
        boolean pass = a == 0 && b == 0;
        for (int i = 0; i < N; i++) {
            int direction = map.get(command[i]);
            x[i + 1] = x[i] + dx[direction];
            y[i + 1] = y[i] + dy[direction];
            if (a == x[i + 1] && b == y[i + 1]) {
                pass = true;
            }
        }

        if (pass) {
        } else if (x[N] == 0 && y[N] == 0) {
        } else if (x[N] == 0) {
            for (int i = 0; i < N; i++) {
                if (x[i] != a) {
                    continue;
                }
                int diff = b - y[i];
                if (diff % y[N] == 0 && diff / y[N] >= 0) {
                    pass = true;
                    break;
                }
            }
        } else {
            for (int i = 0; i < N; i++) {
                int diff = a - x[i];
                if (diff % x[N] != 0 || diff / x[N] <= 0) {
                    continue;
                }
                long step = diff / x[N];
                if (step * y[N] + y[i] == b) {
                    pass = true;
                    break;
                }
            }
        }
        System.out.println(pass ? "Yes" : "No");
        scan.close();
    }

    private static void print(int... arr) {
        System.out.print(arr[0]);
        for (int i = 1; i < arr.length; i++) {
            System.out.print(" ");
            System.out.print(arr[i]);
        }
        System.out.println();
    }

    private static void print(long... arr) {
        System.out.print(arr[0]);
        for (int i = 1; i < arr.length; i++) {
            System.out.print(" ");
            System.out.print(arr[i]);
        }
        System.out.println();
    }

    private static <T> void print(T... arr) {
        System.out.print(arr[0]);
        for (int i = 1; i < arr.length; i++) {
            System.out.print(" ");
            System.out.print(arr[i]);
        }
        System.out.println();
    }

    private static void read(Scanner scan, int[]... arrs) {
        int len = arrs[0].length;
        for (int i = 0; i < len; i++) {
            for (int[] arr : arrs) {
                arr[i] = scan.nextInt();
            }
        }
    }

    private static void read(Scanner scan, long[]... arrs) {
        int len = arrs[0].length;
        for (int i = 0; i < len; i++) {
            for (long[] arr : arrs) {
                arr[i] = scan.nextLong();
            }
        }
    }

    private static void decreaseByOne(int[]... arrs) {
        for (int[] arr : arrs) {
            for (int i = 0; i < arr.length; i++) {
                arr[i] --;
            }
        }
    }
}


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

public class B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        int b = in.nextInt();
        int w = in.nextInt();
        int x = in.nextInt();
        long c = in.nextLong();
        long lo = 0;
        long hi = (long) 1e18;
        long ans = -1;
        while (lo <= hi) {
            long mid = lo + (hi - lo) / 2;
            long temp = mid;
            int B = b;
            long A = a;
            long[] seen = new long[2 * w];
            long[] aVal = new long[2 * w];
            Arrays.fill(seen, -1);
            while (temp > 0) {
                if (seen[B] != -1) {
                    long tDiff = seen[B] - temp;
                    long rounds = temp / tDiff;
                    long aDiff = aVal[B] - A;
                    A -= rounds * aDiff;
                    temp -= rounds * tDiff;
                    Arrays.fill(seen, -1);
                } else {
                    seen[B] = temp;
                    aVal[B] = A;
                    temp--;
                    if (B < x) {
                        B += w - x;
                        A--;
                    } else
                        B -= x;
                }
            }
            if (c - mid <= A) {
                ans = mid;
                hi = mid - 1;
            } else
                lo = mid + 1;
        }
        System.out.println(ans);
    }
}


import java.util.*;
// program referenced from ml_guy's solution
public class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        if(n==m){
            System.out.println(1);
            return;
        }
        m -= n + 1;
        ans = 2;
        int left = Math.max(k - 1, 1);
        int right = Math.min(k + 1, n);
        while ((left > 1 || right < n) && m >= (right - left + 1)) {
            m -= right - left + 1;
            ans++;

            if (left > 1) {
                left--;
            }

            if (right < n) {
                right++;
            }
        }
        int len = right - left + 1;
        ans += m / len;
        System.out.println(ans);
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 *
 * @author Lalo
 */
public class ContestSandbox {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int length = Integer.parseInt(in.nextLine());
        String s = in.nextLine();
        String genome = "ACTG";
        int miniumChanges = 3215643;
        Map<String, Integer> alphabet = new HashMap<>();

        int a = 1;
        for (char ch = 'A'; ch <= 'Z'; ch++) {
            alphabet.put(String.valueOf(ch), a);
            a++;
        }

        for (int i = 0; (i + 4) <= length; i++) {
            int sum = 0;
            for (int x = 0; x < 4; x++) {
                if (Math.abs(alphabet.get(genome.substring(x, x + 1)) - alphabet.get(s.substring(i + x, i + x + 1))) <= 13) {
                    sum += Math.abs(alphabet.get(genome.substring(x, x + 1)) - alphabet.get(s.substring(i + x, i + x + 1)));
                } else if (alphabet.get(s.substring(i + x, i + x + 1)) > alphabet.get(genome.substring(x, x + 1))) {
                    sum += (26 - alphabet.get(s.substring(i + x, i + x + 1)) + alphabet.get(genome.substring(x, x + 1)));
                } else {
                    sum += (26 - alphabet.get(genome.substring(x, x + 1)) + alphabet.get(s.substring(i + x, i + x + 1)));
                }
            }

            if (sum < miniumChanges) {
                miniumChanges = sum;
            }
        }

        System.out.println(miniumChanges);
    }

}


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

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

class TaskA {
    public void solve(int testNumber, InputReader in, OutputWriter out){
	    String F = in.next(), M = in.next(), S = in.next();
	    if (beats(F, M) && beats(F, S)){
		    out.printLine("F");
		    return;
	    }
	    if (beats(M, F) && beats(M, S)){
		    out.printLine("M");
		    return;
	    }
	    if (beats(S, F) && beats(S, M)){
		    out.printLine("S");
		    return;
	    }
	    out.printLine("?");
    }
	boolean beats(String a, String b){
		if (a.equals("rock") && b.equals("scissors")) return true;
		if (a.equals("paper") && b.equals("rock")) return true;
		if (a.equals("scissors") && b.equals("paper")) return true;
		return false;
	}
}

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

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

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			if (Character.isValidCodePoint(c))
				res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

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

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public String next() {
		return readString();
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}
	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}
	public void close() {
		writer.close();
	}
}


import java.util.Scanner;

public class A1080 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		System.out.println((int)(Math.ceil((double)(n*2)/k)+Math.ceil((double)(n*5)/k)+Math.ceil((double)(n*8)/k)));
	}

}


import java.util.Scanner;

public class Task112B {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt() / 2;
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		if (((x == n) || (x == n + 1)) && ((y == n) || (y == n + 1))) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}


import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.TreeSet;

public class Main
{
	public void foo()
	{
		MyScanner scan = new MyScanner();
		int n = scan.nextInt();
		int m = scan.nextInt();
		for(int k = 1; ;++k)
		{
			if(k * m > n)
			{
				System.out.println(-1);
				break;
			}
			int y = n - k * m;
			if(y > k * m)
			{
				continue;
			}
			else
			{
				System.out.println(k * m);
				break;
			}
		}
	}

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

	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

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

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

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

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

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


// Why do we fall ? So we can learn to pick ourselves up.
import java.util.*;
public class solve {
    static int mod = 1000000007;
    static int mod1 = 998244353;
    public static void  main(String[] args){
        Scanner sc = new Scanner(System.in);
        int lll = sc.nextInt(),rrr = sc.nextInt(),a = sc.nextInt();
        int l = Math.min(lll,rrr),r = Math.max(lll,rrr);
        if(lll==rrr) System.out.println(2*(l+a/2));
        else {
            int ll = Math.min(r-l,a);
            l += ll;
            int aa = a-ll;
            System.out.println(2*(l+aa/2));
        }
    }
}


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

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

    static class Garden_915A {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                int m = in.nextInt();
                if (k % m == 0)
                    ans = k / m < ans ? k / m : ans;
            }
            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 int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

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

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

        }

    }
}


import java.util.Scanner;

public class Third {

       public static void main(String[] args) {
        Scanner input = new Scanner (System.in);
        int n = input.nextInt();
        int o = n+1;
        int array [] = new int [n];
        for (int i = 0; i<n; i++){
        array[i]=(i+1);
        }
        int m = input.nextInt();
        input.nextLine();
        for (int j = 0; j < m; j++){
           int r = input.nextInt();
              for (int l = r-1; l<o-1; l++){
              array [l] = r;
              }
           if (  r < o)
           o = r;
        }
            for (int i=0; i< n; i++)
            System.out.print (array[i]+" ");

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long p = in.nextLong();
            int k = in.nextInt();
            int[] digits = representInBase(p, k);

            int[] b = Arrays.copyOf(digits, digits.length + 2);
            for (int i = 0; i + 1 < b.length; i++) {
                b[i + 1] += b[i] / k;
                b[i] %= k;
                if (i % 2 == 1 && b[i] != 0) {
                    b[i] = k - b[i];
                    ++b[i + 1];
                }
            }

            int last = b.length - 1;
            while (b[last] == 0) {
                --last;
            }
            out.println(last + 1);
            for (int i = 0; i <= last; i++) {
                if (i > 0) {
                    out.print(" ");
                }
                out.print(b[i]);
            }
            out.println();
        }

        private int[] representInBase(long n, int k) {
            int numDigits = 0;
            long saved = n;
            while (n > 0) {
                n /= k;
                ++numDigits;
            }
            int[] res = new int[numDigits];
            n = saved;
            numDigits = 0;
            while (n > 0) {
                res[numDigits] = (int) (n % k);
                n /= k;
                ++numDigits;
            }
            return res;
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

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

    }
}


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

public class ProblemB {

    void run() {
        Scanner sc = new Scanner(System.in);

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

        p("%d\n", checkIn(a, x, y));

//        boolean out =  checkIn(a, x, y);
//        if (out) {
//        	p("1\n");
//        } else {
//        	p("-1\n");
//        }
    }

    int checkIn(int a, int x, int y) {
    	int out = 1;
    	d("test");
    	if (y % a == 0) {
    		return -1;
    	}

    	if (y < (2 * a)) {
    		d("hey");
    		out += y / a;
    		if (Math.abs(x) < ((double) a) / 2) {
    			return out;
    		} else {
    			return -1;
    		}
    	} else {
    		d("ho");
    		out += 2;

    		int z = Math.max(y / (2 * a) - 1, 0);
    		out += z * 3;

    		y %= (2 * a);
    		d("y = ", y);
    		if (y > a) {
    			if (Math.abs(x) < ((double) a) / 2) {
    				out += 2;
    				return out;
    			} else {
    				d("fail");
    				return -1;
    			}
    		} else {
    			if (Math.abs(x) < a && x != 0) {
    				if (x > 0) {
    					out += 1;
    				}
    				return out;
    			} else {
    				return -1;
    			}
    		}
    	}
    }

    boolean debug = false;
    void p(String f, Object...params) {
        System.out.printf(f, params);
    }
    void d(Object...params) {
        if (debug) {
            p("DEBUG: %s\n", Arrays.deepToString(params));
        }
    }
    public ProblemB(String[] args) {
        if (args.length > 0 && args[0].equals("debug")) {
            debug = true;
        }
    }
    public static void main(String[] args) {
        new ProblemB(args).run();
    }
}


import java.util.Scanner;

public class WeirdSubstraction {

    public static void weirdSubstraction(){
        Scanner sc = new Scanner(System.in);
        long a = 0;
        long b = 0;

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

        while(a != 0 || b != 0){
        if(a == 0 || b == 0) break;
        else if(a >= b*2) {
            a %= 2*b;
        }
        else if(b >= a*2) {
            b %= 2*a;
            }
        else break;
        }

        System.out.println(a+" "+b);
    }

    public static void weirdSubstractionRec(long a, long b){
        if(a == 0 || b == 0){
            System.out.println(a+" "+b);
        }
        else if(a >= b*2) {
            a -= 2*b;
            weirdSubstractionRec(a, b);
        }
        else if(b >= a*2) {
            b -= 2*a;
            weirdSubstractionRec(a, b);
            }
        else {
            System.out.println(a+" "+b);
        }
    }

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

        long a = sc.nextLong();
        long b = sc.nextLong();
        */
        weirdSubstraction();
    }

}


import java.util.Scanner;

public class cls_div2_328_B {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        long n = scan.nextInt();

        scan.close();

        long result = (n - 2) + ((n - 3) * (n - 2));

        System.out.println(result);
    }
}


import static java.util.Arrays.deepToString;

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

public class BinPow {

	static void solve() throws Exception {
		String s = next();
		char max = 0;
		for(char ch: s.toCharArray()){
			if(ch > max){
				max = ch;
			}
		}
		String ans = "";
		for(char ch: s.toCharArray()){
			if(ch == max){
				ans += ch;
			}
		}
		System.out.print(ans);
	}

	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;

	static void debug(Object... a) {
		System.err.println(deepToString(a));
	}

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

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

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

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

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


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

public class Main {

    void solve(Scanner in, PrintWriter out) {

        int a = in.nextInt();
        int b = in.nextInt();
        int x1 = in.nextInt();
        int y1 = in.nextInt();
        int x2 = in.nextInt();
        int y2 = in.nextInt();

        int n1 = Math.floorDiv(x1 + y1, 2 * a);
        int m1 = Math.floorDiv(x1 - y1, 2 * b);
        int n2 = Math.floorDiv(x2 + y2, 2 * a);
        int m2 = Math.floorDiv(x2 - y2, 2 * b);

        int res = Math.max(Math.abs(n2 - n1), Math.abs(m2 - m1));

        out.print(res);
    }

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

            solve(in, out);
        }
    }

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