import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.TreeMap;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * 6
 * 1 0
 * 0 0
 * 0 0
 * 1 1
 * 0 1
 * 1 1
 *
 * @author pttrung
 */
public class B {

    public static boolean circle;
    public static int a, b;
    public static int[] x = {0, 1, 0, -1};
    public static int[] y = {1, 0, -1, 0};

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out;

        Scanner in = new Scanner();
        //out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        int m = in.nextInt() - 1;
        int k = in.nextInt() - 1;
        String line = in.nextLine();

        String move = in.nextLine();
        int[] pos = new int[move.length() + 1];
        pos[0] = k;
        int add = 1;
        if (line.equals("to head")) {
            add = -1;
        }
        for (int i = 1; i < pos.length; i++) {
            pos[i] = pos[i - 1] + add;
            if (pos[i] == 0) {
                add = 1;
            }
            if (pos[i] == n - 1) {
                add = -1;
            }

        }
        int val = cal(0, m, n, pos, move);
        if (val == move.length()) {
            out.println("Stowaway");
        } else {
            out.println("Controller " + val);
        }
        out.close();
    }

    public static int cal(int min, int index, int n, int[] pos, String move) {
        //System.out.println(min + " " + index + " " + pos[min] + " " + move);
        if (min == move.length()) {
            return min;
        }
        if (index == pos[min]) {
            return min;
        }
        int result = min;
        if (move.charAt(min) == '0') {
            //System.out.println("Min " + min);
            if (index + 1 < n) {
                if (pos[min + 1] != index || pos[min] != index + 1) {
                    int val = cal(min + 1, index + 1, n, pos, move);
                    result = Math.max(result, val);
                } else {
                    result = Math.max(result, min + 1);
                }

            }
            if (index - 1 >= 0) {
                //System.out.println("PREV " + index);
                if (pos[min + 1] != index || pos[min] != index - 1) {
                    int val = cal(min + 1, index - 1, n, pos, move);
                    result = Math.max(result, val);
                } else {
                    result = Math.max(result, min + 1);
                }
            }
            int val = cal(min + 1, index, n, pos, move);
            result = Math.max(result, val);
            return result;
        } else {
            for (int i = 0; i < n; i++) {
                int val = cal(min + 1, i, n, pos, move);
                result = Math.max(result, val);
            }
            return result;
        }
    }

    public static Line getLine(Point a, Point b) {
        int c = (a.x - b.x);
        int d = (a.y - b.y);
        if (c == 0) {
            return new Line(1, 0, -a.x);
        } else if (d == 0) {
            return new Line(0, 1, -a.y);
        } else {
            double rate = (double) (-d) / c;

            double other = ((double) rate * a.x) + a.y;
            //System.out.println(a + "|" + b + ": " + rate + " " + other);
            return new Line(rate, 1, -other);
        }
    }

    public static class Line {

        double a, b, c;

        public Line(double a, double b, double c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 47 * hash + (int) (Double.doubleToLongBits(this.a) ^ (Double.doubleToLongBits(this.a) >>> 32));
            hash = 47 * hash + (int) (Double.doubleToLongBits(this.b) ^ (Double.doubleToLongBits(this.b) >>> 32));
            hash = 47 * hash + (int) (Double.doubleToLongBits(this.c) ^ (Double.doubleToLongBits(this.c) >>> 32));
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Line other = (Line) obj;
            if (Double.doubleToLongBits(this.a) != Double.doubleToLongBits(other.a)) {
                return false;
            }
            if (Double.doubleToLongBits(this.b) != Double.doubleToLongBits(other.b)) {
                return false;
            }
            if (Double.doubleToLongBits(this.c) != Double.doubleToLongBits(other.c)) {
                return false;
            }
            return true;
        }

        @Override
        public String toString() {
            return a + " " + b + " " + c;
        }
    }

    static class FT {

        int[] data;

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

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

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

    public static class Point {

        int x, y;

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

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

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

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

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

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

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

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

        public String next() {

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

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

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

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

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

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


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

public class cf401d {

	static int[] digits;
	static long N;
	static int mod, len;
	static long[][] memo;

	public static long dp(int avail, int cmod) {
		if (avail == 0) {
			return (cmod == 0) ? 1 : 0;
		}
		long tot = 0;

		// test placing each new digit
		for (int i = 0; i < len; i++) {
			int drep = 1 << i;
			// can we use this?
			if ((avail & drep) == drep) {
			int a = avail ^ drep;
			int b = (cmod * 10 + digits[i]) % mod);
			if( memo[a][b] == -1 )
				memo[a][b] = dp(avail ^ drep, (cmod * 10 + digits[i]) % mod);
			tot += memo[a][b];
			}
		}

		return tot;
	}

	public static long fact(int i) {
		long ret = 1;
		for (int j = 2; j <= i; j++)
			ret *= j;
		return ret;
	}

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		N = s.nextLong();
		mod = s.nextInt();
		String Nrep = "" + N;
		len = Nrep.length();
		digits = new int[len];
		for (int i = 0; i < len; i++) {
			digits[i] = Nrep.charAt(i) - '0';
		}

		int gg = (1 << len) - 1;
		memo = new long[gg][mod];
		for (long[] l : memo)
			Arrays.fill(l, -1);

		long tot = 0;
		for (int i = 0; i < len; i++) {
			if (digits[i] != 0) {
				tot += dp(gg ^ (1 << i), digits[i] % mod);
			}
		}

		Arrays.sort(digits);
		int count = 1;
		for (int i = 1; i < len; i++) {
			if (digits[i] == digits[i - 1])
				count++;
			else {
				tot /= fact(count);
				count = 1;
			}
		}

		tot /= fact(count);

		System.out.println(tot);
		s.close();

	}

}


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

public class Main {

	static int[][] h;
	static int INF = (int) 2e9;

	static void getInput(Scanner sc, int n, int m) throws IOException {
		int[] g = new int[n * m + n];
		g[0] = sc.nextInt();
		h = new int[n][m];
		int x = sc.nextInt(), y = sc.nextInt(), z = sc.nextInt();
		for (int i = 1; i < g.length; i++) {
			g[i] = (int) ((g[i - 1] * 1L * x + y) % z);
		}
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++) {
				h[i - 1][j - 1] = g[(i - 1) * m + j - 1];
			}
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), m = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		getInput(sc, n, m);
		long ans = 0;
		SegmentTree2D tree = new SegmentTree2D(h);
		for (int i = 0; i + a <= n; i++)
			for (int j = 0; j + b <= m; j++)
				ans += tree.query(i, i + a - 1, j, j + b - 1);
		out.println(ans);
		out.close();

	}

	static class SegmentTree2D {
		int n, m, min[][], a[][];

		SegmentTree2D(int[][] a) {
			this.a = a;
			n = a.length;
			m = a[0].length;
			min = new int[4 * n][4 * m];
			build_x(1, 0, n - 1);
		}

		void build_y(int vx, int lx, int rx, int vy, int ly, int ry) {
			if (ly == ry) {
				if (lx == rx)
					min[vx][vy] = a[lx][ly];
				else
					min[vx][vy] = Math.min(min[vx * 2][vy], min[vx * 2 + 1][vy]);
			} else {
				int my = (ly + ry) / 2;
				build_y(vx, lx, rx, vy * 2, ly, my);
				build_y(vx, lx, rx, vy * 2 + 1, my + 1, ry);
				min[vx][vy] = Math.min(min[vx][vy * 2], min[vx][vy * 2 + 1]);
			}
		}

		void build_x(int vx, int lx, int rx) {
			if (lx != rx) {
				int mx = (lx + rx) / 2;
				build_x(vx * 2, lx, mx);
				build_x(vx * 2 + 1, mx + 1, rx);
			}
			build_y(vx, lx, rx, 1, 0, m - 1);
		}

		int query(int lN, int rN, int lM, int rM) {
			return query(1, 0, n - 1, lN, rN, lM, rM);
		}

		int query(int node, int tl, int tr, int lN, int rN, int lM, int rM) {
			if (rN < tl || tr < lN)
				return INF;
			if (tl >= lN && tr <= rN) {
				return query(node, 1, 0, m - 1, lM, rM);
			}
			int mid = tl + tr >> 1, left = node << 1, right = left | 1;
			return Math.min(query(left, tl, mid, lN, rN, lM, rM), query(right, mid + 1, tr, lN, rN, lM, rM));

		}

		int query(int nodeN, int node, int tl, int tr, int l, int r) {
			if (r < tl || tr < l)
				return INF;
			if (tl >= l && tr <= r)
				return min[nodeN][node];
			int mid = tl + tr >> 1, left = node << 1, right = left | 1;
			return Math.min(query(nodeN, left, tl, mid, l, r), query(nodeN, right, mid + 1, tr, l, r));
		}
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

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

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

	}

}


import java.lang.Math.*;
import java.util.Scanner;
public class Painting
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();

		int x[] = new int[4] ;

		x[0] = a + b ;
		x[1] = a + c ;
		x[2] = b + d ;
		x[3] = c + d ;

		int max = x[0] ;
		int min = x[3] ;
		for ( int i = 1 ; i < 4 ; i++ )
		{
			if ( x[i] > max )
			{
				max = x[i] ;
			}
		}

		for ( int j = 2 ; j >= 0 ; j-- )
		{
			if ( x[j] < min )
			{
				min = x[j] ;
			}
		}

		System.out.println( n * ( n - ( max - min ) ) );
	}
}


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

public class CF_146B_LuckyMask {
	static int luckyDivision(int num){
		int resultt = 0 ;
		int mult = 1;
		while(num>0){
		if(num%10==7||num%10==4){result+=num%10*mult;mult*=10; }
		num=num/10;
		}
	return resultt ;
	}
public static void main(String[]args)throws Exception{
Scanner sc = new Scanner(System.in);
int a  = sc.nextInt();
int b = sc.nextInt();
if(b>a){
	System.out.println(b);
	return;
}

int result = a+1;
while( luckyDivision(result)!=b){
	result++;
}
System.out.println(result);
}
}


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

public class B {

  private static final String REGEX = " ";
  private static final Boolean DEBUG = false;
  private static final String FILE_NAME = "input.txt";

  public static void main(String[] args) throws IOException {
    if (DEBUG) {
      generate();
    }
    Solver solver = new Solver();
    solver.readData();
    solver.solveAndPrint();
  }

  private static void generate() throws IOException {
//    FileWriter writer = new FileWriter("input.txt");
//    writer.close();
  }

  private static class Solver {

    String[] field = new String[10];
    int curI, curJ;

    void readData() throws IOException {
      InputStream in = DEBUG ? new FileInputStream(FILE_NAME) : System.in;
      Scanner scanner = new Scanner(in);
      for (int i = 0; i < 10; i++) {
        field[i] = scanner.nextLine();
      }
      scanner.close();
    }

    void solveAndPrint() {
      char c;
      for (int i = 0; i < 10; i++) {
        String row = field[i];
        for (int j = 0; j < 10; j++) {
          c = row.charAt(j);
          if (c == '.') {
            curI = i;
            curJ = j;
            if (check(i, j)) {
              System.out.println("YES");
              return;
            }
          }
        }
      }
      System.out.println("NO");
    }

    private boolean check(int i, int j) {
      if (checkHor(i, j - 4) || checkHor(i, j - 3) || checkHor(i, j - 2) || checkHor(i, j - 1) || checkHor(i, j)) {
        return true;
      }
      if (checkVer(i - 4, j) || checkVer(i - 3, j) || checkVer(i - 2, j) || checkVer(i - 1, j) || checkVer(i, j)) {
        return true;
      }
      if (checkDia(i - 4, j - 4) || checkDia(i - 3, j - 3) || checkDia(i - 2, j - 2) || checkDia(i - 1, j - 1) || checkDia(i, j)) {
        return true;
      }
      return false;
    }

    private boolean checkHor(int i, int j) {
      int j1 = j;
      int i1 = i;
      for (int k = 0; k < 5; k++) {
        j1 = j + k;
        if (i1 < 0 || i1 >= 10 || j1 < 0 || j1 >= 10) {
          return false;
        }
        if (i1 == curI && j1 == curJ) {
          continue;
        }
        if (field[i1].charAt(j1) != 'X') {
          return false;
        }
      }
      return true;
    }

    private boolean checkVer(int i, int j) {
      int j1 = j;
      int i1 = i;
      for (int k = 0; k < 5; k++) {
        i1 = i + k;
        if (i1 < 0 || i1 >= 10 || j1 < 0 || j1 >= 10) {
          return false;
        }
        if (i1 == curI && j1 == curJ) {
          continue;
        }
        if (field[i1].charAt(j1) != 'X') {
          return false;
        }
      }
      return true;

    }

    private boolean checkDia(int i, int j) {
      int j1 = j;
      int i1 = i;
      for (int k = 0; k < 5; k++) {
        i1 = i + k;
        j1 = j + k;
        if (i1 < 0 || i1 >= 10 || j1 < 0 || j1 >= 10) {
          return false;
        }
        if (i1 == curI && j1 == curJ) {
          continue;
        }
        if (field[i1].charAt(j1) != 'X') {
          return false;
        }
      }
      return true;
    }

    @SuppressWarnings("SameParameterValue")
    int[] splitInteger(String string, int n) {
      final String[] split = string.split(REGEX, n);
      int[] result = new int[split.length];
      for (int i = 0; i < n; ++i) {
        result[i] = Integer.parseInt(split[i]);
      }
      return result;
    }

    public int[] splitInteger(String string) {
      return splitInteger(string, 0);
    }

    @SuppressWarnings("SameParameterValue")
    long[] splitLong(String string, int n) {
      final String[] split = string.split(REGEX, n);
      long[] result = new long[split.length];
      for (int i = 0; i < n; ++i) {
        result[i] = Long.parseLong(split[i]);
      }
      return result;
    }

    public long[] splitLong(String string) {
      return splitLong(string, 0);
    }

    @SuppressWarnings("SameParameterValue")
    double[] splitDouble(String string, int n) {
      final String[] split = string.split(REGEX, n);
      double[] result = new double[split.length];
      for (int i = 0; i < n; ++i) {
        result[i] = Double.parseDouble(split[i]);
      }
      return result;
    }

    public double[] splitDouble(String string) {
      return splitDouble(string, 0);
    }

    @SuppressWarnings("SameParameterValue")
    String[] splitString(String string, int n) {
      return string.split(REGEX, n);
    }

    public String[] splitString(String string) {
      return splitString(string, 0);
    }

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

    public long max(long a, long b) {
      return Math.max(a, b);
    }

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

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

    public double max(double a, double b) {
      return Math.max(a, b);
    }

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

    private final static int MOD = 1000000009;

    int multMod(int a, int b) {
      return ((a % MOD) * (b % MOD)) % MOD;
    }

    int sumMod(int a, int b) {
      return ((a % MOD) + (b % MOD)) % MOD;
    }

    long multMod(long a, long b) {
      return ((a % MOD) * (b % MOD)) % MOD;
    }

    long sumMod(long a, long b) {
      return ((a % MOD) + (b % MOD)) % MOD;
    }
  }

}


import java.util.*;
public class ctask{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int[] px = new int[4];
		int[] py = new int[4];

		int[] ix = new int[4];
		int[] iy = new int[4];

		for(int i = 0;i < 4;i++){
			px[i] = s.nextInt();
			py[i] = s.nextInt();
		}

		for(int i = 0;i < 4;i++){
			ix[i] = s.nextInt();
			iy[i] = s.nextInt();
		}

		Arrays.sort(px);
		Arrays.sort(py);
		int minx = px[0] , maxx = px[3];
		int miny = py[0] , maxy = py[3];
		int[] arrx = new int[106];
		int[] arry = new int[106];

		for(int i = minx ; i <= maxx ;i++){
			arrx[i] = 1;
		}

		for(int i = miny ; i <= maxy ;i++){
			arry[i] = 1;
		}

		Arrays.sort(ix);
		Arrays.sort(iy);

		int inxmin = ix[0] , inxmax = ix[3];
		int inymin = iy[0] , inymax = iy[3];

		int flag = 0;
		for(int i = inxmin ;i <= inxmax ;i++){
			if(arrx[i] == 1){
				flag = 1;
				break;
			}
		}

		for(int i = inymin ;i <= inymax ;i++){
			if(arry[i] == 1){
				flag++;
				break;
			}
		}
		if(flag == 2)
			System.out.println("YES");
		else
			System.out.println("NO");

	}
}


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

public class C{

	static int k1,k2,k3;
	static void MainMethod()throws Exception{
		k1=reader.nextInt();
		k2=reader.nextInt();
		k3=reader.nextInt();
		if (test()==true)printer.print("YES");
		else printer.print("NO");
	}
	static boolean test() {
		if (test2(k1,k2,k3)) return true;
		if (test2/(k1,k3,k2)) return true;
		if (test2(k2,k1,k3)) return true;
		if (test2(k2,k3,k1)) return true;
		if (test2(k3,k1,k2)) return true;
		if (test2(k3,k2,k1)) return true;

		return false;
	}
	private static boolean test2(int a, int b, int c) {
		if (a==1) return true;
		if (a==2&&b==2) return true;
		if (c==3&&b==3&&a==3) return true;

		return false;
	}
	public static void main(String[] args)throws Exception{
		MainMethod();
		printer.close();
	}
	static void halt(){
		printer.close();
		System.exit(0);
	}
	static PrintWriter printer=new PrintWriter(new OutputStreamWriter(System.out));
	static class reader{
		static BufferedReader bReader=new BufferedReader(new InputStreamReader(System.in));
		static StringTokenizer token=new StringTokenizer("");
		static String readNextLine() throws Exception{
			return bReader.readLine();
		}
		static String next() throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return token.nextToken();
		}
		static int nextInt()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Integer.parseInt(token.nextToken());
		}
		static long nextLong()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Long.parseLong(token.nextToken());
		}
		static double nextDouble()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Double.parseDouble(token.nextToken());
		}
	}
	static class MyMathCompute{
		static long [][] MatrixMultiplyMatrix(long [][] A, long [][] B, long mod) throws Exception{
			int n=A.length, m=B[0].length;
			int p=A[0].length;
			int i,j,k;
			if (B.length!=p) throw new Exception("invalid matrix input");
			long [][] res=new long [n][m];
			for (i=0;i<n;i++) for (j=0;j<m;j++){
				if (A[i].length!=p) throw new Exception("invalid matrix input");
				res[i][j]=0;
				for (k=0;k<p;k++)
					res[i][j]=(res[i][j]+((A[i][k]*B[k][j])% mod))% mod;
			}
			return res;
		}
		static double [][] MatrixMultiplyMatrix(double [][] A, double [][] B ) throws Exception{
			int n=A.length, m=B[0].length;
			int p=A[0].length;
			int i,j,k;
			if (B.length!=p) throw new Exception("invalid matrix input");
			double [][] res=new double [n][m];
			for (i=0;i<n;i++) for (j=0;j<m;j++){
				if (A[i].length!=p) throw new Exception("invalid matrix input");
				res[i][j]=0;
				for (k=0;k<p;k++)
					res[i][j]=res[i][j]+(A[i][k]*B[k][j]);
			}
			return res;
		}
		static long [][] MatrixPow(long [][] A,long n, long mod) throws Exception{
			if (n==1) return A;
			long [][] res=MatrixPow(A, n/2, mod);
			res=MatrixMultiplyMatrix(res, res, mod);
			if ((n % 2) == 1) res=MatrixMultiplyMatrix(A,res, mod);
			return res;
		}
		static double [][] MatrixPow(double [][] A,long n) throws Exception{
			if (n==1) return A;
			double[][] res=MatrixPow(A, n/2);
			res=MatrixMultiplyMatrix(res, res);
			if ((n % 2) == 1) res=MatrixMultiplyMatrix(A,res);
			return res;
		}
		static long pow(long a,long n,long mod){
			a= a % mod;
			if (n==0) return 1;
			long k=pow(a,n/2,mod);
			if ((n % 2)==0) return ((k*k)%mod);
			else return (((k*k) % mod)*a) % mod;
		}
		static double pow(double a,long n){
			if (n==0) return 1;
			double k=pow(a,n/2);
			if ((n % 2)==0) return (k*k);
			else return (((k*k) )*a) ;
		}
	}
}


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

public class cforces{
    static Templates.FastScanner sc = new Templates.FastScanner();
    static PrintWriter fop = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {

        D();

    }

    static void D() throws IOException{
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n = Integer.parseInt(bu.readLine());
        int i,j;
        long f[] = new long[n+1], dp[] = new long[n+1];
        for(i=2;i<=n;i++)
        if(f[i]==0)
        for(j=i;j<=n;j+=i){
            if(f[j]==0) f[j]=1;
            int x=j,c=1;
            while(x%i==0){
                c++;
                x/=i;
            }
            f[j]*=c;

        }
        dp[1]=1;
        long sum=1,M = 998244353;
        for(i=2;i<=n;i++){
            dp[i] = (sum+f[i])%M;
            sum = (sum+dp[i])%M;
        }
        System.out.println(dp[n]);
    }

}


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

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

class TaskB {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int a, b, n;
        a = in.nextInt();
        b = in.nextInt();
        n = in.nextInt();

        if (n >= b) {
            out.printf("%d/%d", a, b);
        } else {
            int bestx = 0, besty = 0;
            double bestdiff = 1000000;
            for (int y = n; y > 0; y--) {
                int x = a*y/b;
                if (abs((double)(a * y - b * x)) < bestdiff) {
                    bestdiff = abs((double)(a * y - b * x));
                    bestx = x; besty = y;
                }
            }

            out.printf("%d/%d", bestx, besty);
        }
	}
}


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

public class RCCDiv2A {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int cb = in.nextInt();
        int ca = in.nextInt();
        int na = in.nextInt();
        int nb = in.nextInt();
        int k = in.nextInt();

        nb -= k / na;
        k %= na;

        if (nb <= 0) {
            out.println(0);
            return;
        }
        System.out.println(Math.min(nb * cb, Math.min((na - k) * ca + (nb - 1) * cb, (na - k) * ca + (nb - 1) * na * ca)));
	}

}


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)a[i] = in.nextInt();
        Arrays.sort(a);
        int m = in.nextInt();
        int ff = Math.min(n, m);
        int ans = 0;
        for (int i = 0; i < ff; i++)ans += a[i];
        if (m > ff)ans = ans - d * (m - ff);
        system.out.println(ans);
    }
}


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

public class Main{

    public static void main (String [] args){
        Scanner scan = new Scanner(System.in);
        long k = scan.nextLong();
        solve(k);
    }

    public static void solve (long k){
        BigInteger mod = BigInteger.valueOf(1000000007);
        long nodes = (long)Math.pow(2, k)-2;
        BigInteger nodess = BigInteger.valueOf(nodes);
        BigInteger four = new BigInteger("4");
        BigInteger result = four.modPow(nodess,mod);
        result = result.multiply(BigInteger.valueOf(6));
        result = result.mod(mod);
        System.out.println(result;
    }
}


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

public class LuckyTickets {

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

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

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

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

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

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

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

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

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

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


public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        String[] a = s.split("0");
        int c=0;
        for (int i = 0; i < s.length(); i++) {

            if (s.charAt(i)=='1') {
                c++;
            }else{
                System.out.print(c);
                c=0;
            }

        }System.out.print(c);

    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Solution {
    //<editor-fold desc="input parse" defaultstate="collapsed">

    private static StringTokenizer st;
    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

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

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

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

    private static short nextShort() {
        return Short.parseShort(st.nextToken());
    }

    private static byte nextByte() {
        return Byte.parseByte(st.nextToken());
    }

    private static void initTokenizer() throws Exception {
        st = new StringTokenizer(reader.readLine());
    }

    //</editor-fold>

    private static class TeamComparator implements Comparator<Team> {
        @Override
        public int compare (Team a, Team b) {
            int c = a.points - b.points;
            if (c != 0) return c;

            c = a.goalsDone - a.goalsLost - (b.goalsDone - b.goalsLost);
            if (c != 0) return c;

            c = a.goalsDone - b.goalsDone;
            if (c != 0) return c;

            return b.country.compareTo(a.country);
        }
    }

    private static class Team {
        private int points;
        private int goalsDone;
        private int goalsLost;
        private String country;
        private int games;

        public Team (String country) {
            this.country = country;
            points = 0;
            goalsDone = 0;
            goalsLost = 0;
            games = 0;
        }
    }

    private static class CountComparator implements Comparator<Count> {
        @Override
        public int compare (Count a, Count b) {
            int c = a.win - a.los - (b.win - b.los);
            if (c != 0) return c;

            return a.los - b.los;
        }

    }

    private static class Count {
        private int win;
        private int los;

        public Count (int win, int los) {
            this.win = win;
            this.los = los;
        }

    }

    private final static TeamComparator comparator = new TeamComparator() {

        @Override
        public int compare (Team a, Team b) {
            return -super.compare(a, b);
        }
    };

    private final static CountComparator countcomparator = new CountComparator();

    private static HashMap<String, Team> teamsMap;

    public static void main(String[] args) throws Exception {
        teamsMap = new HashMap<>();

        for (int i = 0; i < 5; i++) {
            st = new StringTokenizer(reader.readLine(), ": ");

            String team1 = st.nextToken();
            String team2 = st.nextToken();

            int g1 = nextInt();
            int g2 = nextInt();

            Team t1 = teamsMap.get(team1);
            if (t1 == null) {
                t1 = new Team(team1);
                teamsMap.put(team1, t1);
            }

            Team t2 = teamsMap.get(team2);
            if (t2 == null) {
                t2 = new Team(team2);
                teamsMap.put(team2, t2);
            }

            t1.goalsDone += g1;
            t1.goalsLost += g2;

            t2.goalsDone += g2;
            t2.goalsLost += g1;

            if (g1 == g2) {
                t1.points++;
                t2.points++;
            }
            else if (g1 > g2) {
                t1.points += 3;
            }
            else {
                t2.points += 3;
            }

            t1.games++;
            t2.games++;
        }

        Team berland = teamsMap.get("BERLAND");

        Team other = null;

        for (Entry<String, Team> e : teamsMap.entrySet()) {
            if (!e.getKey().equals("BERLAND") && e.getValue().games == 2) {
                other = e.getValue();
                break;
            }
        }

        berland.points += 3;

        ArrayList<Team> list = new ArrayList<>(6);

        for (Team t : teamsMap.values()) {
            list.add(t);
        }

        int bgd = berland.goalsDone;
        int bgl = berland.goalsLost;

        int ogd = other.goalsDone;
        int ogl = other.goalsLost;

        ArrayList<Count> count = new ArrayList<>(1000);

        for (int i = 1; i <= 1000; i++) {
            berland.goalsDone = bgd + i;
            other.goalsLost = ogl + i;

            for (int j = i - 1; j >= 0; j--) {
                berland.goalsLost = bgl + j;
                other.goalsDone = ogd + j;

                Collections.sort(list, comparator);

                if (list.get(0).country.equals("BERLAND") || list.get(1).country.equals("BERLAND")) {
                    count.add(new Count(i, j));
                }
            }
        }

        Collections.sort(count, countcomparator);

        System.out.print(count.size() == 0 ? "IMPOSSIBLE" : (count.get(0).win + " " + count.get(0).los));
    }
}


import java.util.Scanner;

public class TheGreatJulyaCalendar_331C1 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        num = (int)n/10;
        int ans = n < 10 ? 0 : num * 2 + 1;
        System.out.println(ans);
    }
}


package trunghieu11;

import myStream.InputReader;
import myStream.OutputWriter;

public class TaskC {
    private static final long MOD = 1000000007;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int rowCount = in.readInt();
        int columCount = in.readInt();
        int stepCount = in.readInt();
        if (rowCount == 1 || columCount == 1){
            out.printLine(0);
            return;
        }

        long[][] count = new long[stepCount + 1][Math.max(rowCount, columCount) + 1];
        for (int i = 0; i < count[1].length; i++){
            count[1][i] = i * (i + 1) / 2;
        }
        for (int i = 2; i <= stepCount; i++){
            long sum = 0;
            long result = 0;
            for (int j = 2; j < count[i].length; j++) {
                sum += count[i - 1][j - 2];
                result += sum;
                result %= MOD;
                count[i][j] = result;
            }
        }
        long answer = count[stepCount][rowCount - 2] * count[stepCount][columCount - 2] % MOD;
        out.printLine(answer);
    }
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		InputStream input;
		OutputStream output;
		try {
			input = new FileInputStream("input.txt");
			output = new FileOutputStream("output.txt");
		} catch (FileNotFoundException e) {
			input = System.in;
			output = System.out;
		}
		Kattio io = new Kattio(input, output);
		(new Solve(io)).main();
		io.close();

		if (input instanceof FileInputStream)
			try {
				input.close();
			} catch (IOException e) {
			}
		if (output instanceof FileOutputStream)
			try {
				output.close();
			} catch (IOException e) {
			}
	}

}

class Solve {
	static final long mod = (long) 1e9+7;
	Kattio io;
	int n;
	int[] a;
	long[][][] dp;
	int maxx;

	long[] fac;

	Solve(Kattio io) {
		this.io = io;
	}

	long pow(long x,long y)
	{
		if (y==0) return 1;
		else
		{
			long p=pow(x,y/2);
			p=p*p%mod;
			if (y%2==1) return p*x%mod;
			else return p;
		}
	}

	long nCk(int n,int k)
	{
		return fac[n]*pow(fac[k]*fac[n-k]%mod,mod-2)%mod;
	}

	long caldp(int x,int y,int z)
	{
		if (dp[x][y][z]!=-1) return dp[x][y][z];

		if (x==n && z==0 && y==0)
			dp[x][y][z]=1;
		else
		if (x==n)
			dp[x][y][z]=0;
		else
		{
			dp[x][y][z]=caldp(x+1,y,z);
			if (z>=a[x+1] && y>=1) dp[x][y][z]=(dp[x][y][z]+caldp(x+1,y-1,z-a[x+1]))%mod;
		}

		return dp[x][y][z];
	}

	void main()
	{
		n=io.getInt();
		a = new int[n+1];

		maxx = 0;
		TreeMap<Integer,Integer> S = new TreeMap<Integer,Integer>();

		for (int i=1; i<=n; i++)
		{
			a[i]=io.getInt();
			maxx+=a[i];
			if (S.containsKey(a[i]))
				S.put(a[i], S.get(a[i])+1);
			else
				S.put(a[i], 1);
		}

		if (S.size()==2)
		{
			io.print(n);
			return;
		}

		dp = new long[n+1][n+1][maxx+1];
		for (int i=0; i<=n; i++)
			for (int j=0; j<=n; j++)
				Arrays.fill(dp[i][j],-1);

		fac = new long[n+1];
		fac[0]= 1;
		for (int i=1; i<=n; i++)
			fac[i] = fac[i-1]*i%mod;

		int res=0;
		for (Map.Entry<Integer, Integer> entry: S.entrySet())
		{
			Integer value = entry.getValue();
			Integer key = entry.getKey();
			for (int i=res+1; i<=value; i++)
				if (caldp(0,i,key*i)==nCk(value,i))
					res=Math.max(res, i);
		}

		io.println(res);

	}
}

/** Simple yet moderately fast I/O routines.
*
* Example usage:
*
* Kattio io = new Kattio(System.in, System.out);
*
* while (io.hasMoreTokens()) {
*    int n = io.getInt();
*    double d = io.getDouble();
*    double ans = d*n;
*
*    io.println("Answer: " + ans);
* }
*
* io.close();
*
*
* Some notes:
*
* - When done, you should always do io.close() or io.flush() on the
*   Kattio-instance, otherwise, you may lose output.
*
* - The getInt(), getDouble(), and getLong() methods will throw an
*   exception if there is no more data in the input, so it is generally
*   a good idea to use hasMoreTokens() to check for end-of-file.
*
* @author: Kattis
*/
class Kattio extends PrintWriter {
	public Kattio(InputStream i) {
		super(new BufferedOutputStream(System.out));
		r = new BufferedReader(new InputStreamReader(i));
	}

	public Kattio(InputStream i, OutputStream o) {
		super(new BufferedOutputStream(o));
		r = new BufferedReader(new InputStreamReader(i));
	}

	public boolean hasMoreTokens() {
		return peekToken() != null;
	}

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

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

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

	public String getWord() {
		return nextToken();
	}

	private BufferedReader r;
	private String line;
	private StringTokenizer st;
	private String token;

	private String peekToken() {
		if (token == null)
			try {
				while (st == null || !st.hasMoreTokens()) {
					line = r.readLine();
					if (line == null)
						return null;
					st = new StringTokenizer(line);
				}
				token = st.nextToken();
			} catch (IOException e) {
			}
		return token;
	}

	private String nextToken() {
		String ans = peekToken();
		token = null;
		return ans;
	}
}


public class CodeForces1 {

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

        int count = 0;

        while (n > 9) {
            n++;
            while (n%10 == 0) {
                n/=10;
            }
            count++;
        }
        count+=9;

        System.out.println("result: " + count);
    }
}


import java.util.*;

public class x{

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

               int n=sc.nextInt();

               while(n-->0){
                       int t=sc.nextInt();
                       int f=1,s=2,lt=3;

                       if(t==lt){
                               System.out.println("NO");
                               break;
                       }
                       else if(t==f){
                               swap(s,lt);
                       }
                       else if(t==s){
                               swap(f,lt);
                       }
               }
       }

       public static swap(int a,int b){
               int te=a;
               a=b;
               b=te;
       }
}


import java.util.*;

public class Declined {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int[] r = new int[k];
		for(int i = 0; i < k; i++) {
			r[i] = sc.nextInt();
		}
		Arrays.sort(r);
		System.out.println(r[k - 1] > 25 ? r[k - 1] - 25 ? 0);
		}
	}
}


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

//Sub_To_Errichto
public class Main {
    //static final long MOD = 1000000007L;
    //static final long MOD = 998244353L;
    static final int INF = 50000000;
    static final int NINF = -500000000;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        long[] A = new long[] {sc.nl(),sc.nl()};
        long[] B = new long[] {sc.nl(),sc.nl()};
        long[] C = new long[] {sc.nl(),sc.nl()};
        long[][] vals = new long[][] {{A[0],A[1]},{A[1],-A[0]},{-A[0],-A[1]},{-A[1],A[0]}};
        String ans = "NO";
        for (long[] v: vals) {
        	long X = B[0]-v[0];
        	long Y = B[1]-v[1];
        	long num = C[1]*X-C[0]*Y;
        	long den = C[1]*C[1]+C[0]*C[0];
        	if ((num==0&&den==0)||(den!=0 && num%den==0)) {
        		long other = (den==0 ? 0 : num/den);
        		long sub = X-C[1]*other;
        		if (sub%C[0]==0) {
        			ans = "YES";
        			break;
        		}
        	}
        }
        pw.println(ans);
        pw.close();
    }

    //Find the GCD of two numbers
    public static long gcd(long a, long b) {
    	if (a < b) return gcd(b,a);
    	if (b == 0)
    		return a;
    	else
    		return gcd(b,a%b);
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            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 ni() {
            return Integer.parseInt(next());
        }

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

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

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


import java.util.*;
/**
 *
 *
 *
 * @author
 * @version 1.00 2016/9/19
 */

public class RobotSequence {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    	Scanner kbd = new Scanner(System.in);
    	int n = Integer.parseInt(kbd.nextLine());
    	String s = kbd.nextLine().toUpperCase();
    		int x = 0;
    		int y = 0;
    		int count = 0;

    	for( int i = 0; i < n; i++){
    		switch (s.charAt(i)){
    			case 'U':y++;break;
    			case 'D':y--;break;
    			case 'R':y++;break;
    			case 'L':y++;break;
    			if (y == 0 && x == 0){
    			count++;
    		}
    		}

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


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

public class DMCA {
	public static void main(String args[]) throws Exception {
		BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		int res = Math.pow(n, 0.5);
		System.out.println(res);
	}
}


import java.util.*;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.RecursiveAction;
import java.util.concurrent.RecursiveTask;
import java.util.concurrent.atomic.AtomicInteger;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.*;

import javax.swing.plaf.SliderUI;

import static java.lang.Math.*;

public class Solution implements Runnable {

	public void solve() throws Exception {
		String a = sc.nextToken();
		String b = sc.nextToken();
		int scoreA = 0;
		int scoreB = 0;
		for (int i = 0; i < a.length(); i += 2) {
			String first = a.substring(i, i + 2);
			String second = b.substring(i, i + 2);
			switch (first) {
				case "[]": {
					if (second.equals("8<"))
						scoreB++;
					if (second.equals("()"))
						scoreA++;
					break;
				}
				case "()": {
					if (second.equals("8<"))
						scoreA++;
					if (second.equals("[]"))
						scoreB++;

					break;
				}
				case "8<": {
					if (second.equals("[]"))
						scoreA++;
					if (second.equals("()"))
						scoreB++;

					break;
				}
			}
		}
		if (scoreA > scoreB) {
			out.println("TEAM 1 WINS");
		} else if (scoreB > scoreA) {
			out.println("TEAM 2 WINS");
		} else {
			out.println("TIE");
		}
	}

	static Throwable t;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Solution.t = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", 1 << 26);
		thread.start();
		thread.join();
		if (Solution.t != null)
			throw t;
	}

}

class FastScanner {

	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

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

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

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

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

}

interface ISingleton {

	public void doSomething();

}

class SingletonInjection {

	public static void inject(Class singletonClass, Object injection) throws Exception {
		Field field = singletonClass.getDeclaredField("instance");
		field.setAccessible(true);
		field.set(singletonClass, injection);
	}

}

class MockSingleton implements ISingleton {

	@Override
	public void doSomething() {
		// TODO Auto-generated method stub

	}

}

class Singleton implements ISingleton {

	private static ISingleton instance;

	public static ISingleton getInstance() {
		// create business singleton;
		return instance;
	}

	@Override
	public void doSomething() {
		// TODO Auto-generated method stub
	}

}


import java.util.*;
import java.io.*;
import java.math.*;
public class C82{

	public static void main(String args[]){
		FastReader sc = new FastReader();
        int n,m,c0,d0,i,j,k;
        n=sc.nextInt();
        m=sc.nextInt();
        c0=sc.nextInt();
        d0=sc.nextInt();
        int a[]=new int[m];
        int b[]=new int[m];
        int c[]=new int[m];
        int d[]=new int[m];
        for(i=0;i<m;i++){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
            c[i]=sc.nextInt();
            d[i]=sc.nextInt();
        }
        int dp[][]=new int[n+1][m];
        dp[1][0]=Math.max(Math.min(a[0]/b[0],1/c[0])*d[0],(1/c0)*d0);
        for(i=1;i<m;i++)
            dp[1][i]=Math.max(dp[1][i-1],Math.max(Math.min(a[i]/b[i],1/c[i])*d[i],(1/c0)*d0));
        for(i=1;i<=n;i++){
            dp[i][0]=Math.max(Math.min(a[0]/b[0],i/c[0])*d[0],(i/c0)*d0);
        }
        for(i=2;i<=n;i++){
            for(j=1;j<m;j++){
                for(k=0;k<=a[j]/b[j];k++){
                    if((i-k*c[j])>=0)
                        dp[i][j]=Math.max(dp[i][j],dp[i-k*c[j]][j-1]+k*d[j]);
                }
            }
        }
        dp[0][m-1]=(n/c0)*d0;
        for(i=1;i<=n;i++)
            dp[i][m-1]=Math.max(dp[i-1][m-1],dp[i][m-1]+((n-i)/c0)*d0);
        out.println(dp[n][m-1]);
		out.flush();
	}

	static PrintWriter out;
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out,true);
		}
		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;
		}
	}

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

	public static void print(int a[],int l,int r){
		int i;
		for(i=l;i<=r;i++)
			out.print(a[i]+" ");
		out.println();
	}

	public static long fastexpo(long x, long y, long p){
		long res=1;
		while(y > 0){
			if((y & 1)==1)
				res= ((res%p)*(x%p))%p;
			y= y >> 1;
			x = ((x%p)*(x%p))%p;
		}
		return res;
	}

	public static boolean[] sieve (int n) {
		boolean primes[]=new boolean[n+1];
		Arrays.fill(primes,true);
		primes[0]=primes[1]=false;
		for(int i=2;i*i<=n;i++){
			if(primes[i]){
				for(int j=i*i;j<=n;j+=i)
					primes[j]=false;
			}
		}
		return primes;
	}

	public static long gcd(long a,long b){
        return (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b))).longValue();
    }

    public static void merge(int a[],int l,int m,int r){
        int n1,n2,i,j,k;
        n1=m-l+1;
        n2=r-m;

        int L[]=new int[n1];
        int R[]=new int[n2];

        for(i=0;i<n1;i++)
            L[i]=a[l+i];
        for(j=0;j<n2;j++)
            R[j]=a[m+1+j];

        i=0;j=0;

        k=l;
        while(i<n1&&j<n2){
            if(L[i]<=R[j]){
                a[k]=L[i];
                i++;
            }
            else{
                a[k]=R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            a[k]=L[i];
            i++;
            k++;
        }
        while(j<n2){
            a[k]=R[j];
            j++;
            k++;
        }
    }
    public static void sort(int a[],int l,int r){
        int m;
        if(l<r){
            m=(l+r)/2;
            sort(a,l,m);
            sort(a,m+1,r);
            merge(a,l,m,r);
        }
    }
}


import java.util.Scanner;

/**
 *
 * @author sina
 */
public class ACMC1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       Scanner in=new Scanner(System.in);
       int n=in.nextInt();
       int[] x=new int[4*n+1];
       int[] y=new int[4*n+1];
       int maxX=0;
       int maxY=0;
       int maxOX=0;
       int maxOY=0;
       for (int i = 0; i < 4*n+1; i++) {
            x[i]=in.nextInt();
            y[i]=in.nextInt();
            if(x[i]!=y[i])
            {
                if(x[i]>=maxX)
                {
                    maxOX=maxX;
                    maxX=x[i];
                }
                if(y[i]>=maxY)
                {
                    maxOY=maxY;
                    maxY=y[i];
                }
            }
       }
       int l=Math.min(maxOX, maxOY);
       for (int i = 0; i < 4*n+1; i++) {
            if(x[i]!=l&&y[i]!=l&&x[i]!=0&&y[i]!=0)
            {
                System.out.println(x[i]+" "+y[i]);
                break;
            }
            else if(x[i]>l||y[i]>l)
            {
                System.out.println(x[i]+" "+y[i]);
                break;
            }
        }
    }

}


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

import java.math.*;
import java.math.BigInteger;

public final class A
{
	static PrintWriter out = new PrintWriter(System.out);
	static StringBuilder ans=new StringBuilder();
	static FastReader in=new FastReader();
	static ArrayList<Integer> g[];
	static long mod=(long)998244353,INF=Long.MAX_VALUE;
	//	static boolean set[];
	static int par[],partial[];
	static int Days[],P[][];
	static int sum=0,size[];
	static int seg[],col[];
	//	static ArrayList<Long> A;
	static char X[][];
	static boolean set[][];
	static int D[],min[],A[];
	static long dp[][];
	//	static HashSet<Integer> visited,imposters;
	//	static HashSet<Integer> set;
	//	static node1 seg[];
	//static pair moves[]= {new pair(-1,0),new pair(1,0), new pair(0,-1), new pair(0,1)};
	public static void main(String args[])throws IOException
	{
		/*
		 * star,rope,TPST
		 * BS,LST
		 */
		long x=l(),y=l();
		if(x==y)
		{
			System.out.println("YES");
			return;
		}
		String X=binary(x),Y=binary(y); //max length is 60
		if(f(X,Y))
		{
			System.out.println("YES");
			return;
		}
		long t=2L;
		while(x%t==0)x/=t;
		X=binary(x);
		if(f(X,Y))
		{
			System.out.println("YES");
			return;
		}
		X=reverse(X);
		if(f(X,Y))System.out.println("YES");
		else
			System.out.println("NO");
//		System.out.println(f("1101","1101"));
		out.println(ans);
		out.close();
	}
	static boolean f(String A,String B)
	{
		char X[]=A.toCharArray(),Y[]=B.toCharArray();
        for(int i=0; i<=Y.length-X.length; i++)
        {
        	boolean f=true;
        	for(int j=0; j<X.length; j++)
        	{
        		if(X[j]!=Y[i+j])
        		{
//        			System.out.println()
        			f=false;
        		}
        	}
        	if(f)
        	{
        		for(int j=0; j<i; j++)
        		{
        			if(X[j]=='0')f=false;
        		}
        		for(int j=i+X.length; j<Y.length; j++)
        		{
        			if(X[j]=='0')f=false;
        		}
        		if(f)return true;
        	}
        }
		return false;
	}
	static String reverse (String X)
	{
		StringBuilder sb=new StringBuilder(X);
		return sb.reverse().toString();
	}
	static String binary(long x)
	{
		String str="";
		long p=1L;
		while(p<=x)
		{
			if((p&x)!=0)str="1"+str;
			else str="0"+str;
			p<<=1;
		}
		return str;
	}

	static boolean can_loose(Trie root,boolean t)
	{
		if(root==null)return true; //never hits
		int cnt=0;
		for(Trie x:root.A)
		{
			if(x!=null)
			{
				cnt++;
				if(!can_loose(x,t^true))
				{
					//System.out.println("TRUE FOR--> "+x.ch+" "+t);
					return true;
				}
			}
		}
		if(cnt==0)return true;
		return false;
	}
	static boolean f(Trie root)
	{
		if(root==null)return false;
		//		int cnt=0;
		for(Trie x:root.A)
		{
			if(x!=null)
			{
				//				cnt++;
				if(!f(x))
				{

					return true;
				}
			}
		}
		return false;
	}
	static void insert(String X,Trie head)
	{
		Trie root=head;
		for(char x:X.toCharArray())
		{
			int a=x-'a';
			if(root.A[a]==null)root.A[a]=new Trie();
			root=root.A[a];
			root.ch=x;
		}
		root.ends=true;
	}
	static boolean search(String X,Trie head)
	{
		Trie root=head;
		for(char x:X.toCharArray()) {
			int a=x-'a';
			if(root.A[a]==null)return false;
			root=root.A[a];
		}
		return root.ends;

	}
	static boolean starts_with(String X,Trie head)
	{
		Trie root=head;
		for(char x:X.toCharArray()) {
			int a=x-'a';
			if(root.A[a]==null)return false;
			root=root.A[a];
		}
		return true;
	}
	static int lower(ArrayList<Integer>A,int i)
	{
		int l=-1,r=A.size();
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(A.get(m)>i)r=m;
			else l=m;
		}
		return r;
	}
	static int upper(ArrayList<Integer>A,int i)
	{
		int l=-1,r=A.size();
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(A.get(m)<i)l=m;
			else l=m;
		}
		return l;
	}
	static String f()
	{
		StringBuilder X=new StringBuilder(i()+"");int p=i();
		while(p-->0)X.append("0");
		return X.toString();
	}
	static long f(int i,int g,int x,int left)
	{
		if(x<=1)return left;
		if(i<0 || g==1)return left;
		//		System.out.println(i+" "+g);
		if(dp[i][g]==0)
		{
			int next=min[i];
			int new_gcd=(int)GCD(g,x);
			//System.out.println(" factor--> "+x+" gcd--> "+g+" new-->  "+new_gcd);
			long s=0;
			int c=0;
			for(int j=next+1; j<=i; j++)
			{
				if(A[i]%new_gcd==0)
				{
					s+=new_gcd;
					c--;
				}
			}
			long a=0,b=0;
			a=f(i,g,x-1,left);
			b=s+f(next,new_gcd,x-1,left-c);
			dp[i][g]=Math.max(a, b);
		}
		return dp[i][g];
	}
	static boolean f(int A[],int B[],int x)
	{
		int c=0;
		int N=A.length;
		int l=0,r=x-1;
		for(int i=0; i<N; i++)
		{
			if(A[i]>=r && B[i]>=l)
			{
				r--;
				l++;
				c++;
			}
			if(c>=x)return true;
		}
		return false;
	}
	static boolean isPalindrome(int A[])
	{
		int i=0,j=A.length-1;
		while(i<j)
		{
			if(A[i]!=A[j])return false;
			i++;
			j--;
		}
		return true;
	}
	static boolean isPalindrome(int A[],int x)
	{
		int i=0,j=A.length-1;
		while(i<j)
		{
			if(A[i]!=A[j])
			{
				if(A[i]==x)i++;
				else if(A[j]==x)j--;
				else return false;
			}
			else
			{
				i++;
				j--;
			}
		}
		return true;
	}
	static long fact[];
	static double nCr(int a,int b)
	{
		double x=fact[a], y=fact[b]*fact[a-b];
		return x/y;
	}
	static int f(ArrayList<Integer> A,int x)
	{
		int l=-1,r=A.size();
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(A.get(m)<x)l=m;
			else r=m;
		}
		return r;
	}
	static boolean f(long a,long b,long x)
	{
		if(b==0)
		{
			return (x==a || x==b);
		}
		if(a<x)return false;
		else
		{
			if(a%b==x%b)return true;
			return f(b,a%b,x);
		}
	}

	static void dfs(int n,int p)
	{
		if(p!=-1)D[n]=D[p]+1;
		for(int c:g[n])
		{
			if(c!=p)
				dfs(c,n);
		}
	}
	static long f(long a,long A[])
	{
		int l=-1,r=A.length;
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(A[m]<=a)l=m;
			else r=m;
		}
		return A[l];
	}
	static void build(int v,int tl,int tr,int A[])
	{
		if(tl==tr)
		{
			seg[v]=A[tl];
			return;
		}
		int tm=(tl+tr)/2;
		build(v*2,tl,tm,A);
		build(v*2+1,tm+1,tr,A);
		seg[v]=Math.min(seg[v*2], seg[v*2+1]);
	}
	static void update(int v,int tl,int tr,int index,int x)
	{
		if(tl==tr && tl==index)
		{
			seg[v]=x;
			return;
		}
		int tm=(tl+tr)/2;
		if(index<=tm)update(v*2,tl,tm,index,x);
		else update(v*2+1,tm+1,tr,index,x);
		seg[v]=Math.min(seg[v*2], seg[v*2+1]);
	}
	static int ask(int v,int tl,int tr,int l,int r)
	{
		//		System.out.println(v);
		//		if(v>100)return 0;
		if(l>r)return Integer.MAX_VALUE;
		if(tl==l && tr==r)return seg[v];
		int tm=(tl+tr)/2;
		int a=ask(v*2,tl,tm,l,Math.min(tm, r));
		//		System.out.println("for--> "+(v)+" tm--> "+(tm+1)+" tr--> "+tr+" l--> "+Math.max(l, tm+1)+" r--> "+r);
		int b=ask(v*2+1,tm+1,tr,Math.max(l, tm+1),r);
		return Math.min(a, b);
	}
	static int find(int a)
	{
		if(par[a]<0)return a;
		return par[a]=find(par[a]);
	}
	static void union(int a,int b)
	{
		a=find(a);
		b=find(b);
		if(a!=b)
		{
			par[a]+=par[b];
			par[b]=a;
		}
	}
	static int ask(int a,int b)
	{
		System.out.println("? "+a+" "+b);
		return i();
	}

	static long and(int i,int j)
	{
		System.out.println("and "+i+" "+j);
		return l();
	}
	static long or(int i,int j)
	{
		System.out.println("or "+i+" "+j);
		return l();
	}
	static boolean is_Sorted(int A[])
	{
		int N=A.length;
		for(int i=1; i<=N; i++)if(A[i-1]!=i)return false;
		return true;
	}
	static boolean f(StringBuilder sb,String Y,String order)
	{
		StringBuilder res=new StringBuilder(sb.toString());
		HashSet<Character> set=new HashSet<>();
		for(char ch:order.toCharArray())
		{
			set.add(ch);
			for(int i=0; i<sb.length(); i++)
			{
				char x=sb.charAt(i);
				if(set.contains(x))continue;
				res.append(x);
			}
		}

		String str=res.toString();
		return str.equals(Y);
	}
	static boolean all_Zero(int f[])
	{
		for(int a:f)if(a!=0)return false;
		return true;
	}
	static long form(int a,int l)
	{
		long x=0;
		while(l-->0)
		{
			x*=10;
			x+=a;
		}
		return x;
	}
	static int count(String X)
	{
		HashSet<Integer> set=new HashSet<>();
		for(char x:X.toCharArray())set.add(x-'0');
		return set.size();
	}

	//	static void build(int v,int tl,int tr,long A[])
	//	{
	//		if(tl==tr)
	//		{
	//			seg[v]=A[tl];
	//		}
	//		else
	//		{
	//			int tm=(tl+tr)/2;
	//			build(v*2,tl,tm,A);
	//			build(v*2+1,tm+1,tr,A);
	//			seg[v]=Math.min(seg[v*2], seg[v*2+1]);
	//		}
	//	}

	static int [] sub(int A[],int B[])
	{
		int N=A.length;
		int f[]=new int[N];
		for(int i=N-1; i>=0; i--)
		{
			if(B[i]<A[i])
			{
				B[i]+=26;
				B[i-1]-=1;
			}
			f[i]=B[i]-A[i];
		}
		for(int i=0; i<N; i++)
		{
			if(f[i]%2!=0)f[i+1]+=26;
			f[i]/=2;
		}
		return f;
	}

	static int max(int a ,int b,int c,int d)
	{
		a=Math.max(a, b);
		c=Math.max(c,d);
		return Math.max(a, c);
	}
	static int min(int a ,int b,int c,int d)
	{
		a=Math.min(a, b);
		c=Math.min(c,d);
		return Math.min(a, c);
	}

	static HashMap<Integer,Integer> Hash(int A[])
	{
		HashMap<Integer,Integer> mp=new HashMap<>();
		for(int a:A)
		{
			int f=mp.getOrDefault(a,0)+1;
			mp.put(a, f);
		}
		return mp;
	}
	static long mul(long a, long b)
	{
		return ( a %mod * 1L * b%mod )%mod;
	}
	static void swap(int A[],int a,int b)
	{
		int t=A[a];
		A[a]=A[b];
		A[b]=t;
	}

	static boolean isSorted(int A[])
	{
		for(int i=1; i<A.length; i++)
		{
			if(A[i]<A[i-1])return false;
		}
		return true;
	}

	static boolean isDivisible(StringBuilder X,int i,long num)
	{
		long r=0;
		for(; i<X.length(); i++)
		{
			r=r*10+(X.charAt(i)-'0');
			r=r%num;
		}
		return r==0;
	}

	static int lower_Bound(int A[],int low,int high, int x)
	{
		if (low > high)
			if (x >= A[high])
				return A[high];

		int mid = (low + high) / 2;

		if (A[mid] == x)
			return A[mid];

		if (mid > 0 && A[mid - 1] <= x && x < A[mid])
			return A[mid - 1];

		if (x < A[mid])
			return lower_Bound( A, low, mid - 1, x);

		return lower_Bound(A, mid + 1, high, x);
	}

	static String f(String A)
	{
		String X="";
		for(int i=A.length()-1; i>=0; i--)
		{
			int c=A.charAt(i)-'0';
			X+=(c+1)%2;
		}
		return X;
	}

	static void sort(long[] a) //check for long
	{
		ArrayList<Long> l=new ArrayList<>();
		for (long i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static String swap(String X,int i,int j)
	{
		char ch[]=X.toCharArray();
		char a=ch[i];
		ch[i]=ch[j];
		ch[j]=a;
		return new String(ch);
	}

	static int sD(long n)
	{

		if (n % 2 == 0 )
			return 2;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0 )
				return i;
		}

		return (int)n;
	}

	static void setGraph(int N)
	{
		//		tot=new int[N+1];
		partial=new int[N+1];
		Days=new int[N+1];
		P=new int[N+1][(int)(Math.log(N)+10)];
		//		set=new boolean[N+1];
		g=new ArrayList[N+1];
		D=new int[N+1];
		for(int i=0; i<=N; i++)
		{

			g[i]=new ArrayList<>();
			Days[i]=-1;
			D[i]=Integer.MAX_VALUE;
			//D2[i]=INF;
		}
	}

	static  long pow(long a,long b)
	{
		long pow=1;
		long x=a;
		while(b!=0)
		{
			if((b&1)!=0)pow=(pow*x)%mod;
			x=(x*x)%mod;
			b/=2;
		}
		return pow;
	}

	static long toggleBits(long x)//one's complement || Toggle bits
	{
		int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;

		return ((1<<n)-1)^x;
	}

	static int countBits(long a)
	{
		return (int)(Math.log(a)/Math.log(2)+1);
	}

	static long fact(long N)
	{
		long n=2;
		if(N<=1)return 1;
		else
		{
			for(int i=3; i<=N; i++)n=(n*i)%mod;
		}
		return n;
	}

	static int kadane(int A[])
	{
		int lsum=A[0],gsum=A[0];
		for(int i=1; i<A.length; i++)
		{
			lsum=Math.max(lsum+A[i],A[i]);
			gsum=Math.max(gsum,lsum);
		}
		return gsum;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static boolean isPrime(long N)
	{
		if (N<=1)  return false;
		if (N<=3)  return true;
		if (N%2 == 0 || N%3 == 0) return false;
		for (int i=5; i*i<=N; i=i+6)
			if (N%i == 0 || N%(i+2) == 0)
				return false;
		return true;
	}
	static void print(char A[])
	{
		for(char c:A)System.out.print(c+" ");
		System.out.println();
	}
	static void print(boolean A[])
	{
		for(boolean c:A)System.out.print(c+" ");
		System.out.println();
	}
	static void print(int A[])
	{
		for(int a:A)System.out.print(a+" ");
		System.out.println();
	}
	static void print(long A[])
	{
		for(long i:A)System.out.print(i+ " ");
		System.out.println();

	}
	static void print(boolean A[][])
	{
		for(boolean a[]:A)print(a);
	}
	static void print(long A[][])
	{
		for(long a[]:A)print(a);
	}
	static void print(int A[][])
	{
		for(int a[]:A)print(a);
	}
	static void print(ArrayList<Integer> A)
	{
		for(int a:A)System.out.print(a+" ");
		System.out.println();
	}

	static int i()
	{
		return in.nextInt();
	}

	static long l()
	{
		return in.nextLong();
	}

	static int[] input(int N){
		int A[]=new int[N];
		for(int i=0; i<N; i++)
		{
			A[i]=in.nextInt();
		}
		return A;
	}

	static long[] inputLong(int N)     {
		long A[]=new long[N];
		for(int i=0; i<A.length; i++)A[i]=in.nextLong();
		return A;
	}

	static long GCD(long a,long b)
	{
		if(b==0)
		{
			return a;
		}
		else return GCD(b,a%b);
	}

}
class Trie
{
	char ch;
	Trie A[];
	boolean ends;
	Trie()
	{
		ch='*';
		A=new Trie[26];
		ends=false;
	}
}
class pair1 implements Comparable<pair1>
{
	int a, index;
	pair1(int b,int i)
	{
		a=b;
		index=i;
	}
	public int compareTo(pair1 x)
	{
		return x.a-this.a;
	}
}

//Code For FastReader
//Code For FastReader
//Code For FastReader
//Code For FastReader
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;
	}

}


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

/**
 * @author Pavel Mavrin
 */
public class E {

    private static final int MOD = (int) (1e9+7);
    public static final int N = 7;
    public static final int NN = 128;

    private void solve() throws IOException {
        int[] w = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = nextInt();
        }
        int[] start = new int[2];
        start[1] = 1;
        int[] a = start;
        for (int h = 0; h < N; h++) if (w[h] > 0) {
            int nn = (1 << (h + 1));
            {
                int[] aa = new int[nn];
                for (int i = 0; i < a.length; i++) {
                    aa[i - a.length + nn] = a[i];
                }
                a = aa;
            }
            int[][] q = new int[nn][];
            int[] t = new int[nn];
            for (int i = 0; i < nn; i++) {
                t[i] = 1;
                q[i] = add(t, h + 1);
                t[i] = 0;
            }
            q = pow(q, w[h]);
            int[] aa = new int[nn];
            for (int i = 0; i < nn; i++) {
                for (int j = 0; j < nn; j++) {
                    aa[j] = (int) ((aa[j] + 1l * a[i] * q[i][j]) % MOD);
                }
            }
            a = aa;
        }
        out.println(a[a.length - 1]);
    }

    private int[][] pow(int[][] a, int b) {
        int n = a.length;
        if (b == 0) {
            int[][] res = new int[n][n];
            for (int i = 0; i < n; i++) {
                res[i][i] = 1;
            }
            return res;
        }
        if (b % 2 == 0) {
            int[][] aa = mult(a, a);
            return pow(aa, b / 2);
        } else {
            int[][] aa = pow(a, b - 1);
            return mult(aa, a);
        }
    }

    private int[][] mult(int[][] a, int[][] b) {
        int n = a.length;
        int[][] c = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    c[i][k] = (int) ((c[i][k] + 1l * a[i][j] * b[j][k]) % MOD);
                }
            }
        }
        return c;
    }

    private int[] add(int[] a, int n) {
        int nn = (1 << (n + 1));
        int[][] d = new int[n + 1][nn];
        for (int i = 0; i < nn / 2; i++) {
            d[0][(i << 1) + 1] = a[i + a.length - (1 << n)];
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < nn; j++) if (d[i][j] > 0) {
                int q = (j >> i) & 3;
                for (int k = 0; k < 4; k++) {
                    if (q == 3 && k == 3) continue;
                    int jj = (j - (q << i) + (k << i));
                    d[i + 1][jj] += d[i][j];
                    while (d[i + 1][jj] >= MOD) {
                        d[i + 1][jj] -= MOD;
                    }
                }
            }
        }
        int[] res = new int[a.length];
        for (int i = 0; i < (1 << n); i++) {
            res[i + a.length - (1 << n)] = d[n][i + (1 << n)];
        }
        return res;
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

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

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

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


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

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

class TaskD {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int x1 = in.nextInt(), x2 = in.nextInt(), a = in.nextInt(), b = in.nextInt();
        boolean flag = false;
        if (x1 > x2) {
            int aux = x1;
            x1 = x2;
            x2 = aux;
            aux = -a;
            a = -b;
            b = aux;
            flag = true;
        }

        if (b <= 0) {
            out.println("DRAW");
            return;
        }
        if (b >= x2 - x1 && x2 - x1 >= a) {
            out.println("FIRST\n" + (flag ? x1: x2));
            return;
        }
        if (a <= 0) {
            out.println("DRAW");
            return;
        }
        if ((x2 - x1) % (a + b) == 0) {
            out.println("SECOND");
            return;
        }
        if (a <= (x2 - x1) % (a + b) && (x2 - x1) % (a + b) <= b) {
            out.println("FIRST\n" + (flag ? x2 - (x2 - x1) % (a + b): x1 + (x2 - x1) % (a + b)));
            return;
        }
        out.println("DRAW");
    }
}

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

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

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

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

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

        return res.toString();
    }

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

}


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

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

        int N = r.nextInt();
        int[] a = new int[N];
        int sum = 0;
        for(int i = 0; i < N; i++){
            a[i] = r.nextInt();
            sum += a[i];
        }

        ArrayList<Integer> res = new ArrayList<Integer>();
        for(int i = 0; i < N; i++)
            if(a[i] *(N - 1) == (sum - a[i]))res.add(i+1);

        System.out.println(res.size());
        for(int i : res)
            System.out.println(i);
    }
}


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

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

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

    static class EKuroAndTopologicalParity {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int p = in.readInt();
            int[] c = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                c[i] = in.readInt();
            }

            Modular mod = new Modular(1e9 + 7);
            Composite comp = new Composite(n, mod);
            CachedPow pow = new CachedPow(2, mod);
            int[] pow2 = new int[n + 1];
            int[] compEven = new int[n + 1];
            int[] compOdd = new int[n + 1];
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j += 2) {
                    compEven[i] = mod.plus(compEven[i], comp.composite(i, j));
                }
            }
            for (int i = 0; i <= n; i++) {
                for (int j = 1; j <= n; j += 2) {
                    compOdd[i] = mod.plus(compOdd[i], comp.composite(i, j));
                }
            }
            for (int i = 0; i <= n; i++) {
                pow2[i] = pow.pow(i);
            }

            int[][][][] last = new int[n + 1][n + 1][n + 1][2];
            int[][][][] next = new int[n + 1][n + 1][n + 1][2];

            last[0][0][0][0] = 1;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    for (int k = 0; k <= n; k++) {
                        for (int t = j; t + k <= i; t++) {
                            for (int parity = 0; parity < 2; parity++) {
                                next[j][k][t][parity] = 0;
                                if (c[i] != 1 && t > 0) {
                                    //it's 0 now

                                    //pick even and it's odd
                                    if (j > 0) {
                                        next[j][k][t][parity] = mod.plus(next[j][k][t][parity],
                                                mod.mul(mod.mul(last[j - 1][k][t - 1][1 - parity], compEven[k]), pow2[i - t - k]));
                                    }

                                    //pick odd and it's even
                                    next[j][k][t][parity] = mod.plus(next[j][k][t][parity],
                                            mod.mul(mod.mul(last[j][k][t - 1][parity], compOdd[k]), pow2[i - t - k]));
                                }
                                if (c[i] != 0) {
                                    //it's 1 now

                                    //pick even and it's odd
                                    if (k > 0) {
                                        next[j][k][t][parity] = mod.plus(next[j][k][t][parity],
                                                mod.mul(mod.mul(last[j][k - 1][t][1 - parity], compEven[j]), pow2[t - j]));
                                    }

                                    //pick odd and it's even
                                    next[j][k][t][parity] = mod.plus(next[j][k][t][parity],
                                            mod.mul(mod.mul(last[j][k][t][parity], compOdd[j]), pow2[t - j]));
                                }
                            }
                        }
                    }
                }

                int[][][][] tmp = last;
                last = next;
                next = tmp;
            }

            int ans = 0;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    for (int k = 0; k <= n; k++) {
                        int cnt = last[i][j][k][p];
                        cnt = mod.mul(cnt, pow.pow(comp.composite(k, 2)));
                        cnt = mod.mul(cnt, pow.pow(comp.composite(n - k, 2)));
                        ans = mod.plus(ans, cnt);
                    }
                }
            }

            out.println(ans);
        }

    }

    static class DigitUtils {
        private DigitUtils() {
        }

        public static long round(double x) {
            if (x >= 0) {
                return (long) (x + 0.5);
            } else {
                return (long) (x - 0.5);
            }
        }

    }

    static class Composite {
        final Factorial factorial;
        final Modular modular;

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

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

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

    }

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

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

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

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

        public int readInt() {
            int sign = 1;

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

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

            return val;
        }

    }

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

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

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

        public FastOutput println(int c) {
            cache.append(c).append('\n');
            return this;
        }

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

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

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

    }

    static class Modular {
        int m;

        public int getMod() {
            return m;
        }

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

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

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

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

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

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

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

        public Modular getModularForPowerComputation() {
            return new Modular(m - 1);
        }

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

    }

    static class InverseNumber {
        int[] inv;

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

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

    }

    static class CachedPow {
        private int[] first;
        private int[] second;
        private Modular mod;
        private Modular powMod;

        public CachedPow(int x, Modular mod) {
            this(x, mod.getMod(), mod);
        }

        public CachedPow(int x, int maxExp, Modular mod) {
            this.mod = mod;
            this.powMod = mod.getModularForPowerComputation();
            int k = Math.max(1, (int) DigitUtils.round(Math.sqrt(maxExp)));
            first = new int[k];
            second = new int[maxExp / k + 1];
            first[0] = 1;
            for (int i = 1; i < k; i++) {
                first[i] = mod.mul(x, first[i - 1]);
            }
            second[0] = 1;
            int step = mod.mul(x, first[k - 1]);
            for (int i = 1; i < second.length; i++) {
                second[i] = mod.mul(second[i - 1], step);
            }
        }

        public int pow(int exp) {
            return mod.mul(first[exp % first.length], second[exp / first.length]);
        }

    }

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

        public Modular getModular() {
            return modular;
        }

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

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

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

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

    }
}


package com.mangusttank;

//Задача: Взлом кода
//http://codeforces.com/problemset/problem/630/L

import java.math.BigInteger;
import java.util.Scanner;
import java.lang.String;

public class Main {

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

        String str = String.valueOf(in_str.charAt(0)) + String.valueOf(in_str.charAt(2))
                + String.valueOf(in_str.charAt(4)) + String.valueOf(in_str.charAt(3)) + String.valueOf(in_str.charAt(1));

        BigInteger num = BigInteger.valueOf(0).add(new BigInteger(str).pow(5));
        str = new StringBuffer( new StringBuffer(num.toString()).reverse().toString().substring(0,5)).reverse().toString();

        System.out.println(str);
    }
}


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

	public static void main(String args[]){

		Scanner in=new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		int q=in.nextInt();

		while(q--!=0){

			long a=in.nextLong(),
				 b=in.nextLong(),
				 m=in.nextLong();

			if(b<a){
				System.out.println(-1);
				continue;
			}
			else if(a==b){
				System.out.println("1 "+a);
				continue;
			}

			ArrayList<Long> item=new ArrayList<>();
			item.add(a);

			long power=0;

			while(true){

				long curr=(1<<power)*a;
				item.add(curr);

				if(curr>=b || curr+(1<<power)*m>=b)
					break;

				power+=1;
			}
			int n=item.size();

			if((b-item.get(n-1))/(1<<power)<1 ){
				System.out.println(-1);
				continue;
			}

			ArrayList<Long> freq=new ArrayList<>();
			ArrayList<Long> mul=new ArrayList<>();

			for(long i=power; i>=1L; i--){
				freq.add(1L<<(i-1));
				mul.add((b-item.get(n-1))/(1<<power));
			}
			freq.add(1L);
			mul.add((b-item.get(n-1))/(1<<power));

			long rem=(b-item.get(n-1))%(1<<power);

			for(int i=0; i<freq.size(); i++)
				if(freq.get(i)<=rem){
					mul.set(i, mul.get(i)+1);
					rem-=freq.get(i);
				}

			for(int i=1; i<freq.size(); i++)
				for(int j=0; j<i; j++)
					mul.set(i, mul.get(j)+mul.get(i));

			for(int i=1; i<item.size(); i++)
				item.set(i, item.get(i)+mul.get(i-1));

			System.out.print(item.size()+" ");
			for(long value:item)
				System.out.print(value+" ");
			System.out.println();

		}
	}
}


import java.util.*;

public class ABBY_2_b {

	static long sum=0;
	static long max = 0;

	/*             Miller                           */

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

	static long binpow(long a, long b, long p){
		if (b == 0) return 1;
		if (b%2==1) return (binpow(a, b-1, p)*a)%p;
		else {
			long t = binpow(a, b/2, p);
			return (t*t)%p;
		}
	}

	static boolean isPrime(long n){
		long a = 2;
		for (int i = 0; i<10; i++){
			while (gcd(a, n)!=1) a++;
			if (binpow(a, n-1, n) != 1) return false;
		}
		return true;
	}

	static void R(long n, long sum){
		if (n == 1) {  if (sum > max) max = sum; return;}
		if (isPrime(n)) R(1, sum+1);
		for (int i = 2; i <= n; i++)
			if (n%i==0) {
				R(n/i, sum + n/i);
				break;
			}
	}

	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		long n = in.nextLong();
		R(n, n);
		System.out.println(max);
	}

}


import sun.misc.Sort;

import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by user on 04.03.14.
 */

public class code {
        public static void main(String[] args) throws IOException
        {
            new code().run();
        }

    void run(){
        try{
            // с консоли
           sc  = new Scanner( new InputStreamReader(System.in  ) );
           out = new PrintWriter(   new OutputStreamWriter(System.out) );

            // с файлов
           // sc  = new Scanner(new FileReader("input.txt") );
           // out = new PrintWriter(   new FileWriter("output.txt") );
        } catch (Exception e) {
            return;
        }
        double tBeg = System.currentTimeMillis();
        solve();
        System.err.println( "TIME: " + (System.currentTimeMillis()-tBeg)/1e3 );
        out.flush();
        out.close();
    }
    //////////////////////////////////////////////////////////////////////////////////////////

    Scanner sc;
    PrintWriter out;

        void solve()
        {
            int n = sc.nextInt();
            int [] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nextInt();
            int k = sc.nextInt();
            Arrays.sort(a);
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                int cur = 0;
                for (int j = i + 1; j < n; j++)
                {
                    if(a[j] - a[i] <= k)
                        cur++;
                    else
                        break;
                }
                ans = Math.max(ans, ++cur);
            }
            out.print(ans);
        }
}


import java.util.Scanner;

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

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

        long x = 1;
        long k = 2;
        long p = 1000000009;
        while (m>0) {
            if (m%2==0) {
                k = (k*k)%p;
                m/=2;
            } else {
                m--;
                x = (x*k)%p;
            }
        }
        long ans = 1;
        for (int i=1;i<=n;i++) {
            x--;
            if (x<0) {
                x+= p;
            }
            ans*=x;
        }

        System.out.println(ans);
    }
}


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

public class Main{

    BufferedReader in;
    StringTokenizer str = null;
    PrintWriter out;

    private String next() throws Exception{
    	while (str == null || !str.hasMoreElements())
    	    str = new StringTokenizer(in.readLine());
    	return str.nextToken();
    }

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

    int lp[];
    List<Integer> pr;

    public void run() throws Exception{
    	in = new BufferedReader(new InputStreamReader(System.in));
    	out = new PrintWriter(System.out);
	int a = nextInt(), b = nextInt(), k = nextInt();
	for(int i = 2; i * i <= k; ++i){
	    if (k % i == 0){
		out.println(0);
		out.close();
		return;
	    }
	}

	if (k > 100){
	    int n = b / k;
	    pr = new ArrayList<Integer>();
	    lp = new int[n + 1];
	    for(int i = 2; i <= n; ++i){
		if (lp[i] == 0){
		    lp[i] = i;
		    pr.add(i);
		}
		for(int j = 0;j < pr.size() && pr.get(j) <= i && 1L * i * pr.get(j) <= n; ++j){
		    lp[pr.get(j) * i] = pr.get(j);
		}
	    }

	    int res = calc(b, k) - calc(a-1, k);
	    out.println(res);
	}else{
	    pr = new ArrayList<Integer>();
	    for(int i = 2; i < k; ++i){
		if (isPrime(i)){
		    pr.add(i);
		}
	    }

	    int res = calc1(b, k) - calc1(a-1, k);
	    out.println(res);
	}

        out.close();
    }

    private boolean isPrime(int x) {
	for(int i = 2; i * i <= x; ++i){
	    if (x % i == 0){
		return false;
	    }
	}
	return true;
    }

    private int calc(int n, int k){
	int ret = 0;
	for(int i = 2; 1L * i * k <= n; ++i){
	    if (lp[i] >= k){
		++ret;
	    }
	}
	return ret;
    }

    private int calc1(int n, int k){
	int res = n / k;
	int N = pr.size();
	for(int mask = 1; mask < 1 << N; ++mask){
	    int r = n/k;
	    for(int j = 0; j < N; ++j){
	        if ((mask & (1 << j)) > 0){
		    r/=pr.get(j);
		}
	    }
	    if (Integer.bitCount(mask) % 2 == 1){
	        res-=r;
	    }else{
	        res+=r;
	    }
	}

	return res;
    }

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


import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();  // side length of a square
    int x = sc.nextInt();  // x-coord of stone landing.
    int y = sc.nextInt();  // y-coord of stone landing.
    if (y % a == 0) {      // lies either on a border, or in the outer region
      System.out.println("-1");
    } else if (y / a % 2 == 0 && y / a > 1)) {  // two horizontal boxes on this y-level
      if (-a < x && x < 0) {
        System.out.println(((y / a) * 3) / 2);
      } else if (0 < x && x < a) {
        System.out.println(((y / a) * 3) / 2 + 1);
      } else {
        System.out.println("-1");
      }
    } else {  // one horizontal box on this y-level
      if (Math.abs(x) < (a + 1) / 2) {
        if (y < a) {
          System.out.println("1");
        } else {
          System.out.println((((y / a) - 1) * 3) / 2 + 2);
        }
      } else {
        System.out.println("-1");
      }
    }
  }
}