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

public class Solution{
	InputStream is;
	static PrintWriter out;
	String INPUT = "";
	static long mod = (long)1e9+7L;

	public void solve(){
		long n = nl(), m = nl(), k = nl();
		long l = 1L, r = m*n;
		while(l < r){
			long mid = l+(r-l)/2L;
			if(f(n, m, mid, k)){
				r = mid;
			}
			else{
				l = mid+1L;
			}
		}

		out.println(l);
	}

	boolean f(long n, long m, long key, long k){
		long  res2 = 0;
		for(long i = 1 ; i <= n; i++){
			res2 = res2 + Math.min(m, key/i);
		}
		if(res2 >= k){
			return true;
		}
		else{
			return false;
		}
	}

	void run(){
		is = new DataInputStream(System.in);
		out = new PrintWriter(System.out);
		int t=1;while(t-->0)solve();
		out.flush();
	}
	public static void main(String[] args)throws Exception{new Solution().run();}
	long mod(long v, long m){if(v<0){long q=(Math.abs(v)+m-1L)/m;v=v+q*m;}return v%m;}
    long mod(long v){if(v<0){long q=(Math.abs(v)+mod-1L)/mod;v=v+q*mod;}return v%mod;}
	//Fast I/O code is copied from uwi code.
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	private int readByte(){
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	private String ns(){
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	private char[] ns(int n){
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	private char[][] nm(int n, int m){
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	private int[] na(int n){
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	private int ni(){
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	private long nl(){
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	static  int i(long x){return (int)Math.round(x);}
	static class Pair implements Comparable<Pair>{
		long fs,sc;
		Pair(long a,long b){
			fs=a;sc=b;
		}
		public int compareTo(Pair p){
			if(this.fs>p.fs)return 1;
			else if(this.fs<p.fs)return -1;
			else{
				return i(this.sc-p.sc);
			}
			//return i(this.sc-p.sc);
		}
		public String toString(){
			return "("+fs+","+sc+")";
		}
	}

}


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

public class a {

    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt() * 2;
        int[] f = new int[10];
        for (int i = 0; i < 4; i++)
        {
            String line = in.next();
            for (int j = 0; j < 4; j++)
            {
                if (line.charAt(j) == '.')
                    continue;
                f[line.charAt(j) - '0']++;
            }
        }

        Arrays.sort(f);
        System.out.println(f[9] > n ? "NO" : "YES");

    }

}


import java.util.Scanner;

public class A {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();String s= "";
		int t = in.nextInt();
		if(t==10){
			for(int i = 0 ; i < n-1 ; i++)
				s+="1";
			s+="0";
		}else{
			for(int i = 0 ; i < n ; i++)
				s+=t;
		}
		if(s.equals("0"))
			s = "-1";
		System.out.println(s);
	}
}


import java.util.NavigableSet;
import java.util.SortedSet;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.Set;
import java.util.TreeSet;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskF {
	int[] first;
	int[] second;
	int[] cost;

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int count = in.readInt();
		int edgeCount = in.readInt();
		int index = in.readInt() - 1;
		first = new int[edgeCount];
		second = new int[edgeCount];
		cost = new int[edgeCount];
		IOUtils.readIntArrays(in, first, second, cost);
		NavigableSet<State> set = new TreeSet<State>();
		set.add(new State(0, 0, 0, 0, 0));
		for (int i = 0; i < index; i++) {
			State current = set.pollFirst();
			for (int j = 0; j < edgeCount; j++) {
				State next = current.add(j);
				if (next != null)
					set.add(next);
			}
		}
		out.printLine(set.first().cost);
	}

	class State implements Comparable<State> {
		final int menMask;
		final int womenMask;
		final long firstEdgeMask;
		final long secondEdgeMask;
		final int cost;

		State(int menMask, int womenMask, long firstEdgeMask, long secondEdgeMask, int cost) {
			this.menMask = menMask;
			this.womenMask = womenMask;
			this.firstEdgeMask = firstEdgeMask;
			this.secondEdgeMask = secondEdgeMask;
			this.cost = cost;
		}

		public int compareTo(State o) {
			if (cost != o.cost)
				return cost - o.cost;
			int value = IntegerUtils.longCompare(firstEdgeMask, o.firstEdgeMask);
			if (value != 0)
				return value;
			return IntegerUtils.longCompare(secondEdgeMask, o.secondEdgeMask);
		}

		public State add(int edge) {
			if ((menMask >> first[edge] & 1) != 0 || (womenMask >> second[edge] & 1) != 0)
				return null;
			return new State(menMask + (1 << first[edge]), womenMask + (1 << second[edge]),
				firstEdgeMask + (edge < 64 ? 1L << edge : 0), secondEdgeMask + (edge >= 64 ? 1L << (edge - 64) : 0),
				cost + TaskF.this.cost[edge]);
		}
	}
}

class InputReader {

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

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

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

	public int 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 static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(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();
	}

	}

class IOUtils {

	public static void readIntArrays(InputReader in, int[]... arrays) {
		for (int i = 0; i < arrays[0].length; i++) {
			for (int j = 0; j < arrays.length; j++)
				arrays[j][i] = in.readInt();
		}
	}

	}

class IntegerUtils {

	public static int longCompare(long a, long b) {
		if (a < b)
			return -1;
		if (a > b)
			return 1;
		return 0;
	}

	}


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);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		char[][] ans = new char[2][13];

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			String s = in.next();
			int p1 = -1;
			int p2 = -1;
			for (int i = 0; i < s.length(); i++) {
				for (int j = i + 1; j < s.length(); j++) {
					if (s.charAt(i) == s.charAt(j)) {
						p1 = i;
						p2 = j;
					}
				}
			}
			int len = p2 - p1 - 1;
			if (len == 0) {
				out.println("Impossible");
				return;
			}

			Arrays.fill(ans[0], '.');
			Arrays.fill(ans[1], '.');
			if (len == 1) {
				goLeft(0, 1, s.substring(p1, p2));
			} else {
				goLeft(0, len / 2, s.substring(p1, p2));
			}
			String u = rev(s.substring(0, p1));
			String v = s.substring(p2 + 1);
			if (len / 2 + 1 >= ans[0].length && !u.isEmpty()) {
				String t = u;
				u = v;
				v = t;
			}
			if (len == 1) {
				goRight(0, 2, u);
				goRight(1, 0, v);
			} else {
				goRight(0, len / 2 + 1, u);
				goRight(1, (len + 1) / 2, v);
			}
			out.println(new String(ans[0]));
			out.println(new String(ans[1]));
		}

		private String rev(String s) {
			return new StringBuilder(s).reverse().toString();
		}

		private void goLeft(int r, int c, String s) {
			if (s.isEmpty()) {
				return;
			}
			if (ans[r][c] != '.') {
				throw new AssertionError();
			}
			ans[r][c] = s.charAt(0);
			if (c > 0) {
				goLeft(r, c - 1, s.substring(1));
			} else {
				goRight(1 - r, c, s.substring(1));
			}
		}

		private void goRight(int r, int c, String s) {
			if (s.isEmpty()) {
				return;
			}
			if (ans[r][c] != '.') {
				throw new AssertionError();
			}
			ans[r][c] = s.charAt(0);
			if (c + 1 < ans[r].length) {
				goRight(r, c + 1, s.substring(1));
			} else {
				goLeft(1 - r, c, s.substring(1));
			}
		}

	}

	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 {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

	}
}


import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int x1=sc.nextInt(),y1=sc.nextInt();
        int x2=sc.nextInt(),y2=sc.nextInt();
        int r1=0,r2=0;
        r1+=Math.abs(((x1+y1)/(2*a))-((x2+y2)/(2*a)));
        if(((x1+y1)*1.0)/(x2+y2)<0) {
            r1++;
        }
        r2+=Math.abs(((x1-y1)/(2*b))-((x2-y2)/(2*b)));
        if(((x1-y1)*1.0)/(x2-y2)<0){
            r2++;
        }
        System.out.println(Math.max(r1,r2));
    }
}


import java.util.Scanner;

public class BeautifulYear {

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

		int n = sc.nextInt();
		int m = sc.nextInt();

		int inter = n*m;
		int pas=0;

		while(inter>=0 && n>=0 && m>=0)
		{
			inter--;
			n--;
			m--;
			pas++;
		}
		if(pas%2 == 0) System.out.println("Akshat");
		else System.out.println("Malvika");

	}
}


import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class palindromeDance {
    static int n, a, b;
    static int[] input;
    static ArrayList<Integer> unbought;
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        StringTokenizer st = new StringTokenizer(br.readLine());

         n = Integer.parseInt(st.nextToken());
         a = Integer.parseInt(st.nextToken());
         b = Integer.parseInt(st.nextToken());

        input = new int[n];

        st = new StringTokenizer(br.readLine());

        unbought = new ArrayList<Integer>();

        for(int i = 0; i < n; i++){
            input[i] = Integer.parseInt(st.nextToken());
            if(input[i] == 2){
                unbought.add(i);
            }
        }

 boolean alreadyComplete = true;

        for(int i = 0; i < n; i++){
            if(input[i] == 2){
                alreadyComplete = false;
            }
        }

         if(alreadyComplete && isPalindrome(input)){
            out.println(0);
            out.close();
        }
        else if(alreadyComplete && !isPalindrome(input)){
            out.println(-1);
            out.close();
        }
        else if(!alreadyComplete) {

            int n2 = Math.min(solve(0, a, input, 0), solve(0, b, input, 1));

            if (n2 == Integer.MAX_VALUE) {
                out.println(-1);
            } else {
                out.println(n2);
            }

            out.close();
        }

    }

    public static int solve(int pos, int cost, int[] list, int suit){

        list[unbought.get(pos)] = suit;

        if(pos == unbought.size()-1 && isPalindrome(list)){
            return cost;
        }
        //if is not palindrome
        else if(pos == unbought.size()-1){
            return Integer.MAX_VALUE;
        }

        return Math.min(solve(pos+1, cost+a, list, 0), solve(pos+1, cost+b, list, 1));
    }

    public static boolean isPalindrome(int[] list){
        int rightPointer = list.length-1;

        for(int i = 0; i < list.length/2; i++){
            if(list[i] != list[rightPointer]){
                return false;
            }
            rightPointer--;
        }

        return true;
    }

}


import java.util.Scanner;

public class Brain_Photo {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.nextLine();

		boolean color = false;
		for(int i = 0;i<n;i++)
		{
			String arr[] = sc.nextLine().split(" ");
			for(int j = 0;j<m;j++)
			{
				char ch = arr[j].charAt(0);
				if(ch == 'C' || ch == 'M' || ch == 'Y')
					color = true;
			}
		}

		if(color)
			System.out.println("#Color");
		else
			System.out.println("#Black&White");

		sc.close();

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.math.BigInteger;
import java.util.Random;
import java.util.StringTokenizer;

public class D {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();

        long a1 = sc.nextLong();
        long b1 = sc.nextLong();
        long a2 = sc.nextLong();
        long b2 = sc.nextLong();
        long left = sc.nextLong();
        long right = sc.nextLong();

        long lcm = lcm(a1, a2);
        left = Math.max(left, Math.max(b1, b2));

        // a1*x + b1 = a2*y + b2
        // a1*x - a2*y = b1 - b2
        long[] x_y_gcd = solveDiophantine(a1, -a2, b2 - b1);
        if (x_y_gcd == null) {
            System.out.println(0);
        } else {
            BigInteger a1Bi = BigInteger.valueOf(a1);
            BigInteger b1Bi = BigInteger.valueOf(b1);
            BigInteger leftBi = BigInteger.valueOf(left);
            BigInteger rightBi = BigInteger.valueOf(right);
            BigInteger lcmBi = BigInteger.valueOf(lcm);

            BigInteger firstEq = a1Bi.multiply(BigInteger.valueOf(x_y_gcd[0])).add(b1Bi);
            BigInteger diff = leftBi.subtract(firstEq).divide(lcmBi).subtract(BigInteger.ONE);
            firstEq = firstEq.add(diff.multiply(lcmBi));
            while (firstEq.compareTo(leftBi) < 0) { // Might only happen once or twice
                firstEq = firstEq.add(lcmBi);
            }
            if (rightBi.compareTo(firstEq) < 0) {
                System.out.println(0);
            } else {
                long count = Math.max(rightBi.subtract(firstEq).divide(lcmBi).longValue() + 1, 0);
                System.out.println(count);
            }
        }
    }

    /**
     * Finds a single solution {x, y} to the LDE a*x + b*y = c.
     * Outputs an array of the form {x, y, d}, where d = GCD(a,b).
     */
    private static long[] solveDiophantine(long a, long b, long c) {
        long[] e = extEuclid(a, b);
        long k = c / e[2];

        //c not divisible by the GCD(a,b) -> no solution
        if (c - k * e[2] != 0)
            return null;

        long[] output = {e[0] * k, e[1] * k, e[2]};
        return output;
    }

    /**
     * Extended Euclidean Algorithm finds {x, y, d}
     * where d=GCD(a,b) and x and y satisfy a*x + b*y = d
     * The output is an array of the form {x, y, d}.
     */
    private static long[] extEuclid(long a, long b) {
        long s0 = 1, s1 = 0, sTemp;
        long t0 = 0, t1 = 1, tTemp;
        long r0 = a, r1 = b, rTemp;
        long q;

        while (r1 != 0) {
            q = r0 / r1;

            rTemp = r1;
            r1 = r0 - q * r1;
            r0 = rTemp;

            sTemp = s1;
            s1 = s0 - q * s1;
            s0 = sTemp;

            tTemp = t1;
            t1 = t0 - q * t1;
            t0 = tTemp;
        }

        long[] output = {s0, t0, r0};
        return output;
    }

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

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

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public final class Main
{
    static class Cup
    {
        long c, w;

        Cup(long c, long w) {
            this.c = c;
            this.w = w;
        }

        static Comparator<Cup> cupComparator = new Comparator<Cup>() {
            @Override
            public int compare(Cup o1, Cup o2) {
                if (o1.c != o2.c)
                    return - Long.compare(o1.c, o2.c);
                return Long.compare(o1.w, o2.w);
            }
        };
    }

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

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

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

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

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

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

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

    private static long ans = 0;

    public static void main(String[] args)
    {
        FastReader fastReader = new FastReader();
        int n = fastReader.nextInt();
        int m = fastReader.nextInt();
        long d = fastReader.nextInt();
        ArrayList<Cup> cupsP = new ArrayList<>();
        ArrayList<Cup> cupsI = new ArrayList<>();

        for(int i = 0; i < n; i ++)
        {
            long c = fastReader.nextInt();
            long w = fastReader.nextInt();
            cupsP.add(new Cup(c, w));
        }

        long sumCI = 0, sumWI = 0;
        for(int i = 0; i < m; i ++)
        {
            long c = fastReader.nextInt();
            long w = fastReader.nextInt();
            sumCI += c; sumWI += w;
            cupsI.add(new Cup(c, w));
        }

        Collections.sort(cupsP, Cup.cupComparator);
        Collections.sort(cupsI, Cup.cupComparator);

        int idI = m - 1;
        long sumCP = 0, sumWP = 0;
        for(int idP = 0; idP < n; idP ++)
        {
            sumCP += cupsP.get(idP).c;
            sumWP += cupsP.get(idP).w;
            while (sumWP + sumWI > d && idI >= 0)
            {
                sumCI -= cupsI.get(idI).c;
                sumWI -= cupsI.get(idI).w;
                idI --;
            }
            if (sumWP + sumWI <= d && idI >= 0 && ans < sumCI + sumCP) {
                ans = sumCI + sumCP;
            }
        }

        System.out.print(ans);
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class r58 {
	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				System.out)));

		int a1=nextInt(),a2=nextInt(),b1=nextInt(),b2=nextInt();
			if((a1>=b2&&a1-b2==1)||(a2>=b1&&a2-b1==1))
				pw.println("YES");
			else
				if((b1>=a2&&(b1+1)/2-1<=a2)||(b2>=a1&&(b2+1)/2-1<=a1))
					pw.print("YES");
			else
			pw.print("NO");
		pw.close();
	}

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

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

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

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


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

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

		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();

		if (Math.abs(b) > n) {
			if (b > 0) {
				b = b%n;
			}
			else if (b < 0) {
				b = Math.abs(b)%n;
				b *= -1;
			}
		}
		if (b > 0) {
			int ans = (a+b)%n;
			if (ans == 0) {
				ans = n;
			}
			System.out.println(ans);
		} else if (b < 0) {
			int newB = (b+a);
			if (newB > 0) {
				System.out.println(newB);
			}
			else {
				int ans = n - Math.abs(newB);
				System.out.println(ans);
			}
		} else {
			System.out.println(a);
		}
	}
}


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

public class Emperor implements Runnable {
    static class Side implements Comparable<Side> {
        int dx;
        int dy;
        double alpha;
        Side next;

        public int compareTo(Side side) {
            return Double.compare(alpha, side.alpha);
        }

        public void getAlpha() {
            alpha = Math.atan2(dy, dx);
        }
    }

    static final int MAX = 500;
    static final int MAGIC = 7;
    List<Side> res;
    int tdx;
    int tdy;

    private void solve() throws IOException {
        int n = nextInt();
        Side[] first = new Side[MAX * MAX + 1];
        for (int dx = -MAX; dx <= MAX; ++dx)
            for (int dy = -MAX; dy <= MAX; ++dy) {
                int z = dx * dx + dy * dy;
                if (z <= MAX * MAX) {
                    Side s = new Side();
                    s.dx = dx;
                    s.dy = dy;
                    s.next = first[z];
                    first[z] = s;
                }
            }
        int total = 0;
        List<Side> firsts = new ArrayList<Side>();
        for (int len = 1;; ++len) {
            if (first[len] == null)
                continue;
            ++total;
            firsts.add(first[len]);
            if (total < n)
                continue;
            if (doit(firsts, n)) {
                System.err.println(n + " " + total);
                break;
            }
        }
        for (Side s : res)
            s.getAlpha();
        Collections.sort(res);
        int x = 0;
        int y = 0;
        writer.println("YES");
        for (Side s : res) {
            writer.println(x + " " + y);
            x += s.dx;
            y += s.dy;
        }
    }

    private boolean doit(List<Side> firsts, int n) {
        res = new ArrayList<Side>();
        tdx = 0;
        tdy = 0;
        return rec(firsts, n, firsts.size() - 1);
    }

    private boolean rec(List<Side> firsts, int toMake, int at) {
        if (toMake == 0) {
            return (tdx == 0 && tdy == 0);
        }
        if (at < 0) {
            throw new RuntimeException();
        }
        if (at >= MAGIC) {
            Side best = firsts.get(at);
            int bdist = (tdx + best.dx) * (tdx + best.dx) + (tdy + best.dy) * (tdy + best.dy);
            Side cur = best.next;
            while (cur != null) {
                int cdist = (tdx + cur.dx) * (tdx + cur.dx) + (tdy + cur.dy) * (tdy + cur.dy);
                if (cdist < bdist) {
                    bdist = cdist;
                    best = cur;
                }
                cur = cur.next;
            }
            res.add(best);
            tdx += best.dx;
            tdy += best.dy;
            if (rec(firsts, toMake - 1, at - 1))
                return true;
            res.remove(res.size() - 1);
            tdx -= best.dx;
            tdy -= best.dy;
        } else {
            Side best = firsts.get(at);
            while (best != null) {
                res.add(best);
                tdx += best.dx;
                tdy += best.dy;
                if (rec(firsts, toMake - 1, at - 1))
                    return true;
                res.remove(res.size() - 1);
                tdx -= best.dx;
                tdy -= best.dy;
                best = best.next;
            }
            if (at >= toMake)
                if (rec(firsts, toMake, at - 1))
                    return true;
        }
        return false;
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

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

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


import java.util.Scanner;
public class CarrotCakes {

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

        int time1=0;
        int tot1 = 0;

        for(int i = 1;tot1!=n&&tot1<=n;i++){
            time1=time1+t;
            tot1 = tot1 + k;
        }

      //   System.out.println();
      //   System.out.println("total    "+tot1);
       //  System.out.println("time     "+time1);

        int time2=0;
        int tot2 = 0;
        int f = 0;
        int ww =0;
        int oo = 0;
        for(int i = 1;true;i++){
          if(tot2>=n){break;}
          ww++;
          f++;
//          time2++;
          if(ww==t){
              tot2 = tot2+ k;
              ww=0;
          }
          if(f>d ){
           oo++;
          }
          if(oo==t){
              tot2 = tot2+ k;
              oo=0;
          }
          time2++;
    }

     //   System.out.println();
      //  System.out.println("total     "+tot2);
       // System.out.println("time      "+time2);

         if(time2<time1){System.out.println("YES");}
         else{System.out.println("NO");}

    }
}


import org.omg.CORBA.ARG_OUT;

import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: piyushd
 * Date: 3/26/11
 * Time: 10:53 PM
 * To change this template use File | Settings | File Templates.
 */
public class TaskC {

    int[] senior;

    long totalArrangements(int[] a) {
        int N = a.length;
        long[] dp = new long[1<<N];
        dp[0] = 1;
        for(int mask = 0; mask < (1<<N); mask++) {
            if(dp[mask] == 0) continue;

            int i = Integer.bitCount(mask);
            for(int j = 0; j < N; j++) {
                if(a[j] == -1 || a[j] == i) {
                    if((mask & (1<<j)) == 0) {
                        if((mask & senior[j]) == senior[j]) {
                           dp[mask | (1<<j)]  += dp[mask];
                        }
                    }
                }
            }
        }
        return dp[(1<<N) - 1];
    }

    void run(){
        int N = nextInt();
        long year = nextLong() - 2001;
        int M = nextInt();
        senior = new int[N];
        for(int i = 0; i < M; i++) {
            int a = nextInt() - 1;
            int b = nextInt() - 1;
            senior[b] |= (1<<a);
        }

        int[] ans = new int[N];
        Arrays.fill(ans, -1);

        for(int i = 0; i < N; i++) {
            while(true) {
                ans[i]++;
                if(ans[i] == N) {
                    System.out.println("The times have changed");
                    return;
                }

                long ways = totalArrangements(ans);
                if(year < ways) {
                    break;
                }
                else {
                    year -= ways;
                }
            }
        }

        for(int x : ans) System.out.print((x + 1) + " ");
        System.out.println();
    }

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

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

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

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

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

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


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

public class btest9
{
	public static void main(String[] args) throws Exception
	{
		InputReader in = new InputReader(System.in);
		OutputWriter out = new OutputWriter(System.out);
		int n=in.readInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)a[i]=in.readInt();
		int k=in.readInt();
		Arrays.sort(a);
		int lo,hi,mid;
		int fi=0;
		int ans=0;
		int max=-5;
		for(int i=0;i<n;i++)
		{
			lo=i+1;hi=n-1;fi=a[i]+k;
			while(lo<hi)
			{
				mid=lo+(hi-lo+1)/2;
				if(a[mid]>fi)hi=mid-1;
				else lo=mid;
			}
			if(lo<n&&a[lo]<=fi)ans=lo-i+1;
			else ans=1;
			if(ans>max)max=ans;
		}
		out.printLine(max);
		out.close();
	}

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

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

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

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

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

	private static class OutputWriter
	{
		private final PrintWriter writer;

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

		public OutputWriter(Writer writer)
		{
			this.writer = new PrintWriter(writer);
		}
 		public void print(Object... objects)
		{
			for (int i = 0; i < objects.length; i++)
			{
				if (i != 0)
				writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void printf(double n)
		{
			writer.printf("%.4f%n", n);
		}
		public void printLine(Object... objects)
		{
			print(objects);
			writer.println();
		}

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

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

	}
}


import java.util.*;
public class QAQ {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner as = new Scanner (System.in);
        Vector as1 = new Vector ();
        String qaq;
        int dd=0;
        qaq = as.next();

        String [] qaq1 = qaq.split("");
       // System.out.println(Arrays.toString(qaq1));
        for (int i =0;i<qaq1.length;i++){
        if(qaq1[i].equalsIgnoreCase("A") || qaq1[i].equalsIgnoreCase("Q") ){
        as1.add(qaq1[i]);

        }

        }
        //System.out.println(as1);
        for (int i =0; i<as1.size();i++){
            if(as1.get(i).equals("Q")){
                for (int z=i; z<as1.size();z++){

                if(as1.get(z).equals("A")){
                for(int c=z; c<as1.size();c++){
                if(as1.get(c).equals("Q")){
                dd++;
                }

                }

                }

                }

            }

        }
        System.out.println(dd);
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Created by Sergey on 19.09.2014.
 */
public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        BigInteger a = new BigInteger(in.next());
        String s17 = "100000000000000000";
        BigInteger ost = BigInteger.valueOf(45).multiply(BigInteger.valueOf(18)).multiply(new BigInteger(s17));
        ost = ost.add(BigInteger.ONE);
        ost = ost.mod(a);

        BigInteger L = BigInteger.ONE;
        BigInteger R = new BigInteger(s17 + "0");

        BigInteger add = a.subtract(ost);
        add = add.mod(a);

        L = L.add(add);
        R = R.add(add);

        System.out.println(L + " " + R);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

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


import javax.swing.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;

// Please name your class Main
public class Main {
    static FastScanner fs=new FastScanner();
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next() {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        int Int() {
            return Integer.parseInt(next());
        }

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

        String Str(){
            return next();
        }
    }

    public static void main (String[] args) throws java.lang.Exception {
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        //reading /writing file
        //Scanner in=new Scanner(System.in);
        //Scanner in=new Scanner(new File("input.txt"));
        //PrintWriter pr=new PrintWriter("output.txt");

        int T=1;
        for(int t=0;t<T;t++){
            Solution sol1=new Solution(out,fs);
            sol1.solution(T,t);
        }
        out.flush();

    }

    public static int[] Arr(int n){
        int A[]=new int[n];
        for(int i=0;i<n;i++)A[i]=Int();
        return A;
    }
    public static int Int(){
        return fs.Int();
    }
    public static long Long(){
        return fs.Long();
    }
    public static String Str(){
        return fs.Str();
    }

}

class Solution {
    PrintWriter out;
    int INF = Integer.MAX_VALUE;
    int NINF = Integer.MIN_VALUE;
    int MOD = 998244353;
    int mod = 1000000007;
    Main.FastScanner fs;

    public Solution(PrintWriter out, Main.FastScanner fs) {
        this.out = out;
        this.fs = fs;

    }

    public void solution(int all, int testcase) {
        int n = fs.Int();
        mod = fs.Int();

        long dp[][] = new long[n][n * n + 5];
        dp[0][0] = 1;
        for(int i = 1; i < n; i++) {
            for(int j = 0; j < dp[0].length; j++) {
                for(int cnt = 0; cnt <= i; cnt++){
                    if(j - cnt >= 0) {
                        dp[i][j] += dp[i - 1][j - cnt];
                        dp[i][j] %= mod;
                        if(dp[i][j] == 0){
                            dp[i][j] += mod;
                        }
                    }
                }
            }
        }

        long sums[][] = new long[dp.length][dp[0].length];
        for(int i = 0; i < dp.length;i++){
            int sum = 0;
            for(int j = 0; j < dp[0].length; j++){
                sum += dp[i][j];
                sum %= mod;
                if(sum == 0) sum += mod;
                sums[i][j] = sum;
            }
        }

        //init
        long fact[] = new long[501 * 501];
        fact[0] = fact[1] = 1;
        for(int i = 2; i < fact.length;i++){
            fact[i] = fact[i - 1] * i;
            fact[i] %= mod;
        }
        long ncr[][] = new long[501][501];
        ncr[0][0]=1;
        for (int i=1;i<ncr.length;i++) {
            ncr[i][0]=1;
            for (int j=1;j<ncr[0].length;j++) {
                ncr[i][j]=(ncr[i-1][j] + ncr[i-1][j-1])%mod;
                if(ncr[i][j] == 0)ncr[i][j] += mod;
            }
        }

        long res = 0;
        for(int i = n - 2; i >= 0; i--) {
            int cnt = n - i;
            int pre = n - cnt;
            long com = (ncr[n][pre] * fact[pre]) % mod;
            if(com == 0) com += mod;
            long sum = 0;

            long last[] = dp[cnt - 2];
            long ssum = 0;
            long total =0;
            for(int j = 2; j < dp[0].length; j++) { // j == inversions
                total += sums[cnt - 2][j - 2] * (cnt - 1);
                total %= mod;
                if(total == 0) total += mod;

                sum += last[j] * total;
                sum %= mod;
                if(sum == 0) sum += mod;

                ssum += sums[cnt - 2][j - 2];
                if(j - cnt - 1 >= 0) {
                    ssum -= sums[cnt - 2][j - cnt - 1];
                }
                ssum += mod;
                ssum %= mod;
                if(ssum == 0) ssum += mod;

                total -= ssum;
                total += mod;
                total %= mod;
                if(total == 0)total += mod;
            }
            res += sum * com;
            res%=mod;
            if(res == 0) res += mod;
        }
        out.println(res % mod);
    }
}


import java.util.Scanner;
public class abdo  {
public static void main(String[] args){
Scanner abd = new Scanner(System.in);
        String a=abd.next();
        String s=abd.next();
        int q=a.length(),k=0,z=0;
        int w=s.length();
        char[]x=new char[q+w];
        int f=0;
        for(int i=0;i<q;i++){
            x[i]=a.charAt(i);
            if(x[i]=='|'){
               k=q-(i+1);      //right
               z=q-(k+1);      //left
               f++;
            }
            if(f>0)
                break;
        }
        for(int i=0;i<w;i++){
            x[i]=s.charAt(i);
        }
//        System.out.println(z+" "+k);
         if(k<z){

             if(w==z-k){
                 System.out.println(a+s);
                 return;
             }
            else if(w-(z-k)>0){
              if((w-(z-k))%2==0){
                 for(int i=0;i<(w-(z-k))/2;i++){
                  System.out.print(x[i]);
                 }

                 System.out.print(a);
                 for(int i=(w-(z-k))/2;i<w;i++){
                     System.out.print(x[i]);
                 }
             }
              else{
                  System.out.println("Impossible");
                   return;
              }
            }
             else{
                  System.out.println("Impossible");
                 return;
             }
         }
         else if(z<k){

             if(w==k-z){
                 System.out.println(s+a);
                 return;
             }
            else if((w-(k-z))>0){
              if((w-(k-z))%2==0){
                 for(int i=(w-(k-z))/2;i<w;i++){
                     System.out.print(x[i]);
                 }
                 System.out.print(a);
                 for(int i=0;i<(w-(k-z))/2;i++){
                  System.out.print(x[i]);
                 }
             }
              else{
                  System.out.println("Impossible");
                 return;
             }
            }
              else{
                  System.out.println("Impossible");
                 return;
             }

         }
         else{
             if(w%2==0){
                 for(int i=0;i<(w/2);i++){
                  System.out.print(x[i]);
                 }
                 System.out.print(a);
                 for(int i=(w/2);i<w;i++){
                  System.out.print(x[i]);
                 }
             }
             else{
                  System.out.println("Impossible");
                 return;
             }
         }
}}


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

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

    static class TaskE {
        TaskE.GCDResult gcdExt(final long a, final long b) {
            TaskE.GCDResult result;
            if (a == 0) {
                result = new TaskE.GCDResult();
                result.d = b;
                result.x = 0;
                result.y = 1;

                return result;
            }
            result = gcdExt(b % a, a);
            long t = result.x;
            result.x = result.y - (b / a) * t;
            result.y = t;

            return result;
        }

        public void solve(int testNumber, FastScanner in, FastWriter out) {
            long n = in.nextInt();
            long m = in.nextInt();
            long x0 = in.nextInt();
            long y0 = in.nextInt();
            int vx = in.nextInt();
            int vy = in.nextInt();

            long x;
            long y;
            if (vx == 0 || vy == 0) {

                if (x0 == 0) {
                    x = 0;
                    if (vx != 0) {
                        out.println(-1);
                        return;
                    }
                    if (vy > 0) {
                        y = m;
                    } else {
                        y = 0;
                    }
                } else if (x0 == n) {
                    x = n;
                    if (vx != 0) {
                        out.println(-1);
                        return;
                    }
                    if (vy > 0) {
                        y = m;
                    } else {
                        y = 0;
                    }
                } else if (y0 == 0) {
                    y = 0;
                    if (vy != 0) {
                        out.println(-1);
                        return;
                    }
                    if (vx > 0) {
                        x = n;
                    } else {
                        x = 0;
                    }
                } else if (y0 == m) {
                    y = m;
                    if (vy != 0) {
                        out.println(-1);
                        return;
                    }
                    if (vx > 0) {
                        x = n;
                    } else {
                        x = 0;
                    }
                } else {
                    out.println(-1);
                    return;
                }

                out.println(x + " " + y);
            } else {

                if (vx < 0) x0 = n - x0;
                if (vy < 0) y0 = m - y0;

                //vx = 1, vy = 1
                long c = x0 - y0;
                TaskE.GCDResult g = gcdExt(n, m);
                if (c % g.d == 0) {
                    c /= g.d;

                    x = g.x * c;
                    y = g.y * c;

                    long dx = m / g.d;
                    long dy = n / g.d;
                    if (x < 0) {
                        long d = (-x) / dx;
                        if (-x % dx > 0) d++;

                        x += d * dx;
                        y -= d * dy;
                    }

                    if (y > 0) {
                        long d = y / dy;
                        if (y % dy > 0) d++;

                        x += d * dx;
                        y -= d * dy;
                    }
                    if (x > 0 && y < 0) {
                        long d1 = x / dx;
                        long d2 = -y / dy;
                        long d = Math.min(d1, d2);
                        if (d > 0) {
                            x += d * dx;
                            y -= d * dy;
                        }
                    }

                    if (x == 0 && y == 0) {
                        x += dx;
                        y -= dy;
                    }

                    x = n * (x % 2);
                    y = m * (-y % 2);

                    if (vx < 0) x = n - x;
                    if (vy < 0) y = m - y;
                    out.println(x + " " + y);
                } else {
                    out.println(-1);
                }
            }
        }

        static class GCDResult {
            long x;
            long y;
            long d;

            public String toString() {
                return "GCDResult{" +
                        "x=" + x +
                        ", y=" + y +
                        ", d=" + d +
                        '}';
            }

        }

    }

    static class FastScanner {
        static final int BUFFER_SIZE = 1 << 18;
        final BufferedReader input;
        StringTokenizer buffer;

        public FastScanner(InputStream inputStream) {
            input = new BufferedReader(new InputStreamReader(inputStream), BUFFER_SIZE);
        }

        private String readToken() {
            try {
                if (buffer == null || !buffer.hasMoreTokens()) {
                    buffer = new StringTokenizer(input.readLine());
                }
                return buffer.nextToken();
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }

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

    }

    static class FastWriter extends PrintWriter {
        static final int BUFFER_SIZE = 1 << 18;

        public FastWriter(OutputStream out) {
            super(new BufferedOutputStream(out, BUFFER_SIZE));
        }

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

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

    }
}


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

public class Getting_an_A {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        double n=Double.parseDouble(br.readLine());
        String str[]=br.readLine().split(" ");
        double a[]=new double[(int) n];
        double sum=0;
        for(int i=0;i<n;i++) {
            a[i] = Double.parseDouble(str[i]);
            sum+=a[i];
        }
        Arrays.sort(a);
        long count=0;
        if(sum/n>=4.5)
            System.out.println("0");
        else
        {
            long value=round((n*4.5)-sum);
            for(int i = 0; i<n; i++)
            {
                if(value<=0)
                    break;
                long diff= (long) (5-a[i]);
                if(diff>0)
                {
                    value-=diff;
                    count++;
                }

            }
            System.out.println(count);
        }
    }
    private static int  round(double d) {
        double dAbs = Math.abs(d);
        int i = (int) dAbs;
        double result = dAbs - (double) i;
        if (result < 0.5) {
            return d < 0 ? -i : i;
        } else {
            return d < 0 ? -(i + 1) : i + 1;
        }
    }
}


import java.io.*;

public class IlyaBank {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = in.readLine();
		int num = Integer.parseInt(line);
		if (Integer.parseInt(line) < 0) {
			if (line.charAt(line.length() - 1) >= line.charAt(line.length() - 2)) {
				num /= 10;
			} else {
				int add = Character.getNumericValue(line.charAt(line.length() - 1));
				num /= 100;
				num *= 10;
				num -= add;
			}
		}
		System.out.println(num);
	}
}


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

/**
 * Created by vikas.k on 14/03/17.
 */
public class CF086C {
    public static PrintWriter out;
    public static FastScanner in;
    private List<Integer> primes;

    private void solve(){
        int lo = in.nextInt();
        int hi = in.nextInt();

        int limit = (int)Math.sqrt(hi);
        boolean[] mrk = simpleSieve(limit);
        primes = new ArrayList<>();
        for(int i=2;i<mrk.length;i++){
            if(mrk[i]) primes.add(i);
        }
        int cnt = 0;
        if(2 >= lo && 2<=hi) cnt++;
        if(lo<=limit){
            int k = (lo-1)%4 == 0 ? (lo-1)/4 : ((lo-1)/4 + 1);
            int st = 4*k+1;
            while (st<=limit){
                if(mrk[st]) cnt++;
                st = 4*(++k)+1;
            }
            lo = limit+1;
        }

        for(;lo+limit<=hi;lo+=limit+1){
            mrk = sieve(lo,lo+limit);
            int k = (lo-1)%4 == 0 ? (lo-1)/4 : ((lo-1)/4 + 1);
            int st = 4*k+1;
            while (st<=lo+limit){
                if(mrk[st-lo]) cnt++;
                st = 4*(++k)+1;
            }
        }
        mrk = sieve(lo,hi);
        int k = (lo-1)%4 == 0 ? (lo-1)/4 : ((lo-1)/4 + 1);
        int st = 4*k+1;
        while (st<=hi){
            if(mrk[st-lo]) cnt++;
            st = 4*(++k)+1;
        }
        out.print(cnt);
    }

    private boolean[] sieve(int lo,int hi){
        boolean[] ret = new boolean[hi-lo+1];
        Arrays.fill(ret,true);

        for (int p:primes){
            int st = lo%p == 0 ? lo : ((lo/p)+1)*p;
            for(int i = st;i<=hi;i+=p){
                ret[i-lo]= false;
            }
        }
        return ret;
    }
    private boolean[] simpleSieve(int n){
        boolean[] ret = new boolean[n+1];
        Arrays.fill(ret,true);
        ret[0] = false;
        ret[1] = false;
        for(int i=2+2;i<=n;i+=2){
            ret[i] = false;
        }

        for(int i=3;i*i<=n;i+=2){
            if(ret[i]){
                for(int j=i*2;j<=n;j+=i){
                    ret[j] = false;
                }
            }
        }
        return ret;
    }

    private void runIO(){
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner(){
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next(){
            if(stringTokenizer == null || !stringTokenizer.hasMoreElements()){
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt(){
            return Integer.parseInt(next());
        }
        private long nextLong(){
            return Long.parseLong(next());
        }
        private String nextLine(){
            String ret= "";
            try {
                ret= bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new CF086C().runIO();
    }
}


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

public class Main {
    static void solve() throws IOException {
        int n = ni1();
        rl();
        int a[] = new int[n];
        int b[] = new int[n];
        int c[] = new int[n];
        for (int i = 0; i < n; i++) a[i] = b[i] = ni2();
        Arrays.sort(b);
        for (int i = 0; i < n; i++) {
            int k = Arrays.binarySearch(b, a[i]);
            c[i] = b[(k + 1) % n];
        }
        for (int i = 0; i < n; i++) ans.append(c[i]).append(" ");
        output.write(ans.toString());
        output.flush();
        output.close();
    }

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

    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuilder ans = new StringBuilder();
    static String line;
    static StringTokenizer stringTokenizer;

    static int ni1() throws IOException {
        return Integer.parseInt(input.readLine());
    }

    static int ni2() throws IOException {
        return Integer.parseInt(stringTokenizer.nextToken());
    }

    static long nl1() throws IOException {
        return Long.parseLong(input.readLine());
    }

    static long nl2() {
        return Long.parseLong(stringTokenizer.nextToken());
    }

    static void rl() throws IOException {
        stringTokenizer = new StringTokenizer(input.readLine());
    }
}


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

public class Problem931B {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader();
		int n=s.nextInt();
		int a=s.nextInt();
		int b=s.nextInt();
		int temp1=Integer.max(a, b);
		int temp2=Integer.min(a, b);
		a=temp2;
		b=temp1;
		int count=0;
		int rounds=0;
		int temp=n;
		while(temp>0) {
			temp=temp/2;
			rounds++;
		}
		rounds--;
		int start=0;
		int end=n;
		while(end>start) {
			int mid=(end+start)/2;
			if(mid>=a && mid<b) {
				break;
			}else if(mid>=a && mid>=b){
				end=mid;
				count++;
			}else if(mid<a && mid<b) {
				start=mid;
				count++;
			}
		}
		if(count==0) {
			out.println("Final!");
			out.close();
			return;
		}
		out.println(rounds-count);
		out.close();
	}

	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct

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

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

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

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

}


import java.io.*;
public class round29B {

    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String [] use = br.readLine().split(" ");
        int totDist = Integer.parseInt(use[0]);
        int trafficDist = Integer.parseInt(use[1]);
        int speed = Integer.parseInt(use[2]);
        int green = Integer.parseInt(use[3]);
        int red = Integer.parseInt(use[4]);
        double t1 = (double)trafficDist / (double)speed;
        double cur = green;
        boolean f = true;
        while(t1 >= cur){
            cur += (f == true) ? red : green;
            f = !f;
        }
        t1 += f == false ? (cur - t1) : 0;
        t1 += ((double)(totDist - trafficDist) / (double)speed);
        System.out.println(t1);
    }
}


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

public class Main {
//	static Scanner in; static int next() throws Exception {return in.nextInt();};
//	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
	static BufferedReader in;
	static PrintWriter out;
	static int n = 1000;
	static boolean[][] win = new boolean[n][n];

	static HashMap<String, Integer> map;

	static boolean go(long a, long b) {
//		System.out.println(a + " " + b);
		//if (a < n && b < n) return win[(int)a][(int)b];
		if (a == 0 || b == 0) return false;

		if (a > b) {
			long temp = a;
			a = b;
			b = temp;
		}

		long c = b % a;

		boolean w1 = go(c, a);
		if (!w1) return true;

		long d = b/a;

		if (a % 2 == 1) return d % 2 == 0;

		long e = d % (a + 1);
		return e % 2 == 0;
	}

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

	static int rand() {return (int)(Math.random() * 1e9);}

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

/*		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) if (i != 0 || j != 0) if (!win[i][j]) {
				if (i < j) for (int t = i + j; t < n; t += j) win[t][j] = true;
				else for (int t = i + j; t < n; t += i) win[i][t] = true;

				if (j > 1) for (int t = j; i + t < n; t *= j) win[i + t][j] = true;
				else if (j > 0 && i + j < n) win[i + j][j] = true;
				if (i > 1) for (int t = i; j + t < n; t *= i) win[i][j + t] = true;
				else if (i > 0 && i + j < n) win[i][j + i] = true;
			}
	   	}*/

/*	   	for (int i = 0; i < 50; i++) {
	   		for (int j = 0; j < 50; j++) out.print(win[i][j] ? "1 " : "0 ");
	   		out.println();
	   	}
	   	int count = 0;
	   	for (int i = 1; i < n; i++) for (int j = 1; j < n; j++) if (!win[i][j]) count++;
	   	out.println(count);*/

		int tests = Integer.parseInt(in.readLine());
		for (int test = 0; test < tests; test++) {
			map = new HashMap<String, Integer>();
			String[] s = in.readLine().split(" ");
			out.println(go(Long.parseLong(s[0]), Long.parseLong(s[1])) ? "First" : "Second");
		}

		out.close();
	}
}


import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

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

		char[] here = new char[n];
		char[] current = new char[n];
		char[] result = new char[n];
		;
		int te = n - 2;
		String temp = sc.next();
		for (int i = 0; i < n; i++) {
			here[i] = temp.charAt(i);
		}

		int count = 0;

		while (count != t) {
			if (count == 0)
				current = here;

			else {
				current = result;
				result = new char[n];
			}
			int i ;
			for ( i = 0; i < n - 1; i++) {
				char c = current[i];
				char b = current[i + 1];
				if (c == 'B')
					if (b == 'G') {
						result[i] = 'G';
						result[i + 1] = 'B';
						i++;
					} else {
						result[i] = 'B';
						result[i + 1] = 'B';
					}
				else {
					result[i] = c;
					result[i + 1] = b;

					if (b == 'G')
						i++;

				}

			}
			if(i==n-1){
				result[n-1]=current[n-1];

			}
			if (i<n-1) {
				char c = result[te];
				char b = current[n - 1];
				System.out.println(c);
				System.out.println(b);
				if (c == 'B')
					if (b == 'G') {
						result[te] = 'G';
						result[n - 1] = 'B';
					} else {
						result[te] = 'B';
						result[n - 1] = 'B';
					}
				else {
					result[te] = c;
					result[n - 1] = b;
				}
			}
			count++;
		}

		System.out.println(result);

	}
}


/*
    Author: Anthony Ngene
    Created: 24/08/2020 - 05:51
*/

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

public class A {
// It is only a fool that goes to dinner with the devil and fails to use a long spoon. - African Proverb
    public static void main(String[] args) throws IOException {
        in = new FastScanner();

        int n = in.intNext();
        int[] arr = in.nextIntArray(n);

        HashSet<Integer> seen = new HashSet<>();
        List<Integer> unique = new ArrayList<>();
        for (int i = n - 1; i >= 0; i--) {
            if (!seen.contains(arr[i])) {
                seen.add(arr[i]);
                unique.add(arr[i]);
            }
        }
        out.println(unique.size());
        for (int i = unique.size()-1; i >= 0; i--) {
            out.p(unique.get(i)).p(" ");
        }
        out.close();
    }

// checks: 1. edge cases   2. overflow   3. possible errors (e.g 1/0, arr[out])   4. time/space complexity
// Generated Code Below:
private static final FastWriter out = new FastWriter();
private static FastScanner in;
static ArrayList<Integer>[] adj;
private static long e97 = (long)1e9 + 7;
static class FastWriter {
    private static final int IO_BUFFERS = 128 * 1024;
    private final StringBuilder out;
    public FastWriter() { out = new StringBuilder(IO_BUFFERS); }
    public FastWriter p(Object object) { out.append(object); return this; }
    public FastWriter p(String format, Object... args) { out.append(String.format(format, args)); return this; }
    public FastWriter pp(Object... args) { for (Object ob : args) { out.append(ob).append(" ");  } out.append("\n"); return this; }
    public FastWriter pp(int[] args) { for (int ob : args) { out.append(ob).append(" ");  } out.append("\n"); return this; }
    public FastWriter pp(long[] args) { for (long ob : args) { out.append(ob).append(" ");  } out.append("\n"); return this; }
    public FastWriter pp(char[] args) { for (char ob : args) { out.append(ob).append(" ");  } out.append("\n"); return this; }
    public void println(long[] arr) { out.append(Arrays.toString(arr)).append("\n"); }
    public void println(int[] arr) { out.append(Arrays.toString(arr)).append("\n"); }
    public void println(char[] arr) { out.append(Arrays.toString(arr)).append("\n"); }
    public void println(double[] arr) { out.append(Arrays.toString(arr)).append("\n"); }
    public void println(boolean[] arr) { out.append(Arrays.toString(arr)).append("\n"); }
    public <T>void println(T[] arr) { out.append(Arrays.toString(arr)).append("\n"); }
    public void println(long[][] arr) {  for (long[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public void println(int[][] arr) {  for (int[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public void println(char[][] arr) {  for (char[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public void println(double[][] arr) {  for (double[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public <T>void println(T[][] arr) {  for (T[] row: arr) out.append(Arrays.toString(row)).append("\n"); }
    public FastWriter println(Object object) { out.append(object).append("\n"); return this; }
    public void toFile(String fileName) throws IOException {
        BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
        writer.write(out.toString());
        writer.close();
    }
    public void close() throws IOException { System.out.print(out); }
}
static class FastScanner {
    private InputStream sin = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(){}
    public FastScanner(String filename) throws FileNotFoundException {
        File file = new File(filename);
        sin = new FileInputStream(file);
    }
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = sin.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long longNext() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b) || b == ':'){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int intNext() {
        long nl = longNext();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double doubleNext() { return Double.parseDouble(next());}
    public long[] nextLongArray(final int n){
        final long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = longNext();
        return a;
    }
    public int[] nextIntArray(final int n){
        final int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = intNext();
        return a;
    }
    public double[] nextDoubleArray(final int n){
        final double[] a = new double[n];
        for (int i = 0; i < n; i++)
            a[i] = doubleNext();
        return a;
    }
    public ArrayList<Integer>[] getAdj(int n) {
        ArrayList<Integer>[] adj = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) adj[i] = new ArrayList<>();
        return adj;
    }
    public ArrayList<Integer>[] adjacencyList(int nodes, int edges) throws IOException {
        return adjacencyList(nodes, edges, false);
    }
    public ArrayList<Integer>[] adjacencyList(int nodes, int edges, boolean isDirected) throws IOException {
        adj = getAdj(nodes);
        for (int i = 0; i < edges; i++) {
            int a = intNext(), b = intNext();
            adj[a].add(b);
            if (!isDirected) adj[b].add(a);
        }
        return adj;
    }
}

}


import java.util.*;

public class NonSquareEquation {

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

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        for (int i = 1; i <= 90; i++) {
            double x = ((-1 * i) + (Math.sqrt(i * i - (-4 * n))));
            if (x > 0 && x % 2 == 0) {
                x /= 2;
                long x2 = (long) x;
                int sum = sum((long) x);
                long tmp = x2 * x2 + i * x2;
                if (tmp == n && i == sum) {
                    System.out.println(x2);
                    return;
                }

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


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

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int max = 0;
            for (int b = 0; b < k; b++) {
                int sum = 0;
                for (int i = 0; i < n; i++) {
                    if ((i + b) % k != 0) {
                        sum += a[i];
                    }
                }
                max = Math.max(max, Math.abs(sum));
            }
            out.println(max);
        }

    }
}


//package srm304;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.LinkedList;

public class SoldierAndCards {

    static class Card {
        int number;

        public Card(int number) {
            this.number = number;
        }

        @Override
        public String toString() {
            return String.valueOf(number);
        }
    }

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        LinkedList<Card> playerOne = new LinkedList<Card>();
        LinkedList<Card> playerTwo = new LinkedList<Card>();

        String[] parts = br.readLine().split(" ");
        for (int i = 1; i < parts.length; i++) {
            playerOne.add(new Card(Integer.parseInt(parts[i])));
        }

        parts = br.readLine().split(" ");
        for (int i = 1; i < parts.length; i++) {
            playerTwo.add(new Card(Integer.parseInt(parts[i])));
        }

        HashSet<String> visited = new HashSet<String>();

        StringBuilder sb = new StringBuilder();
        for (Card c : playerOne)
            sb.append(c.toString() + " ");
        sb.append("\n");
        for (Card c : playerTwo)
            sb.append(c.toString() + " ");
        visited.add(sb.toString());

        int counter = 0;
        while (playerOne.size()>0 && playerTwo.size()>0) {
            counter++;
            Card top1 = playerOne.poll();
            Card top2 = playerTwo.poll();

            if (top1.number > top2.number) {
                playerOne.add(top2);
                playerOne.add(top1);
            } else {
                playerTwo.add(top1);
                playerTwo.add(top2);
            }

            sb = new StringBuilder();
            for (Card c : playerOne)
                sb.append(c.toString() + " ");
            sb.append("\n");
            for (Card c : playerTwo)
                sb.append(c.toString() + " ");

            if (visited.contains(sb.toString())) {
                break;
            }
            visited.add(sb.toString());

        }

        if (playerOne.size() == 0) {
            System.out.println(counter + " " + 2);
            return;
        }
        if (playerTwo.size() == 0) {
            System.out.println(counter + " " + 1);
            return;
        }
        System.out.println(-1);
    }

}


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

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] fib = new int[n + 10];
        fib[1] = 1;
        fib[2] = 1;
        for (int i = 3; i <= n; i++)
            fib[i] = add(fib[i - 1], fib[i - 2]);
        int den = modPow(2, n);
        out.println(mult(fib[n], modPow(den, mod - 2)));
        out.flush();
        out.close();
    }

    static final int mod = 998244353;

    static int add(int a, int b) {
        long c = a + b;
        if (c >= mod) c -= mod;
        if (c < 0) c += mod;
        return (int) c;
    }

    static int mult(long a, int b) {
        return (int) (a * b % mod);
    }

    static int modPow(int b, int e) {
        int res = 1;
        while (e > 0) {
            if ((e & 1) == 1) res = mult(res, b);
            b = mult(b, b);
            e >>= 1;
        }
        return res;
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(s));
        }

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

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

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

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

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

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

    }
}


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

import java.util.Scanner;

/**
 *
 * @author a
 */
public class Number7 {
    public static void main(String[] args) {
        Scanner l=new Scanner (System.in);
        int B=0;
        int arr[]=new int [8];
        for (int i = 0; i <8; i++) {
            arr[i]=0;
        }
        for (int i = 0; i < 8; i++) {
            String ch=l.next();
            int c=0;
            for (int j = 0; j < 8; j++) {
                if(ch.charAt(j)=='B'){
                    c++;
                    arr[j]++;
                }

                 if(c==8)
                     B++;

            }
        }

        if(B!=8)
        for (int i = 0; i <8; i++) {
            if(arr[i]==8)
                B++;

        }
        System.out.println(B);

    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class B_Round_144_Div1 {

	public static long MOD = 1000000007;
	static long[][] dp;
	static long[][]pre;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		long m = in.nextLong();
		int k = in.nextInt();
		long[][] c = new long[101][101];
		c[0][0] = 1;

		for (int i = 1; i < 101; i++) {
			c[i][0] = 1;
			c[i][i] = 1;
			for (int j = 1; j < i; j++) {
				c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
				c[i][j] %= MOD;
			}
		}
		dp = new long[n][k + 1];
		for (long[] a : dp) {
			Arrays.fill(a, -1);
		}
		pre = new long[2][n + 1];
		for(int i = 0; i <= n; i++){
			long total = m/n;
			pre[0][i] = pow(c[n][i], total);
			pre[1][i] = (c[n][i]*pre[0][i]) % MOD;
		}
		long v = cal(0, k, n, m, c);
		out.println(v);
		out.close();
	}

	static long cal(int index, int left,int n, long m, long[][]c){

    	if(index  == n){
    		if(left == 0){
    			return 1;
    		}
    		return 0;
    	}
    	if(left == 0){
    		return 1;
    	}
    	if(dp[index][left] != -1){
    		return dp[index][left];
    	}
    	long result = 0;
    	for(int i = 0; i <= Math.min(left, n); i++){
    		long a = pre[0][i];

    		if(m % n > index && m %n != 0){
    			a = pre[1][i];
    		}

    		//System.out.println(i + " " + a + " " + index + " " + total);
    		result += (a*cal(index + 1, left - i, n, m ,c)) %MOD;
    		result %= MOD;
    	}
    	return dp[index][left] = result;
    }

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return x - o.x;
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

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

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

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

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

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

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

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

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}


//package year2019.month03.cf.eduround61div2;

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

public class eduround61div2A {

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

    public eduround61div2A() throws IOException {
        InputReader in;
        if (ONLINE_JUDGE) {
            in = new InputReader(System.in);
        } else {
            in = new InputReader(new FileInputStream("/Users/karj/cp/input.txt"));
        }
        PrintWriter out = new PrintWriter(System.out);

        int T = 1;
        for (int caseNo = 1; caseNo <= T; caseNo++) {
            solve(caseNo, in, out);
        }

        out.close();
    }

    private void solve(int caseNo, InputReader in, PrintWriter out) throws IOException {
        long a1 = in.nextLong();
        long a2 = in.nextLong();
        long a3 = in.nextLong();
        long a4 = in.nextLong();
        if (a1 == 0 &&
                a2 == 0 &&
                a3 == 0 &&
                a4 == 0) {
            out.println(1);
            return;
        }
        if (a1 == 0 &&
                a3 == 0 &&
                a4 == 0 &&
                a2 > 0) {
            out.println(1);
            return;
        }
        if (a1 != a4) {
            out.println(0);
            return;
        }
        if (a1 == a4 && a1 == 0) {
            out.println(0);
            return;
        }
        out.println(1);
    }

    static class InputReader {

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

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

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

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

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

        public interface SpaceCharFilter {

            public boolean isSpaceChar(int ch);
        }

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

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

        public 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() {
            return Long.parseLong(nextString());
        }

        public Double nextDouble() {
            return Double.parseDouble(nextString());
        }

        public char nextCharacter() {
            return nextString().charAt(0);
        }

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

        public long[] nextLongArray(int N) {
            long A[] = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = nextLong();
            }
            return A;
        }

        public double[] nextDoubleArray(int N) {
            double A[] = new double[N];
            for (int i = 0; i < N; i++) {
                A[i] = nextDouble();
            }
            return A;
        }
    }

    int min(int... a) {
        int min = Integer.MAX_VALUE;
        for (int v : a) {
            min = Math.min(min, v);
        }
        return min;
    }

    long min(long... a) {
        long min = Long.MAX_VALUE;
        for (long v : a) {
            min = Math.min(min, v);
        }
        return min;
    }

    double min(double... a) {
        double min = Double.MAX_VALUE;
        for (double v : a) {
            min = Math.min(min, v);
        }
        return min;
    }

    int max(int... a) {
        int max = Integer.MIN_VALUE;
        for (int v : a) {
            max = Math.max(max, v);
        }
        return max;
    }

    long max(long... a) {
        long max = Long.MIN_VALUE;
        for (long v : a) {
            max = Math.max(max, v);
        }
        return max;
    }

    double max(double... a) {
        double max = Double.MIN_VALUE;
        for (double v : a) {
            max = Math.max(max, v);
        }
        return max;
    }

    private void debug(Object... o) {
        if (ONLINE_JUDGE) {
            return;
        }
        System.out.println(Arrays.deepToString(o));
    }

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


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

public class noldbach {

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

		int topNumber = s.nextInt();
		int kPrimes = s.nextInt();
		int totalPrimes = 0;

		List<Integer> myList = new ArrayList<Integer>();

		for(int count = 2; count <= topNumber; count++){
			if(isPrime(count)){
				myList.add(count);
			}

		}

		for(int count = 0; count < myList.size() - 1; count++){
			int first = myList.get(count);
			int second = myList.get(count + 1);

			for(int counter = 0; counter < myList.size(); counter++){
				int n = myList.get(counter);
				if(isNoldbach(first, second, n)){
					totalPrimes++;
				}
			}

		}

		if(totalPrimes >= kPrimes) System.out.println("YES");
		else System.out.println("NO");
	}

	public static boolean isPrime(int n){
		for(int i = 2; i < n; i++){
			if(n % i == 0) return false;
		}
		return true;
	}

	public static boolean isNoldbach(int primeOne, int primeTwo, int n){
		if(primeOne + primeTwo + 1 == n) return true;
		return false;
	}

}