import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.concurrent.ThreadLocalRandom;

public class Main2 {

    static long mod = 1000000007L;
    static FastScanner scanner;

    public static void main(String[] args) {
        scanner = new FastScanner();
        int n = scanner.nextInt();
        int T = scanner.nextInt();

        int[][] songs = new int[n][2];
        for (int i = 0; i < n; i++) {
            songs[i][0] = scanner.nextInt();
            songs[i][1] = scanner.nextInt() - 1;
        }

        long[][][][] dp = new long[17][65536][3][T + 10];
        int mask = 1;
        for (int i = 0; i < n; i++) {
            dp[1][mask][songs[i][1]][songs[i][0]] = 1;
            mask <<= 1;
        }
        for (int i = 1; i < n; i++) {
            mask = 1;
            for (int k = 0; k < n; k++) {
                int cg = songs[k][1];

                int g1,g2;
                if (cg == 0) {g1 = 1; g2 = 2;}
                else if (cg == 1) {g1 = 0; g2 = 2;}
                else {g1 = 0; g2 = 1;}

                for (int j = 1; j < 65536; j++) {
                    if ((j & mask) != 0) continue;
                    for (int t = 0; t <= T - songs[k][0]; t++) {
                        dp[i + 1][j | mask][cg][t + songs[k][0]] += dp[i][j][g1][t] + dp[i][j][g2][t];
                    }
                }
                mask <<= 1;
            }
        }
        int sum = 0;
        for (int i = 0; i< 17; i++) {
            for (int j = 0; j < 65536; j++)
                for (int g = 0; g < 3; g++)
                    sum += dp[i][j][g][T];
        }
        System.out.println(sum);
    }

    static long test(long[] b, long c, int maxSkipped, int startWith) {
        int skipped = 0;
        long lastSkipped = b[0];
        for (int i = startWith; i < b.length; i++) {
            long expected = b[0] + c * (i - skipped);
            if (b[i] != expected) {
                skipped++;
                lastSkipped = b[i];
                if (skipped > maxSkipped) {
                    return Long.MAX_VALUE;
                }
            }
        }
        return lastSkipped;
    }

    static boolean test2(long[] b, long c) {
        for (int i = 1; i < b.length; i++) {
            long expected = b[1] + c * (i - 1);
            if (b[i] != expected) {
                return false;
            }
        }
        return true;
    }

//    5 5
//    1 1 5 2 3

    static class WithIdx implements Comparable<WithIdx> {
        int val;
        int idx;

        public WithIdx(int val, int idx) {
            this.val = val;
            this.idx = idx;
        }

        @Override
        public int compareTo(WithIdx o) {
            if (val == o.val) {
                return Integer.compare(idx, o.idx);
            }
            return -Integer.compare(val, o.val);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException();
            }
        }

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

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

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

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

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

        String[] nextStringArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) res[i] = nextToken();
            return res;
        }
    }

    static class PrefixSums {
        long[] sums;

        public PrefixSums(long[] sums) {
            this.sums = sums;
        }

        public long sum(int fromInclusive, int toExclusive) {
            if (fromInclusive > toExclusive) throw new IllegalArgumentException("Wrong value");
            return sums[toExclusive] - sums[fromInclusive];
        }

        public static PrefixSums of(int[] ar) {
            long[] sums = new long[ar.length + 1];
            for (int i = 1; i <= ar.length; i++) {
                sums[i] = sums[i - 1] + ar[i - 1];
            }
            return new PrefixSums(sums);
        }

        public static PrefixSums of(long[] ar) {
            long[] sums = new long[ar.length + 1];
            for (int i = 1; i <= ar.length; i++) {
                sums[i] = sums[i - 1] + ar[i - 1];
            }
            return new PrefixSums(sums);
        }
    }

    static class ADUtils {
        static void sort(int[] ar) {
            Random rnd = ThreadLocalRandom.current();
            for (int i = ar.length - 1; i > 0; i--)
            {
                int index = rnd.nextInt(i + 1);
                // Simple swap
                int a = ar[index];
                ar[index] = ar[i];
                ar[i] = a;
            }
            Arrays.sort(ar);
        }

        static void reverse(int[] arr) {
            int last = arr.length / 2;
            for (int i = 0; i < last; i++) {
                int tmp = arr[i];
                arr[i] = arr[arr.length - 1 - i];
                arr[arr.length - 1 - i] = tmp;
            }
        }

        static void sort(long[] ar) {
            Random rnd = ThreadLocalRandom.current();
            for (int i = ar.length - 1; i > 0; i--)
            {
                int index = rnd.nextInt(i + 1);
                // Simple swap
                long a = ar[index];
                ar[index] = ar[i];
                ar[i] = a;
            }
            Arrays.sort(ar);
        }
    }

    static class MathUtils {
        static long[] FIRST_PRIMES = {
                2,     3,      5,      7,     11,     13,     17,     19,     23,     29,
                31,     37,     41,     43,     47,     53,     59,     61,     67,     71,
                73,     79,     83,     89  ,   97 ,    101,    103,    107,    109,    113,
                127,    131,    137,    139,    149,    151,    157,    163,    167,    173,
                179,    181,    191,    193,    197,    199,    211,    223,    227,    229,
                233,    239,    241,    251,    257,    263,    269,    271,    277,    281,
                283,    293,    307,    311,    313,    317,    331,    337,    347,    349,
                353,    359,    367,    373,    379,    383,    389,    397,    401,    409,
                419,    421,    431,    433,    439,    443,    449,    457,    461,    463,
                467,    479,    487,    491,    499,    503,    509,    521,    523,    541,
                547,    557,    563,    569,    571,    577,    587,    593,    599,    601,
                607,    613,    617,    619,    631,    641,    643,    647,    653,    659,
                661,    673,    677,    683,    691,    701,    709,    719,    727,    733,
                739,    743,    751,    757,    761,    769,    773,    787,    797,    809,
                811,    821,    823,    827,    829,    839,    853,    857,    859,    863,
                877,    881,    883,    887,    907,    911,    919,    929,    937,    941,
                947,    953,    967,    971,    977,    983,    991,    997,   1009,   1013,
                1019,   1021,   1031,   1033,   1039,   1049,   1051};

        static long[] primes(int to) {
            long[] all = new long[to + 1];
            long[] primes = new long[to + 1];
            all[1] = 1;
            int primesLength = 0;
            for (int i = 2; i <= to; i ++) {
                if (all[i] == 0) {
                    primes[primesLength++] = i;
                    all[i] = i;
                }
                for (int j = 0; j < primesLength && i * primes[j] <= to && all[i] >= primes[j]; j++) {
                    all[(int) (i * primes[j])] = primes[j];
                }
            }
            return Arrays.copyOf(primes, primesLength);
        }

        static long modpow(long b, long e, long m) {
            long result = 1;

            while (e > 0) {
                if ((e & 1) == 1) {
                    /* multiply in this bit's contribution while using modulus to keep
                     * result small */
                    result = (result * b) % m;
                }
                b = (b * b) % m;
                e >>= 1;
            }

            return result;
        }

        static long submod(long x, long y, long m) {
            return (x - y + m) % m;
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion();
        solver.solve(1, in, out);
        out.close();
    }

    static class G1PlaylistForPolycarpEasyVersion {
        static ArrayList<Integer> list;
        static int n;
        static int req;
        static int[] dur;
        static int[] genre;
        static Integer[][][][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            n = sc.nextInt();
            req = sc.nextInt();
            dur = new int[n];
            genre = new int[n];
            list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                dur[i] = sc.nextInt();
                genre[i] = sc.nextInt();
            }
            int ans = 0;
            memo = new Integer[1 << n][n + 1][n + 1][4];
            for (int i = 0; i <= n; i++)
                ans += bf(0, 0, 0, i);
            pw.print(ans);
        }

        private int bf(int idx, int msk, int before, int max) {
            if (idx == max) {
                int sum = 0;
                for (int x : list)
                    sum += x;
                if (sum == req)
                    return 1;
                return 0;
            }
            if (memo[msk][idx][max][before] != null)
                return memo[msk][idx][max][before];
            int toRet = 0;
            for (int i = 0; i < n; i++) {
                if (genre[i] != before && (msk & 1 << i) == 0) {
                    list.add(dur[i]);
                    toRet += bf(idx + 1, msk | 1 << i, genre[i], max);
                    list.remove(list.size() - 1);
                }
            }
            return memo[msk][idx][max][before] = toRet;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

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

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

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

    }
}


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

public class D {

	int INF = Integer.MAX_VALUE / 1000;
	static Scanner sc = null;
	int n = 0;
	int[] d = null;
	boolean[][] dp = null;
	public void solve() throws Exception{

		n = sc.nextInt();
		d = readIntArray(n);
		dp = new boolean[n][1 << n];
		dp[0][1] = true;
		for(int i = 1; i < n; i++){
			int max = 1 << i;
			for(int j = 0; j < max; j++){
				if(dp[i-1][j]){

					for(int k = 0; k < i; k++){
						if( ((1 << k) & j) == 0) continue;

						for(int m = k; m < i; m++){
							if( ((1 << m) & j) == 0) continue;
							if(d[k] + d[m] == d[i]){
								int nj = j | (1 << i);
								dp[i][nj] = true;
								for(int p = 0; p < i; p++){
									int mask = 1 << p;
									if( (j & mask) > 0){
										dp[i][(j^mask) | 1 << i ] = true;
									}
								}
							}
						}
					}
				}
			}
		}
		int ans = INF;
		for(int i = 0; i < 1 << n; i++){
			if(dp[n-1][i]){
				int tmp = i;
				int num = 0;
				while(tmp > 0){
					if( (tmp & 1) > 0){
						num++;
					}
					tmp = tmp >> 1;
				}
				ans = Math.min(ans, num);
			}
		}
		if(ans != INF){
			System.out.println(ans);
		}
		else{
			System.out.println("-1");
		}
	}

    public int[] readIntArray(int n) {
        int[] ret = new int[n];
        for (int i = 0; i < n; i++) {
            ret[i] = sc.nextInt();
        }
        return ret;
    }

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		File file = new File("input.txt");
		if(file.exists()){
			System.setIn(new BufferedInputStream(new FileInputStream("input.txt")));
		}
		sc =  new Scanner(System.in);
		D t = new D();
		t.solve();

	}

}


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

/*
inputs:
5
1 2 3 6 8

2

3
3 6 5

-1

6
2 4 8 6 10 18

3
 */

public class MinimumNumberOfVariables {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[] m = new int[n];
		for(int i=0;i<n;i++){
			m[i] = sc.nextInt();
		}

		//index[a][b] = c -> m[b] + m[c] = m[a], b&c<a
		int[][] index = new int[n][n];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				index[i][j] = -1;
			}
		}

		for(int a=0; a<n; a++){
			for(int b=0; b<a; b++){
				for(int c=0; c<a; c++){
					if(m[b] + m[c] == m[a]){
						index[a][b] = c;
					}
				}
			}
		}

		//isPossible[i][Set] = true if u can finish the ith step (read m[0...i])
		//with exactly els = Set
		//only need to keep 2 rows actually, but whatever
		boolean[][] isPossible = new boolean[n][1<<n];
		for(int i=0;i<isPossible.length;i++){
			isPossible[i] = new boolean[1<<n];
		}
		isPossible[0][1] = true;

		for(int i=1; i<n; i++){
			//System.out.println("i = " + i);
			for(int p=(1<<i); p<(1<<(i+1)); p++){
				//System.out.println("Checking state of " + Integer.toBinaryString(p));
				//go through all the possible previous states of p
				//shift 0 mask from 0 to i (to include possibility of no missing stuff)
				int pWithoutNewEl = p & ((1<<i)-1);
				//System.out.println("State without new element = " + Integer.toBinaryString(pWithoutNewEl));
				for(int exist = 0; exist < i && !isPossible[i][p]; exist++){
					int prevState = (1<<exist) | pWithoutNewEl;
					//System.out.println("exist = "+ exist + ", prevState with exist = " + Integer.toBinaryString(prevState));
					if(isPossible[i-1][prevState]){
						//check if there exists a sum
						for(int prevStateI = 0; prevStateI < i; prevStateI++){
							int bitAt = (prevState >> prevStateI) & 1;
							if(bitAt == 1){
								int compBitI = index[i][prevStateI];
								if(compBitI != -1 && ((prevState >> compBitI) & 1) == 1){
									//exist a sum!
									isPossible[i][p] = true;
									break;
								}
							}
						}
					}
				}
			}
		}

		int min = Integer.MAX_VALUE;
		for(int p=0; p< (1<<n); p++){
			if(isPossible[n-1][p])
				min=Math.min(min, Integer.bitCount(p));
		}

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

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

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

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.stream.Stream;

public class Solution implements Runnable {

	static final long MOD = Long.MAX_VALUE;
	static final Reader in = new Reader();
	static final PrintWriter out = new PrintWriter(System.out);
	StringBuilder answer = new StringBuilder();

	public static void main(String[] args) {
		// long startt = System.nanoTime();
		new Thread(null, new Solution(), "persefone", 1 << 28).start();
		// out.println((System.nanoTime() - startt));

	}

	@Override
	public void run() {
		solve(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt());
		printf();
	}

	void solve(int x1, int y1, int x2, int y2) {
		if ((x1 + x2) <= Math.max(x2, y2) || (x1 <= x2 && y1 <= y2))
			printf("Polycarp");
		else
			printf("Vasiliy");
	}

	void computeHashArray(long[] hash, CharSequence s, int n) {
		for (int i = 1; i <= n; i++)
			hash[i] = (31 * hash[i - 1] + s.charAt(i - 1) - 'a') % MOD;
	}

	void computeModArray(long[] mod, int n) {
		mod[0] = 1;
		for (int i = 1; i <= n; i++)
			mod[i] = (mod[i - 1] * 31) % MOD;
	}

	long getHash(long[] hash, long[] mod, int i, int j) {
		return (hash[j] - hash[i] * mod[j - i]) % MOD;
	}

	long getHash(String s) {
		long hash = 0;
		for (int i = 0; i < s.length(); i++)
			hash = (hash * 31 + s.charAt(i) - 'a') % MOD;
		return hash;
	}

	void printf() {
		out.print(answer);
		out.close();
	}

	void printf(Stream<?> str) {
		str.forEach(o -> add(o, " "));
		add("\n");
	}

	void printf(Object... obj) {
		if (obj.getClass().isPrimitive()) {
			add(obj, "\n");
			return;
		}
		if (obj.length > 1) {
			printf(Arrays.stream(obj));
			return;
		}

		if (obj.length == 1) {
			Object o = obj[0];
			if (o instanceof int[])
				printf(Arrays.stream((int[]) o).boxed());
			else if (o instanceof char[])
				printf(String.valueOf(o).chars());
			else if (o instanceof long[])
				printf(Arrays.stream((long[]) o).boxed());
			else if (o instanceof double[])
				printf(Arrays.stream((double[]) o).boxed());
			else
				add(o, "\n");
		}
	}

	void printf(Collection<?> col) {
		printf(col.stream());
	}

	<T, K> void add(T t, K k) {
		if (t instanceof Collection<?>) {
			((Collection<?>) t).forEach(i -> add(i, " "));
		} else if (t instanceof Object[]) {
			Arrays.stream((Object[]) t).forEach(i -> add(i, " "));
		} else
			add(t);
		add(k);
	}

	<T> void add(T t) {
		answer.append(t);
	}

	static class Node {
		private String x, y;

		Node(String x, String y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o)
				return true;
			if (o == null || !(o instanceof Node))
				return false;
			Node node = (Node) o;
			return x.equals(node.x) && y.equals(node.y);
		}

		@Override
		public int hashCode() {
			int hash = 31;
			hash = 89 * hash + x.hashCode();
			hash = 89 * hash + y.hashCode();
			return hash;
		}

		@Override
		public String toString() {
			return x + " " + y;
		}
	}

	static class Pair<K extends Comparable<? super K>, V extends Comparable<? super V>>
			implements Comparable<Pair<K, V>> {
		private K k;
		private V v;

		Pair() {
		}

		Pair(K k, V v) {
			this.k = k;
			this.v = v;
		}

		K getK() {
			return k;
		}

		V getV() {
			return v;
		}

		void setK(K k) {
			this.k = k;
		}

		void setV(V v) {
			this.v = v;
		}

		void setKV(K k, V v) {
			this.k = k;
			this.v = v;
		}

		@SuppressWarnings("unchecked")
		@Override
		public boolean equals(Object o) {
			if (this == o)
				return true;
			if (o == null || !(o instanceof Pair))
				return false;
			Pair<K, V> p = (Pair<K, V>) o;
			return k.compareTo(p.k) == 0 && v.compareTo(p.v) == 0;
		}

		@Override
		public int hashCode() {
			int hash = 31;
			hash = hash * 89 + k.hashCode();
			hash = hash * 89 + v.hashCode();
			return hash;
		}

		@Override
		public int compareTo(Pair<K, V> pair) {
			return k.compareTo(pair.k) == 0 ? v.compareTo(pair.v) : k.compareTo(pair.k);
		}

		@Override
		public Pair<K, V> clone() {
			return new Pair<K, V>(this.k, this.v);
		}

		@Override
		public String toString() {
			return String.valueOf(k).concat(" ").concat(String.valueOf(v)).concat("\n");
		}
	}

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

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

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

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

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

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

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


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

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

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out){
	    int PX = in.ri(), PY = in.ri(), VX = in.ri(), VY = in.ri();
	    int PMOVE = 1;
	    while(true){
		    if (PX == 0 && PY == 0){
			    out.printLine("Polycarp");
			    return;
		    }
		    if(VX == 0 && VY == 0){
			    out.printLine("Vasiliy");
			    return;
		    }
		    if (PMOVE == 1){
			    if (PX > 0) PX--;
			    else PY--;
		    }
		    else{
			    if ((VX - 1 != PX || VY - 1 != PY) && VX > 0 && VY > 0){
				    VX--;
				    VY--;
			    }
			    else if (VY > 0) VY--;
			    else VX--;
		    }
		    if (PX < 0 || PY < 0 || VX < 0 || VY < 0) throw new RuntimeException();
		    PMOVE ^= 1;
	    }
    }
}

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 ri(){
		return readInt();
	}

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

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

class OutputWriter {
	private final PrintWriter writer;

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


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

public class A669 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        int o = 0;
        for(int i = 1; i <= n; i++){
            if (i%2!=0){
                list.add(1);
                n--;
            }
            else
                list.add(2);
        }
        for (int i = 0; i < list.size();i++){
            o++;
        }
        System.out.print(o);
    }
}


import java.util.*;
public class Main{
public static void main(String... args){
Scanner sc = new Scanner(System.in);
int[][] t = new int[3][3];
for (int i=0; i<3; i++)
for (int j=0; j<3; j++)
  t[i][j]=sc.nextInt();
int k = sc.nextInt();
long[][][] r = new int[k+1][3][3];
for (int i=1; i<=k; i++){
  for (int a = 0; a<3; a++){
    for (int b=0; b<3; b++){
      if (a==b) continue;
      int c = 1^2^a^b;
      long x1 = r[i-1][a][c] + t[a][b] + r[i-1][c][b];
      long x2 = r[i-1][a][b] + t[a][c] + r[i-1][b][a] + t[c][b] + r[i-1][a][b];
      r[i][a][b] = Math.min(x1,x2);
      //System.out.println(i+" "+a+"-"+b+":"+r[i][a][b]+"  ("+x1+","+x2+")");
    }
  }
}
System.out.println(r[k][0][2]);
}
}


/*
 * 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.
 */

import java.util.Scanner;

/**
 *
 * @author TEAM5_CODESPRINT2018
 */
public class ProblemJ {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int t = s.nextInt();
        int k = s.nextInt();
        int d = s.nextInt();
        int fk=0;
        int ft=0;
        int sk=0;
        int st=0;
        int tk=0;
        int tt=0;
        int count=0;
        int diff=0;
        if(k>n)
        {
            System.out.print("No");
        }
        else{
            for(int i=1;i>0;i++)
            {
                fk+=k;
                ft+=t;
                    if(fk>=n)
                    {
                        break;
                    }
            }

            if(d<=t){
                for(int i = 1; i>0;i++){
                if(st<t)
                {
                    sk+=k;
                    st+=t;
                }
                else{
                    sk+=k;
                    st+=t;
                    if (sk>=n)
                    {
                        st-=(t-d);
                            if(ft<=st){
                                System.out.print("No");
                                break;
                            }
                            else
                            {
                                System.out.print("Yes");
                                break;
                            }
                    }
                    sk+=k;
                    st+=t;
                    if (sk>=n)
                    {
                        st-=(t-d);
                            if(ft<=st){
                                System.out.print("No");
                                break;
                            }
                            else
                            {
                                System.out.print("Yes");
                                break;
                            }
                    }
                }
            }
            }
            else if(d>t){
                for(int i = 1; i>0;i++)
                {
                    if(tt<=d)
                    {
                        tt+=t;
                        tk+=k;
                        if(tk>=n){
                            if(ft<=tt){
                                System.out.print("No");
                                break;
                            }
                            else
                            {
                                System.out.print("Yes");
                                break;
                            }
                        }
                    }
                    else{
                        tt+=t;
                        tk+=k;
                        if(tk>=n){
                            for(int j = 1; j>0;j++)
                            {
                                count+=d;
                                if(count>d)
                                {
                                    diff=count-d;
                                }
                            }
                            tt-=diff;
                                if(ft<=tt){
                                System.out.print("No");
                                break;
                            }
                            else
                            {
                                System.out.print("Yes");
                                break;
                            }
                        }
                        tt+=t;
                        tk+=k;
                        if(tk>=n){
                            for(int j = 1; j>0;j++)
                            {
                                count+=d;
                                if(count>d)
                                {
                                    diff=count-d;
                                }
                            }
                            tt-=diff;
                                if(ft<=tt){
                                System.out.print("No");
                                break;
                            }
                            else
                            {
                                System.out.print("Yes");
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
}


import java.util.Scanner;

public class chocolate{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int kmin, kmax;
		if (n >= 2 * m)
			kmin = n - 2 * m;
		else
			kmin = 0;
		kmax = (int) (n - (Math.ceil((1 + Math.sqrt((double)(1 + 8 * m)))/2)));
		System.out.println(kmin + " " + kmax);

	}
}


import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class CF2{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		ArrayList<String> A = new ArrayList<String>();
		//C, C#, D, D#, E, F, F#, G, G#, A, B, H
		A.add(C);
		A.add(C#);
		A.add(D);
		A.add(D#);
		A.add(E);
		A.add(F);
		A.add(F#);
		A.add(G);
		A.add(G#);
		A.add(A);
		A.add(B);
		A.add(H);
		String X = sc.next();
		String Y = sc.next();
		String Z = sc.next();
		int n = Math.abs(A.indexOf(X)-A.indexOf(Y));
		int m = Math.abs(A.indexOf(Y)-A.indexOf(Z));
		int p = Math.abs(A.indexOf(X)-A.indexOf(Z));
		int x = Math.min(n, 12-n);
		int x1 = Math.max(n, 12-n);
		int y = Math.min(m, 12-m);
		int y1 = Math.max(m, 12-m);
		int z = Math.min(p, 12-p);
		int z1 = Math.max(p, 12-p);
		if(x==4 || x==3 || x1== 7){
		    if(x1==7){
		        if(z==4 && y==3){
		            System.out.println("major");
		        }
		        else if(z==3 && y==4){
		            System.out.println("minor");
		        }
		    }
		    else if(y1==7){
		        if(x==4 && z==3){
		            System.out.println("major");
		        }
		        else if(x==3 && z==4){
		            System.out.println("minor");
		        }
		    }
		    else if(z1==7){
		        if(x==4 && y==3){
		            System.out.println("major");
		        }
		        else if(x==3 && y==4){
		            System.out.println("minor");
		        }
		    }
		}
		else{
		    System.out.println("strange");
		}
	}
}


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
 *
 * @author kessido
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        GTakeMetro solver = new GTakeMetro();
        solver.solve(1, in, out);
        out.close();
    }

    static class GTakeMetro {
        int step(int n, long t, int s, int m) {
            int curJump = (int) (t % n);
            int sign = s < m ? 1 : -1;
            s += sign * curJump;
            s %= n;
            if (s < 0) s += n;
            return s;
        }

        int doLoop(int s, long t, int n, int m) {
            for (int i = 0; i < n; i++) {
                s = step(n, t--, s, m);
            }
            return s;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.NextInt();
            int m = in.NextInt();
            int s = in.NextInt() - 1;
            long t = in.NextLong();
            while (t != 0) {
                s = step(n, t--, s, m);
            }
            long[] lastSeem = new long[n];
            int round = 0;
            Arrays.fill(lastSeem, -1);
            while (t != 0) {
                s = doLoop(s, t, n, m);
                t -= n;
                if (lastSeem[s] != -1) {
                    long interval = lastSeem[s] - t;
                    t %= interval;
                    break;
                } else {
                    lastSeem[s] = round++;
                }
            }
            while (t != 0) {
                s = step(n, t--, s, m);
            }
            out.println(s + 1);
        }

    }

    static class InputReader {
        BufferedReader reader;
        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(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}


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

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

    static class GTakeMetro {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            int s = in.nextInt() - 1;
            long t = in.nextLong();
            while (t % n != 0) {
                if (s < m) {
                    s = (int) ((s + t) % n);
                } else {
                    s = (int) ((s - t) % n);
                    if (s < 0) s += n;
                }
                t--;
            }
            t /= n;
            int ps = -1;
            while (t-- > 0) {
                for (int i = n - 1; i >= 1; i--) {
                    if (s < m) {
                        s = (s + i) % n;
                    } else {
                        s = (s - i + n) % n;
                    }
                }
                if (s == ps) break;
                ps = s;
            }
            out.println(s + 1);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1 << 16];
        private int curChar;
        private int numChars;

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

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException var2) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public long nextLong() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            long res = 0L;

            while (c >= 48 && c <= 57) {
                res *= 10L;
                res += (long) (c - 48);
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * (long) sgn;
                }
            }

            throw new InputMismatchException();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }
}


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

/**
 *
 * @author shaolin
 */
public class TavasAndNavas2 {

    static int[] numbers;
    static int totalDigits;
    static int index;

    public static void main(String[] args) {
        numbers = new int[1000000000];
        totalDigits = 10;
        index = 1;
        Queue<String> queue = new Queue<>();
        String number;
        queue.enqueue("4");
        queue.enqueue("7");
//        queue.add("47");
        numbers[4] = index++;
        numbers[7] = index++;
        while (!queue.isEmpty()) {
            number = queue.dequeue();
            if (number.length() < totalDigits) {
                queue.enqueue(number + "4");
                queue.enqueue(number + "7");
                numbers[Integer.parseInt(number) * 10 + 4] = index++;
                numbers[Integer.parseInt(number) * 10 + 7] = index++;
            }
        }
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(numbers[n]);
    }

    static class Queue<T> {

        private ArrayList<T> objects;

        public Queue() {
            this.objects = new ArrayList<T>();
        }

        public void enqueue(T t) {
            this.objects.add(t);
        }

        public T dequeue() {
            if (isEmpty()) {
                return null;
            }
            T t = this.objects.get(0);
            this.objects.remove(0);
            return t;
        }

        public boolean isEmpty() {
            return this.objects.size() == 0;
        }
    }

}


import java.util.*;
public class Main {
    public static int n, m;
    public static int[] arr;
    public static TreeSet<Integer>[] set;
    public static boolean ok(int day) {
        int[] clone = arr.clone();
        int[] last = new int[n];
        for (int i = 0; i < n; i++) {
            Integer res = set[i].floor(day);
            last[i] = (res == null) ? -1 : res;
        }
        int burles = 0;
        for (int i = 0; i <= day; i++) {
            burles++;
            for (int j = 0; j < n; j++) {
                if (last[j] == i) {
                    while (clone[j] > 0 && burles > 0) {
                        burles--;
                        clone[j]--;
                    }
                }
            }
        }
        for (int i = 0; i < n; i++) {
            while (clone[i] > 0) {
                clone[i]--;
                burles -= 2;
            }
        }
        return burles >= 0;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        set = new TreeSet[n];
        for (int i = 0; i < n; i++) {
            set[i] = new TreeSet<>();
        }
        for (int i = 0; i < m; i++) {
            int d = in.nextInt() - 1;
            int t = in.nextInt() - 1;
            set[t].add(d);
        }
        for (int i = 0; i <= 2000; i++) {
            if (ok(i)) {
                System.out.println(i + 1);
                break;
            }
        }
    }
}


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

//Mann Shah [ DAIICT ].
//fast io

public class Main {
	static int mod = (int) (1e9+7);
	static InputReader in;
    static PrintWriter out;

		public static void main(String args[] )  {

		  in = new InputReader(System.in);
	      out = new PrintWriter(System.out);

	      long n = in.nextLong();
	      long b = in.nextLong();

	      boolean[] p = new boolean[10000002];
	      for(int i=0;i<=10000001;i++) {
	    	  	p[i]=true;
	      }
	      for(int i=2;i*i<=10000001;i++) {
	    	  		if(p[i]) {
	    	  			for(int j=i+i;j<=10000001;j+=i) {
	    	  				p[i]=false;
	    	  			}
	    	  		}
	      }
	      ArrayList<Long> ar = new ArrayList();
	      for(int i=2;i<=10000001;i++) {
	    	  	if(p[i]) {
	    	  		ar.add((long)i);
	    	  	}
	      }
	      long min = Long.MAX_VALUE;

	      for(int i=0;i<ar.size();i++) {
		      long c=0;
	    	  long temp = n;
	    	  	while(temp>0) {
		    	  	c+= Math.floor(temp/b);
		    	  	temp/=b;
		      }
	    	  	min = Math.min(min, c);
	      }
	      if(n<b) {
	    	  	out.print("1");
	      }
	      else {
	      out.print(min);
	      }
	     out.close();
		}

	 static class InputReader
	    {

	        private final InputStream stream;
	        private final byte[] buf = new byte[8192];
	        private int curChar, snumChars;
	        private SpaceCharFilter filter;

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

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

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

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

	        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 String readString()
	        {
	                int c = snext();
	                while (isSpaceChar(c))
	                {
	                        c = snext();
	                }
	                StringBuilder res = new StringBuilder();
	                do
	                {
	                        res.appendCodePoint(c);
	                        c = snext();
	                } while (!isSpaceChar(c));
	                return res.toString();
	        }

	        public String nextLine()
	        {
	                int c = snext();
	                while (isSpaceChar(c))
	                        c = snext();
	                StringBuilder res = new StringBuilder();
	                do
	                {
	                        res.appendCodePoint(c);
	                        c = snext();
	                } while (!isEndOfLine(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;
	        }

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

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

	    }

}

//For Pair sorting

//Arrays.sort(arr,new Comparator<Pair>() {
//		@Override public int compare(Pair p1, Pair p2)
//{
//    return p1.x - p2.x;
//}
//});

//Pair arr[] = new Pair[n];
//arr[0] = new Pair(10, 20);
class Pair {
    int x;
    int y;

    // Constructor
public Pair(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}
// class Compare {
//	  //void return by default.
//     public  Pair[] compare(Pair arr[], int n)
//    {
//        // Comparator to sort the pair according to first element.
//        Arrays.sort(arr, new Comparator<Pair>() {
//            @Override public int compare(Pair p1, Pair p2)
//            {
//                return p1.x - p2.x;
//            }
//        });
//
//
//        return arr;
//       /* for (int i = 0; i < n; i++) {
//            System.out.print(arr[i].x + " " + arr[i].y + " ");
//        }
//        System.out.println(); */
//    }
//}
//

class couple implements Comparable<couple>
{ int x,y;
  public couple(int m,int f) {
 	 x=m;
 	 y=f;
  }
	public int compareTo(couple o) {

		return x-o.x;
	}
}


package proj2;

import java.util.Scanner;

public class petrCalendar {

	public static void main(String[] args)

	{

		Scanner s =new Scanner(System.in);
		System.out.println("Enter the month");
		int m=s.nextInt();
		System.out.println("enter the weekday");
		int d=s.nextInt();

		if(m<8)
		{
			if(m%2== 0)
			{
				checkdate30(d);
			}
			else
			{
				checkdate31(d);
			}
		}
		else if(m>8 && m<12)
		{
			if(m%2==0)
			{
				checkdate31(d);
			}
			else
			{
				checkdate30(d);
			}
		}

	}

	private static void checkdate31(int d) {
		// TODO Auto-generated method stub

		if(d>=6 && d<=7)
		{
		System.out.println("6");

		}
		else if(d<6)
		{
			System.out.println("5");
		}
	}

	private static void checkdate30(int d) {
		// TODO Auto-generated method stub
		if(d==7)
		{
			System.out.println("6");
		}
		else if(d<7 && d>0)
		{
			System.out.println("5");
		}

	}

}


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

public class Petr {

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

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int m = Integer.parseInt(reader.readLine());
		int d = Integer.parseInt(reader.readLine());

		int brDana,brTjedana=0;

		if( (m<=7 && m%2==1) || (m>=8 && m%2==0) )
			brDana=31;
		else if( m == 2 )
			brDana=28;
		else
			brDana=30;

		brDana = brDana - (7-d) -1;
		brTjedana++;

		for(;brDana>0;brDana-=7)
			brTjedana++;

		System.out.println(brTjedana);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.stream.IntStream;

public class d {
    public static void main(String[] args) {
        FS in = new FS(System.in);
        PrintWriter out = new PrintWriter(System.out);

        new d().solve(in, out);

        out.close();
    }

    public void solve(FS in, PrintWriter out) {
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int d = x2-x1;
        int a = in.nextInt();
        int b = in.nextInt();
        if(Integer.signum(a) != Integer.signum(b)) {
            if(d >= a && d <= b) {
                System.out.println("FIRST");
                System.out.println(x2);
            } else {
                System.out.println("DRAW");
            }
            return;
        }
        int has = 1;
        if(a < 0) {
            a *= -1;
            b *= -1;
            d *= -1;
            has *= -1;
            a ^= b;
            b ^= a;
            a ^= b;
        }
        if(d < 0) {
            System.out.println("DRAW");
            return;
        }

        if(d%(a+b) == 0) {
            System.out.println("SECOND");
            return;
        }

        if(d%(a+b) < a || d%(a+b) > b) {
            System.out.println("DRAW");
            return;
        }

        System.out.println("FIRST");
        System.out.println(x1+has*(d%(a+b)));
    }

    static class FS {

        BufferedReader in;
        StringTokenizer token;

        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }

        public String next() {
            if (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }

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


//package round109;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class D2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	String F = "FIRST";
	String S = "SECOND";
	String D = "DRAW";

	void solve()
	{
		int x1 = ni(), x2 = ni(), a = ni(), b = ni();
		int ox1 = x1, ox2 = x2;
		if(x1 > x2){
			int d = x1; x1 = x2; x2 = d;
			a = -a;
			b = -b;
		}
		int d = x2 - x1;
		if(d-b <= 0 && 0 <= d-a){
			out.println(F);
			out.println(ox2);
			return;
		}

		if(a > 0){
			if(d % (a+b) >= a){
				out.println(F);
				int mv = d % (a+b) - (a-1);
				if(ox1 == x1){
					out.println(ox1 + mv);
				}else{
					out.println(ox1 - mv);
				}
			}else if(d % (a+b) >= 1 && d % (a+b) <= b){
				out.println(D);
			}else{
				out.println(S);
			}
		}else if(a == 0){
			out.println(D);
		}else if(b <= 0){
			out.println(D);
		}else if(-a >= b){
			out.println(D);
			// a<0<b
		}else{
			if(d % (b+(-a+1)) >= 1 && d % (b+(-a+1)) <= b){
				out.println(F);
				int mv = d % (b+(-a+1));
				if(ox1 == x1){
					out.println(ox1 + mv);
				}else{
					out.println(ox1 - mv);
				}
			}else{
				out.println(D);
			}
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

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

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.util.Scanner;

public class p62a {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int f1 = in.nextInt();
        int f2 = in.nextInt();

        int m1 = in.nextInt();
        int m2 = in.nextInt();
        if(f1-m2 == 1 || f2-m1 == 1) {
            System.out.println("YES");
            return;
        }
        if(f1 <= m2) {
            int maxMale = f1*2;
            if(m2<=maxMale) {
                System.out.println("YES");
                return;
            }
        }
        if(f2<=m1) {
            int maxMale = f2*2;
            if(m1<=maxMale) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        JzzhuAndSequences solver = new JzzhuAndSequences();
        solver.solve(1, in, out);
        out.close();
    }

    static class JzzhuAndSequences {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int mod = (int) 1e9 + 7;
            long x = in.nextLong();
            long y = in.nextLong();
            int n = in.nextInt();
            long[] vals = new long[n];
            vals[0] = x;
            vals[1] = y;
            for (int i = 2; i < n; i++) {
                vals[i] = (vals[i - 1] - vals[i - 2] + 2 * mod) % mod;
            }
            out.println((vals[n - 1] + mod) % mod);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

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

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

    }
}


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

public class Main {
    static PrintWriter w = new PrintWriter(System.out);
    static Reader sc = new Reader();

    public static void main(String args[]) throws IOException {
        int tc = 1;
        for (int i = 1; i <= tc; i++) {
            // w.print("Case #"+(i)+": ");
            solve();
        }
        w.close();
    }

    //// SOLUTION BEGIN <--------------------------------------->
    public static void solve() {
        int mod = (int)1e9+7;
        long f1 = sc.ni();
        long f2 =sc.ni();
        int n = sc.ni();
        long arr[] = new long[n+1];
        arr[1] = (f1+mod)%mod;
        arr[2] = (f2+mod)%mod;
        for (int i = 3; i <=n; i++) {
            arr[i] = (arr[i-1] - arr[i-2]+mod)%mod;
        }
        w.println(arr[n]);
    }

    //// SOLUTION END <------------------------------------------->

    // Class for Fast I/O------------------------------
    static class Reader {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

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

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

        public String nline() {
            try {
                return br.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DRomanAndNumbers solver = new DRomanAndNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DRomanAndNumbers {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            char[] s = in.scanString().toCharArray();
            int m = in.scanInt();
            int n = s.length;
            for (int i = 0; i < n; i++) {
                if (s[i] != '0') dp[1 << i][(s[i] - '0') % m] = 1;
            }
            int[] si = new int[n];
            for (int i = 0; i < n; i++) si[i] = s[i] - '0';
            Arrays.sort(si);

            long[][] dp = new long[1 << n][m];
            dp[0][0] = 1;
            for (int i = 0; i < 1 << n; i++) {
                for (int j = 0; j < m; j++) {
                    if (dp[i][j] == 0) continue;
                    for (int k = 0; k < n; k++) {
                        if (i << 31 - k >= 0) {
                            if (i == 0 && si[k] == 0) continue;
                            if (k > 0 && si[k] == si[k - 1] && i << 31 - (k - 1) >= 0) continue;
                            dp[i | 1 << k][(j * 10 + si[k]) % m] += dp[i][j];
                        }
                    }
                }
            }
            out.println(dp[(1 << n) - 1][0]);

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


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

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    FastReader sc=new FastReader();
	    String s=sc.next();
	    HashMap<Integer,Character> hm = new HashMap<Integer, Character>();
	    int l=s.length();
	    int c=0;
	    for(int i=0;i<l;i++)
	    {
	        char z=s.charAt(i);
	        if(z=='.' && c!=3){
	       hm.clear();
	        c=0;
	        }
	        else if(z!='.' && c <3)
	        {
	            if(hm.containsValue(z)==false)
	            hm.put(++c,z);
	            else
	            {
	                c=0;
	                hm.clear();
	            }
	        }
	        else if(c==3)
	        break;

	    }
	    if(c==3)
	    System.out.println("Yes");
	    else
	    System.out.println("No");

	}
}
class FastReader {

    BufferedReader br;
    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;
    }
}
close


import java.util.Scanner;

public class EasyNumberChallenge {
	static int[] divisors = new int[1000001];
	static int getNumberOfDivisors(int n) {
		if(divisors[n] != 0)
			return divisors[n];
		int d = 0;
		for(int i = 1; i * i <= n; i++) {
			if(n % i == 0) {
				d++;
				if(i * i != n)
					d++;
			}
		}
		return d;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int i = 1, j = 1, k = 1;
		int n = 1000000;
		int[]divisorsArray = new int[n + 1];

        for(int q = 1 ; q<=n ; q++)
            for(int w = q ; w<=n ; w+=q)
            	divisorsArray[w]++;

		long sum = 0;
		while(i <= a) {
//			sum += divisorsArray[i * j * k];
			sum += getNumberOfDivisors(i * j * k);
			if(j == b && k == c) {
				i++;
				j = 1;
				k = 1;
			}
			else if(k == c) {
				j++;
				k = 1;
			}
			else
				k++;
		}
		System.out.println(sum % 1073741824);
		sc.close();
	}
}


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

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

class TaskA {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int l = in.nextInt();
        String n = in.next();
        String s1 = n.substring(0, l / 2);
        String s2 = n.substring(l / 2);
        String rev = new StringBuffer(s2).reverse().toString();
        if (s1.equals(rev)) {
            int k1 = 0, k2 = 0;
            for (int i = 0; i < s1.length(); ++i) {
                if (s1.charAt(i) == '4' || s1.charAt(i) == '7')
                    k1++;
                if (s2.charAt(i) == '4' || s2.charAt(i) == '7')
                    k2++;
            }
            if (k1+k2 == l)
                out.print("YES");
            else
                out.print("NO");
        } else
            out.print("NO");
	}
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        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 java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class A {
    static final double eps = 1e-8;
    static InputStreamReader in = new InputStreamReader(System.in);
    static BufferedReader bf = new BufferedReader(in);
    static StreamTokenizer st = new StreamTokenizer(bf);
    public static void main(String[] args) throws IOException{
        int x1 = nextInt();
        int y1 = nextInt();
        int x2 = nextInt();
        int y2 = nextInt();
        int x3 = nextInt();
        int y3 = nextInt();
        if (cw(x1,y1,x2,y2,x3,y3) < eps){
            System.out.println("RIGHT");
            return;
        }
        if (cw(x1,y1,x2,y2,x3,y3) > eps){
            System.out.println("LEFT");
            return;
        }
        System.out.println("TOWARDS");
    }
    private static double cw(double x1, double y1, double x2, double y2, double x3, double y3) {
        return x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2);
    }
    private static int nextInt() throws IOException{
        st.nextToken();
        return (int) st.nval;
    }

}
/*
579796456 -149651968
516495557 -133472697
-369717029 93037097
 */


//package kanak;
import java.util.*;
import java.lang.*;
import java.io.*;
public  class Solution {
   static  ArrayList<Character> tr;
    public static void main(String[] args) {
        InputReader fi = new InputReader(System.in);
        int i, j, n, k, index,pos,l;
        String x  = fi.readString();
        String  y = fi.readString();
        char[] a=x.toCharArray();
        char[] b=y.toCharArray();
       /* for (i=0;i<a.length;i++)
            System.out.print(a[+i] +  "  ");*/

        //  System.out.println();
        int al=a.length;
        int bl=b.length;
        tr=new ArrayList<>();
       for (i=0;i<al;i++){
           tr.add(a[i]);
       }
       Collections.sort(tr);
      //  System.out.println(" tr " +tr );

        /*System.out.println(" lower (4)  " +lower('4'));
        System.out.println(" floor (4)  " +floor('4'));
        //tr.remove(Character.valueOf('3'));
        System.out.println(" tr " +tr );*/
        Character w,q;
        StringBuilder sb=new StringBuilder("");
        if (al < bl)
        {
            for (i=al-1;i>=0;i--){
                char r=tr.get(tr.size()-1);
                sb.append(r);
                tr.remove(Character.valueOf(r));
            }
        }
        else if (al > bl){
            int diff=al-bl;
            for(i=al-1;i>=0;i--){
                if (a[i]=='0' && diff > 0){
                    sb.append(a[i]);
                    tr.remove(Character.valueOf(a[i]));
                    diff--;
                }
            }

        }

         if (tr.size()==bl){
            boolean flag=false;
            for (j=0;j<bl;j++){
                w=floor(b[j]);
              //  System.out.println(" w = " +w + " B[J]  " +b[+j]  +  " j = " +j);
                if ( !flag && w==b[j]) {
                    if (j < (bl - 1)) {
                        q = floor(b[j + 1]);
                     //   System.out.println(" q  " + q);
                        if (q != null)
                        {

                            sb.append(w);
                            tr.remove(Character.valueOf(w));
                        }
                        else
                            {
                              //  System.out.println(" q is null");
                            w = lower(b[j]);
                           // System.out.println(" w  "  +w);
                            sb.append(w);
                            tr.remove(Character.valueOf(w));
                            flag=true;
                        }
                    }

                    else{
                        sb.append(w);
                        tr.remove(Character.valueOf(w));
                    }
                }
                else if (tr.size()>=1)
                    {
                            if (!flag) {

                            flag = true;
                        }
                        else {
                            w=tr.get(tr.size()-1);
                        }
                        if (w!=null) {
                            sb.append(w);
                            tr.remove(Character.valueOf(w));
                        }

                }
            }
        }

        System.out.println(sb.toString());

    }

    static  Character lower(char x){

        Character ans=null;
        Iterator<Character> it=tr.iterator();
        while (it.hasNext()){
            Character temp=it.next();
            if (temp<x){
                ans=temp;
            }
        }
        return ans;

    }

    static  Character floor(char x){
        Character ans=null;
        Iterator<Character> it=tr.iterator();
        while (it.hasNext()){
            Character temp=it.next();
            if (temp<=x){
                ans=temp;
            }
        }
            return ans;
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

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

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

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

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

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

    public String readString() {
        int c = snext();
        while (isSpaceChar(c))
            c = snext();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = snext();
        } 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);
    }
}


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

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

    Scanner sc = new Scanner(System.in);

    String str = sc.next();

    BigInteger big1 = new BigInteger(str);
    BigInteger big2 = new BigInteger("5");
    BigInteger big3 = new BigInteger("1");
    BigInteger big4 = new BigInteger("5");
    BigInteger big5 = new BigInteger("1");

    while((big1.compareTo(big3)==1)){

      big2 = big2.multiply(big4);

       big1 = big1.subtract(big5);
    }

    String st = big2.toString();

    System.out.println("25");
  }
}


import java.util.*;
public class MultiplicationTable {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		long x = sc.nextLong();
		int m=0;
		long a[][] = new long[n][n];
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				a[i][j]=(i+1)*(j+1);
				if(a[i][j]==x) m++;
			}
		}
		System.out.println(m);
	}

}


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

public class ProblemA {

	public static void main(String[] args) throws IOException {
		   BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		    String in = input.readLine();
		    String[] init = in.split(" ");

		    int a = Integer.parseInt(init[0]);
		    int b = Integer.parseInt(init[1]);
		    int c = Integer.parseInt(init[2]);

		    int minA =(Math.min(a + b + c, (a + a  + b + b)));
		    int minB = Math.min(a + c + c + a, b + c + c + a);

		    System.out.println(Math.min(minA, minB));

	}

}


import java.util.Scanner;
public class F399 {

	public static final long p = 1_000_000_007;
	public static long[] factorial;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int food = in.nextInt();
		int wine = in.nextInt();
		int H = in.nextInt();
		in.close();

		factorial = new long[200001];
		factorial[0] = 1;
		for(int i = 1; i < factorial.length; i++)
			factorial[i] = (factorial[i-1] * i) % p;

		long result = answer(food, wine, H);
		System.out.println(result);
	}

	public static long answer(int food, int wine, int H) {
		if(food == 0) {
			return wine > H? 1 : 0;
		}
		if(wine == 0) {
			return 1;
		}

		long[] foodArr = new long[1 + Math.max(food, wine)];
		long[] wineArr = new long[1 + Math.max(food, wine)];

		for(int i = 1; i < food+1; i++) {
			foodArr[i] = nCr(food - 1, i - 1);
		}

		for(int i = 1; i < wine+1; i++) {
			wineArr[i] = nCr(wine - 1, i - 1);
		}

//		System.out.println("food:");
//		for(int i = 0; i < Math.min(20, foodArr.length); i++)
//			System.out.print(foodArr[i] + " ");
//		System.out.println();
//		System.out.println("foodArr: " + Arrays.toString(foodArr));
//		System.out.println("wineArr: " + Arrays.toString(wineArr));

		long denom = 0;
		for(int i = 1; i < foodArr.length; i++) {
			denom += 2 * wineArr[i] * foodArr[i];
//			if(2*wineArr[i]*foodArr[i] < 0) {
//				System.out.println("WAHT1");
//			}
			denom %= p;
		}

		for(int i = 1; i < foodArr.length-1; i++) {
			denom += foodArr[i] * wineArr[i+1];
			denom += wineArr[i] * foodArr[i+1];
//			if(foodArr[i] * wineArr[i+1] < 0 || wineArr[i] * foodArr[i+1] < 0)
//				System.out.println("WAHT2");
			denom %= p;
		}

//		System.out.println("denom = " + denom);
		long[] validWine = new long[wineArr.length];
		for(int i = 1; i < validWine.length; i++) {
			validWine[i] = nCr(wine + i - 1 - i*(H+1), i-1);
		}

		long numer = 0;
		for(int i = 1; i < foodArr.length; i++) {
			numer += 2 * validWine[i] * foodArr[i];
			numer %= p;
		}

		for(int i = 1; i < foodArr.length-1; i++) {
			numer += foodArr[i] * validWine[i+1];
			numer += validWine[i] * foodArr[i+1];
			numer %= p;
		}

//		System.out.println("numer = " + numer);
//		System.out.println("denom = " + denom);

		long denomInv = modInverse(denom, p);
		long result = numer * denomInv % p;

		return result;
	}

	public static long nCr(int N, int R) {
		if(N == 0 && R == 0) return 1;
		if(N < 0) return 0;
		if(N < R) return 0;

		long result = factorial[N];
		long denom1 = modInverse(factorial[R], p);
		long denom2 = modInverse(factorial[N-R], p);

		result = (result * denom1) % p;
		result = (result * denom2) % p;

		return result;
	}

	//Extended Euclidean algorithm find x such that ax = 1 (mod m)
	public static long modInverse(long a, long m) {
		long[] a1 = {a, 1, 0};
		long[] b1 = {m, 0, 1};
		while(b1[0] != 0) {
			long[] c1 = new long[3];
			long q = a1[0] / b1[0];
			c1[0] = a1[0] - q * b1[0];
			c1[1] = a1[1] - q * b1[1];
			c1[2] = a1[2] - q * b1[2];
			a1 = b1;
			b1 = c1;
		}

		if(a1[1] < 0) a1[1] += m;
		return a1[1];
	}

}
/*
1 1 1
outputCopy
0
inputCopy
1 2 1
outputCopy
666666672

4138 4245 30
105072868
*/


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

public class CF768F extends PrintWriter {
	CF768F() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF768F o = new CF768F(); o.main(); o.flush();
	}

	static final int MD = 1000000007;
	int d_, x_, y_;
	void gcd_(int a, int b) {
		if (b == 0) {
			d_ = a;
			x_ = 1; y_ = 0;
		} else {
			gcd_(b, a % b);
			int tmp = x_ - a / b * y_; x_ = y_; y_ = tmp;
		}
	}
	int inv(int a, int b) {
		gcd_(a, b);
		return x_;
	}
	int[] ff, gg;
	void init(int n) {
		ff = new int[n];
		gg = new int[n];
		for (int i = 0, f = 1; i < n; i++) {
			gg[i] = inv(ff[i] = f, MD);
			f = (int) ((long) f * (i + 1) % MD);
		}
	}
	int choose(int n, int k) {
		return n < k ? 0 : (int) ((long) ff[n] * gg[k] % MD * gg[n - k] % MD);
	}
	void main() {
		int f = sc.nextInt();
		int w = sc.nextInt();
		int h = sc.nextInt();
		if (f == 0) {
			println(w > h ? 1 : 0);
			return;
		}
		if (w == 0) {
			println(1);
			return;
		}
		int n = Math.max(f, w);
		init(n);
		int[] aa = new int[n + 2];
		for (int i = 1; i <= f; i++)
			aa[i] = choose(f - 1, i - 1);
		int[] bb = new int[n + 2];
		for (int j = 1; j <= w; j++)
			bb[j] = choose(w - 1, j - 1);
		int[] cc = new int[n + 2];
		for (int j = 1; h * j < w; j++)
			cc[j] = choose(w - h * j - 1, j - 1);
		int p = 0, q = 0;
		for (int i = 1; i <= n; i++) {
			p = (int) ((p + aa[i] * (cc[i] * 2L + cc[i - 1] + cc[i + 1])) % MD);
			q = (int) ((q + aa[i] * (bb[i] * 2L + bb[i - 1] + bb[i + 1])) % MD);
		}
		if (p < 0)
			p += MD;
		if (q < 0)
			q += MD;
		int ans = (int) ((long) p * inv(q, MD) % MD);
		if (ans < 0)
			ans += MD;
		println(ans);
	}
}


import java.io.Closeable;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.Collections;
import java.io.InputStream;

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

class TaskA {
	public void solve(int testNumber, QuickScanner in, ExtendedPrintWriter out) {
        List<Integer> list = new ArrayList<Integer>();
        int a = in.nextInt();
        int b = in.nextInt();
        long lcm = NumberUtils.lcm(a, b);
        for (int i = 0; i <= lcm; i += a) {
            list.add(i);
        }
        for (int i = 0; i <= lcm; i += b) {
            list.add(i);
        }
        Collections.sort(list);
        int[] stopTime = ArrayUtils.unique(ArrayUtils.toArray(list));
        long aTime = 0, bTime = 0;
        for (int i = 1; i < stopTime.length; i++) {
            int current = stopTime[i];
            if (current % a == 0 && current % b == 0) {
                if (a > b) {
                    aTime += stopTime[i] - stopTime[i - 1];
                } else {
                    bTime += stopTime[i] - stopTime[i - 1];
                }
            } else if (current % a == 0) {
                aTime += stopTime[i] - stopTime[i - 1];
            } else {
                bTime += stopTime[i] - stopTime[i - 1];
            }
        }
        if (aTime > bTime) {
            out.println("Dasha");
        }
        else if (aTime < bTime) {
            out.println("Masha");
        } else {
            out.println("Equal");
        }
    }
}

class QuickScanner implements Iterator<String>, Closeable {
    BufferedReader reader;
    StringTokenizer tokenizer;
    boolean endOfFile = false;

    public QuickScanner(InputStream inputStream){
        reader = new BufferedReader(new InputStreamReader(inputStream));
        try {
            tokenizer = new StringTokenizer(reader.readLine());
        } catch (Exception e) {
            endOfFile = true;
        }
    }

    public boolean hasNext() {
        if (!tokenizer.hasMoreTokens()) {
            try {
                checkNext();
            } catch (NoSuchElementException ignored) {
            }

        }
        return !endOfFile;
    }

    private void checkNext() {
        if (endOfFile) {
            throw new NoSuchElementException();
        }
        try {
            while (!tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (Exception e) {
            endOfFile = true;
            throw new NoSuchElementException();
        }
    }

    public String next() {
        checkNext();
        return tokenizer.nextToken();
    }

    public void remove() {
        throw new UnsupportedOperationException();
    }

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

    public void close() {
        try {
            reader.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

class ExtendedPrintWriter extends PrintWriter {

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

    public ExtendedPrintWriter(Writer out, boolean autoFlush) {
        super(out, autoFlush);
    }

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

    public ExtendedPrintWriter(OutputStream out, boolean autoFlush) {
        super(out, autoFlush);
    }

    }

class NumberUtils {

    public static int gcd(int a, int b) {
        if (a == 0 && b == 0) {
            throw new IllegalArgumentException();
        }
        return privateGcd(Math.abs(a), Math.abs(b));
    }

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

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

    }

class ArrayUtils {

    public static int[] unique(int[] array) {
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if (i == 0 || array[i - 1] != array[i]) {
                count++;
            }
        }
        int[] result = new int[count];
        count = 0;
        for (int i = 0; i < array.length; i++) {
            if (i == 0 || array[i - 1] != array[i]) {
                result[count++] = array[i];
            }
        }
        return result;
    }

    public static int[] toArray(List<Integer> list) {
        return toArray(list, list.size());
    }

    public static int[] toArray(Iterable<Integer> list, int size) {
        int[] result = new int[size];
        int index = 0;
        for (Integer item : list) {
            result[index++] = item;
        }
        return result;
    }

    }


import java.io.*;
import java.util.*;
public class z3 {
	public static void main(String[] args) throws IOException {
	Scanner	in = new Scanner(System.in);
	int n=in.nextInt();
	int[] a = new int[n];
	for (int i=0;i<n;i++) a[i]=in.nextInt();
	int t=in.nextInt();
	int temp;
	for (int i=0;i<t;i++) {temp=in.nextInt();a[temp-1]=-Math.abs(a[temp-1]);}
	if ((n%2)!=0) System.out.println("NO");
	else
	  {
		int kol=0;int[] st=new int[n];
		  for (int i=n-1;i>=0;i--)
		  {
			  if (kol==0) {kol=1;st[kol]=Math.abs(a[i]);a[i]=-st[kol];} else
			  {
				  if (st[kol]==a[i]) kol-=1; else
				  {kol+=1;st[kol]=Math.abs(a[i]);a[i]=-st[kol];}
			  }
		  }
		  if (kol!=0) System.out.println("NO"); else
		  {
			  System.out.println("YES");
			  for (int i=0;i<n;i++) System.out.print(""+a[i]+" ");
		  }
	}
}
}


mport java.io.*;
import java.util.*;
public class z3 {
	public static void main(String[] args) throws IOException {
	Scanner	in = new Scanner(System.in);
	int n=in.nextInt();
	int[] a = new int[n];
	for (int i=0;i<n;i++) a[i]=in.nextInt();
	int t=in.nextInt();
	int temp;
	for (int i=0;i<t;i++) {temp=in.nextInt();a[temp-1]=-Math.abs(a[temp-1]);}
	if ((n%2)!=0) System.out.println("NO");
	else
	  {
		int kol=0;int[] st=new int[n/2];
		  for (int i=n-1;i>=0;i--)
		  {
			  if (kol==0) {kol=1;st[kol]=Math.abs(a[i]);a[i]=-st[kol];} else
			  {
				  if (st[kol]==a[i]) kol-=1; else
				  {kol+=1;st[kol]=Math.abs(a[i]);a[i]=-st[kol];}
			  }
		  }
		  if (kol!=0) System.out.println("NO"); else
		  {
			  System.out.println("YES");
			  for (int i=0;i<n;i++) System.out.println(a[i]+" ");
		  }
	}
}
}


package collectors;

import java.util.Scanner;
import java.util.stream.IntStream;

public class Solution {

	public static int[] toIntArray(String s) {
		String[] nums = s.split("\\s");
		return IntStream.range(0, nums.length)
			.map(index -> Integer.parseInt(nums[index]))
			.toArray();
	}
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = Integer.parseInt(scanner.nextLine());

		int[] a = Util.toIntArray(scanner.nextLine());

		double sum = a[0];
		int max = a[0];

		for(int i = 1; i < n; i++) {
			if(max < a[i]) {
				max = a[i];
			}

			sum += a[i];
		}
		int k = (int) Math.max(max, Math.ceil(2 * sum / n));

		System.out.println(k);
	}

}


/**
 *   Author: Ridam Nagar
 *   Date: 04 February 2019
 *   Time: 12:59:59
**/
/*
package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{

    public static void main (String[] args) throws java.lang.Exception
    {
       Scanner sc=new Scanner(System.in);
       int n=sc.nextInt();
       int count=1;
       for(int i=1;i<=n/2;i++){

               if((n/i)>0){
                count++;
               }
        }

       System.out.println(count);

 }
}


/*
ID:lpeter83
PROG:CF66A
LANG:JAVA
*/

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CF66A implements Runnable {
	private final boolean ONLINE = false;

	private void solve() throws IOException {
		long [] xx=new long[3];
		xx[0]=nextLong();
		xx[1]=nextLong();
		xx[2]=nextLong();
		long k=nextInt();
		Arrays.sort(xx);
		long a,b,c;
		long t=k;

		if (xx[0]-1<t/3) {a=xx[0]-1;t-=a;}
		else {a=t/3;t-=a;}

		if (xx[1]-1<t/2) {b=xx[1]-1;t-=b;}
		else {b=t/2;t-=b;}

		if (xx[2]-1<t) {c=xx[2]-1;t-=c;}
		else {c=t;}

		writer.println((a+1)*(b+1)*(c+1));
	}

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

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			tokenizer = null;
			if (ONLINE) {
				reader = new BufferedReader(new InputStreamReader(System.in));
				writer = new PrintWriter(System.out);
			} else {
				reader = new BufferedReader(new FileReader("CF66A.in"));
				writer = new PrintWriter(new BufferedWriter(new FileWriter(
						"CF66A.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());
	}

	BigInteger nextBigInt() throws IOException {
		return new BigInteger(nextToken());
	}

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

	boolean hasNext() throws IOException {
		String s = reader.readLine();
		if (s == null)
			return false;
		else {
			tokenizer = new StringTokenizer(s);
			return true;
		}
	}

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

	public void prt(Object... os) {
		System.out.println(Arrays.deepToString(os));
	}
}


import java.util.*;

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

    TaskD() {
    }

    int b, d, lenA,lenC;
    String a, c;
    int[][] next, delta;

    public void solve() {
        Scanner in = new Scanner(System.in);
        b = in.nextInt();
        d = in.nextInt();
        a = in.next();
        c = in.next();

        lenA = a.length();
        lenC = c.length();

        next = new int[lenA][lenC];
        delta = new int[lenA][lenC];
        for (int i = 0; i < lenA; ++i) {
            Arrays.fill(next[i], -1);
            Arrays.fill(delta[i], -1);

            for (int j = 0; j < lenC; ++j) {
                if (a.charAt(i) != c.charAt(j)) continue;

                int l = 1, dd = 0, lastL = 0;
                while (l < lenA) {
                    int ii = (i + l) % lenA;
                    int jj = (j + dd + 1) % lenC;
                    if (a.charAt(ii) == c.charAt(jj)) {
                        ++dd;
                        lastL = l;
                    }
                    ++l;
                }

                if (lastL > 0) {
                    next[i][j] = lastL;
                    delta[i][j] = dd;
                }
            }
        }

        int cnt = 0, i = 0, j = 0;
        while (i < lenA && next[i][j] == -1) ++i;
        if (next[i][j] == -1) {
            System.out.println(0);
            return;
        }

        while (next[i % lenA][j] != -1 && i + next[i % lenA][j] < lenA * b) {
            assert a.charAt(i % lenA) == c.charAt(j);
            int ii = i % lenA;
            int jj = j;
            cnt += delta[ii][jj];
            i += next[ii][jj];
            j = (j + delta[ii][jj]) % lenC;
        }

        if (next[i % lenA][j] != -1) {
            while (i < lenA * b) {
                if (a.charAt(i % lenA) == c.charAt(j)) {
                    ++cnt;
                    j = (j + 1) % lenC;
                }
                ++i;
            }
        }

        System.out.println(cnt / (d * lenC));
    }
}


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

public class Solution
{
	public static void main (String[] args)
	{
		Scanner s=new Scanner(System.in);
		int  n=s.nextInt();
		int count=0;
		for(int i=1;i<=n;i++)
		{
		      for(int j=1;j<=n-i;j++)
		      {
		            if(i+i*j==n)
		                  count++;
		      }
		}
		System.out.print(count);
	}
}


/*
 * 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 codeforces;

//import java.util.Scanner;

/**
 *
 * @author HOME
 */
public class Main {
    public static void main(String[] args){
        Scanner sc  = new Scanner(System.in);
        String g = sc.next();
        int t = Integer.parseInt(g, 2);
        if(t>= 64)
            System.out.println("yes");
        else
            System.out.println("no");

        }
    }