import java.io.*;

//Codeforces Beta Round #41 (Div. 1), B
public class Chess {

    public static void main(String[] args) throws IOException {
		File file = new File("input.txt");
		if(file.exists())
			System.setIn(new FileInputStream(file));
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String[] ss = r.readLine().split(" ");
		boolean a[][] = new boolean[10][10];
		for(int i = 0; i < 10; i++)
			a[0][i] = a[i][0] = a[9][i] = a[i][9] = true;
		int k1 = ss[2].charAt(0) - 'a' + 1, k2 = ss[2].charAt(1) - '0';
		for(String s : new String[]{ss[0], ss[1]}) {
			int l1 = s.charAt(0) - 'a' + 1, l2 = s.charAt(1) - '0';
			for(int i = 1; i < 9; i++) {
				if(i != l1 && (l2 != k2 || i <= k1 && l1 < k1 || i >= k1 && l1 > k1))
					a[i][l2] = true;
				if(i != l2 && (l1 != k1 || i <= k2 && l2 < k2 || i >= k2 && l2 > k2))
					a[l1][i] = true;
			}
		}
		a[k1][k2] = a[k1][k2 - 1] = a[k1][k2 + 1] = a[k1 - 1][k2 - 1] = a[k1 - 1][k2] = a[k1 - 1][k2 + 1] = a[k1 + 1][k2 - 1] = a[k1 + 1][k2] = a[k1 + 1][k2 + 1] = true;
		/*for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 10; j++)
				System.out.print(a[i][j] ? 'X' : ' ');
			System.out.println();
		}*/
		int p1 = ss[3].charAt(0) - 'a' + 1, p2 = ss[3].charAt(1) - '0';
		boolean result = a[p1][p2] && a[p1][p2 - 1] && a[p1][p2 + 1] && a[p1 - 1][p2 - 1] && a[p1 - 1][p2] && a[p1 - 1][p2 + 1] && a[p1 + 1][p2 - 1] && a[p1 + 1][p2] && a[p1 + 1][p2 + 1];
		System.out.println(result ? "CHECKMATE" : "OTHER");
    }

}


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

public class Greedy {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] firstLine = sc.nextLine().split(" ");
        int d = Integer.parseInt(firstLine[0]);
        int toStudy = Integer.parseInt(firstLine[1]);
        int[] arr = new int[d * 2];
        int[] gb = new int[d];
        for(int i = 0; i < d; i++) {
            String[] nextLine = sc.nextLine().split(" ");
            arr[i * 2] = Integer.parseInt(nextLine[0]);
            arr[i * 2 + 1] = Integer.parseInt(nextLine[1]);
            toStudy -= arr[i * 2]; // greedy subtraction of the minimum;
            gb[i] = arr[i * 2];
        }
        if(toStudy < 0) {
            System.out.println("NO"); // the mins are too high for the study time
            return;
        }
        for(int i = 0; i < d; i++) {
            toStudy -= (arr[i * 2 + 1] - arr[i * 2]);
            gb[i] = arr[i * 2 + 1];
            if(toStudy <= 0) {
                gb[i] -= Math.abs(toStudy);
                System.out.println("YES");
                printString(gb);
                return;
            }
        }
        System.out.println("NO");

    }

    private static void printString(int[] arr) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < arr.length; i++) {
            sb.append(arr[i]);
            sb.append(" ");
        }
        System.out.println(sb.toString());
    }

}


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

public class AntonAndFairyTale {
    InputStream is;
    PrintWriter pw;
    String INPUT = "";
    long L_INF = (1L << 60L);

    void solve() {
        long n = nl(), m = nl(), start = 0, end = (long)2e9, mid;
        if (m >= n) {
            pw.println(n);
            return;
        }
        n -= m;
        while (start < end) {
            mid = start + (end - start) / 2;
            long x = mid * (mid + 1) / 2;
            if (n <= x)
                end = mid;
            else
                start = mid + 1;
        }
        pw.println(start + m);
    }

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

        long s = System.currentTimeMillis();
        //        int t = ni();
        //        while (t-- > 0)
        solve();
        pw.flush();
        tr(System.currentTimeMillis() - s + "ms");
    }

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

    private byte[] inbuf = new byte[1024];
    private int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

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

    private void tr(Object... o) {
        if (!oj) System.out.println(Arrays.deepToString(o));
    }
}


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

public class Main {

    static long n, k, a, b;
    static long mn = Long.MAX_VALUE;
    static long mx = Long.MIN_VALUE;

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

    static void check(long start, long finish) {
        long len = (finish - start + n * k) % (n * k);
        long g = gcd(n * k, len);
        long cnt = n * k / g;
        mn = Math.min(mn, cnt);
        mx = Math.max(mx, cnt);
//        System.err.println(len + " " + mn + " " + mx);
    }

    public static void main(String[] args) throws Exception {
        FastScanner scanner = new FastScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        n = scanner.nextInt();
        k = scanner.nextInt();

        a = scanner.nextInt();
        b = scanner.nextInt();

        for (long i = 0; i < n; i++) {
            check(1 + a, 1 + i * k + b);
            check(1 + a, 1 + i * k - b);
            check(1 - a, 1 + i * k + b);
            check(1 - a, 1 + i * k - b);
        }

        writer.println(mn + " " + mx);
        writer.close();
    }

    final static class FastScanner implements AutoCloseable {
        private final int BUFFER_CAPACITY = 1024;

        private final InputStream stream;
        private final byte[] buffer = new byte[BUFFER_CAPACITY];
        private int size = 0;
        private int current = 0;
        private char lastReadedChar = '\0';

        FastScanner(InputStream stream) {
            this.stream = stream;
        }

        FastScanner(String filename) throws IOException {
            this.stream = new FileInputStream(filename);
        }

        public void close() throws Exception {
            stream.close();
        }

        boolean hasNextLine() throws Exception {
            try {
                return Character.isWhitespace(lastReadedChar) || !endOfInputReached();
            } catch (IOException e) {
                return false;
            }
        }

        char nextChar() throws Exception {
            byte firstByte = nextByte();
            int octets = 0;
            for (int i = 7; (firstByte >> i & 1) == 1; i--) {
                octets++;
            }
            if (octets == 0) {
                return (char) firstByte;
            }
            char res = 0;
            for (int bit = 7 - octets; bit >= 0; bit--) {
                res <<= 1;
                res += (firstByte >> bit) & 1;
            }
            for (int i = 1; i < octets; i++) {
                res <<= 6;
                res += nextByte() + 128;
            }
            return res;
        }

        String next() throws Exception {
            do {
                lastReadedChar = nextChar();
            } while (Character.isWhitespace(lastReadedChar));
            StringBuilder res = new StringBuilder();
            while (!endOfInputReached() && !Character.isWhitespace(lastReadedChar)) {
                res.append(lastReadedChar);
                lastReadedChar = nextChar();
            }
            if (!Character.isWhitespace(lastReadedChar)) {
                res.append(lastReadedChar);
            }
            return res.toString();
        }

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

        private byte nextByte() throws Exception {
            if (endOfInputReached()) {
                throw new Exception();
            }
            return buffer[current++];
        }

        private void fillBuffer() throws Exception {
            do {
                size = stream.read(buffer);
            } while (size == 0);
            current = 0;
        }

        private boolean endOfInputReached() throws Exception {
            if (current >= size) {
                fillBuffer();
            }
            return size == -1;
        }
    }
}


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;

public class D {

	static int N;
	static Vec ar[];
	static boolean used[];
	static char S[];
	static int sId;
	static ArrayList<Integer> res;
	static boolean largerY = false;
	public static void main(String[] args) {
		JS in = new JS();
		PrintWriter out = new PrintWriter(System.out);

		N = in.nextInt();
		res = new ArrayList<Integer>();
		ar = new Vec[N];
		for(int i = 0; i < N; i++) {
			ar[i] = new Vec(in.nextLong(),in.nextLong(),i);
		}

		S = in.next().toCharArray();

		Vec b = ar[0];
		if(S[0] == 'L') {
			for(int i = 1; i < N; i++) if(ar[i].x < b.x || (ar[i].x == b.x && ar[i].y > b.y)) b = ar[i];
		}
		else {
			for(int i = 1; i < N; i++) if(ar[i].x < b.x || (ar[i].x == b.x && ar[i].y < b.y)) b = ar[i];
		}
		used = new boolean[N];
		add(b.id);

		for(int sId = 0; sId < S.length; sId++) {
			if(S[sId] == 'L') {
				Vec next = null;
				for(int i = 0; i < N; i++) {
					if(used[ar[i].id])continue;
					if(next == null || ar[i].sub(b).cross(next.sub(b)) > 0) next = ar[i];
				}
				add(next.id);
				b = next;
			}
			else {
				Vec next = null;
				for(int i = 0; i < N; i++) {
					if(used[ar[i].id])continue;
					if(next == null || ar[i].sub(b).cross(next.sub(b)) < 0) next = ar[i];
				}
				add(next.id);
				b = next;
			}

		}

		for(int i = 0; i < N; i++) {
			if(!used[ar[i].id]) res.add(ar[i].id);
		}

		for(int ii : res) out.print((ii+1)+" ");
		out.println();
		out.close();
	}

	static void add(int x) {
		res.add(x);
		used[x]=true;
	}

	static class Vec implements Comparable<Vec>{
		long x,y;
		int id;
		public Vec(long xx, long yy) {
			x=xx;
			y=yy;
		}
		public Vec(long xx, long yy, int ii) {
			x=xx;
			y=yy;
			id=ii;
		}
		public long cross(Vec o) {
			return x*o.y - y*o.x;
		}
		public Vec sub(Vec o) {
			return new Vec(x-o.x, y-o.y);
		}
		@Override
		public int compareTo(Vec o) {
			if(x == o.x) return  largerY ? -Long.compare(y, o.y) : Long.compare(y, o.y);
			return Long.compare(x, o.x);
		}
	}

	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
		    while(c!='.'&&c!='-'&&(c <'0' || c>'9')) c = nextChar();
		    boolean neg = c=='-';
		    if(neg)c=nextChar();
		    boolean fl = c=='.';
		    double cur = nextLong();
		    if(fl) return neg ? -cur/num : cur/num;
		    if(c == '.') {
			double next = nextLong();
			return neg ? -cur-next/num : cur+next/num;
		    }
		    else return neg ? -cur : cur;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}


import java.util.*;

public class BearAndCompressing {

    int n, q, ans = 0;
    String[][] op = new String[36][2];

    BearAndCompressing() {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        q = scanner.nextInt();

        for (int i = 0; i < q; i++) {
            op[i][0] = scanner.next();
            op[i][1] = scanner.next();
        }

        for (int i = 0; i < q; i++) {
            if (op[i][1].equals("a")) {
                recursive(op[i][0]);
            }
        }
        System.out.println(ans);
        scanner.close();
    }

    void recursive(String res){
        if (res.length() >= n) {
            ans++;
            return;
        }
        String temp;
        for (int i = 0; i < q; i++) {
            if (op[i][1].charAt(0) == res.charAt(0)) {
                temp = res;
                res = op[i][0] + res.substring(1);
                //System.out.println(res);
                recursive(res);
                res = temp;
            }
        }
    }

    public static void main(String[] args) {
        BearAndCompressing solve = new BearAndCompressing();
    }
}


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

public class ar {

    static 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 (final 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 (final IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static boolean[] seen;
    static Map<Integer, Integer> map;
    static Set<Character> charset;
    static Set<Integer> set;
    static int[] arr;
    static int[][] dp;
    static int rem = (int) 1e9 + 7;
    static List<List<Integer>> graph;
static int[][] kmv ={{2,1},{1,2},{2,-1},{-1,2},{-2,1},{1,-2},{-1,-2},{-2,-1}};
static char[]car;
static boolean[] primes;
static int MAX=(int)1e4+1;
static double[] dar;
static long[] lar;
static void Sieve(){

primes=new boolean[MAX];
primes[0]=true;
primes[1]=true;

for(int i=2;i*i<MAX;i++){
    if(!primes[i]){
        for(int j=i*i;j<MAX;j+=i){
            primes[j]=true;
        }
    }
}

}

public static void main( String[] args) throws java.lang.Exception {
         FastReader scn = new FastReader();
int n=scn.nextInt();
String s=scn.next();
int cnt=0;
int ans=0;
int i=0;
while(i<n){
    if(s.charAt(i)>='a' && s.charAt(i)<='z'){
        charset=new HashSet<>();
    for(int j=i;j<n;j++){
        if(s.charAt(j)<='Z'){
          ans=Math.max(ans,cnt);
          cnt = 0; break;}
        if(s.charAt(j)>='a' && s.charAt(j)<='z'){
           if(!charset.contains(s.charAt(j)))
           {charset.add(s.charAt(j));
               cnt++;}
       }
    i++;
    }
    if(cnt>ans)ans=cnt;
}else i++;
}
System.out.print(ans);
return;
}

}


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

public class B {

  void solve() {
    Input in = new Input(System.in);
    int n = in.nextInt();
    int r = in.nextInt();
    int v = in.nextInt();

    for(int i = 0; i < n; i++) {
      int s = in.nextInt();
      int f = in.nextInt();
      int d = f - s;

      double gain = 0.0;
      while(true) {
        double newGain = calculateGain(gain, d, r);
        if(Math.abs(newGain - gain) < 10e-7) {
          break;
        } else {
          gain = (newGain + gain) / 2;
        }
      }

      double result = (d - gain) / v;

      System.out.println(result);
    }
  }

  double calculateGain(double gain, int d, int r) {
    double rounds = Math.floor((d -gain) / (2 * Math.PI * r));
    double diff = d -gain - rounds * 2 * Math.PI * r;
    double angle = diff / r;

    if(angle > Math.PI) angle = 2 * Math.PI - angle;

    double newGain = 2 * r * Math.sin(angle / 2);

    return newGain;
  }

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

  class Input {

    BufferedReader br;
    StringTokenizer st;

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

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

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

  }

}


import java.util.*;

public class A {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.println((int)Math.signum(s.nextLine().toLowerCase().compareTo(s.nextLine().toLowerCase())));
    }
}


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

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

		int num = scan.nextInt();

		int[] numbers = new int[num];

		for (int i = 0; i < num; i++) {
			numbers[i] = scan.nextInt();
		}

		Arrays.sort(numbers);

		if (num == 0) {
			System.out.println("YES");
			System.out.println(1);
			System.out.println(1);
			System.out.println(3);
			System.out.println(3);
			return;
		}
		else if (num == 1) {
			System.out.println("YES");
			System.out.println(numbers[0]);
			System.out.println(3*numbers[0]);
			System.out.println(3*numbers[0]);
			return;
		}

		else if (num == 2) {
			if (numbers[0] == numbers[1]) {
				System.out.println("YES");
				System.out.println(3*numbers[0]);
				System.out.println(3*numbers[0]);
				return;
			}

			else if (numbers[1]/numbers[0] == 3) {
				System.out.println("YES");
				System.out.println(3*numbers[0]);
				System.out.println(3*numbers[1]);
				return;
			}

			else if (numbers[0]/numbers[1] == 3) {
				System.out.println("YES");
				System.out.println(3*numbers[0]);
				System.out.println(3*numbers[1]);
			}

			else {
				for(int i = 1; i <= 1500; i++) {
					for (int j = 1; j <= 1500; j++) {
						if (check2(numbers, i, j)) {
							System.out.println("YES");
							System.out.println(i);
							System.out.println(j);
							return;
						}
					}
				}
				System.out.println("NO");
				return;
			}
		}

		else if (num == 3) {
//			if (numbers[0] == numbers[1]) {
//				if (numbers[2]/numbers[0] == 3) {
//					System.out.println("YES");
//					System.out.println(numbers[2]);
//					return;
//				}
//				else if (numbers[0]/numbers[2] == 3) {
//					System.out.println("YES");
//					System.out.println(numbers[2]);
//					return;
//				}
//				else {
//					System.out.println("NO");
//					return;
//				}
//			}
//
//			else if (numbers[0] == numbers[2]) {
//				if (numbers[1]/numbers[0] == 3 || numbers[0]/numbers[1] == 3) {
//					System.out.println("YES");
//					System.out.println(numbers[1]);
//					return;
//				}
//				else {
//					System.out.println("NO");
//					return;
//				}
//			}
//
//			else if (numbers[1] == numbers[2]) {
//				if (numbers[0]/numbers[1] == 3 || numbers[1]/numbers[0] == 3) {
//					System.out.println("YES");
//					System.out.println(numbers[0]);
//					return;
//				}
//				else {
//					System.out.println("NO");
//					return;
//				}
//			}
			//no duplicates at all
			//else {
				if (3*numbers[0]<numbers[2]) {
					System.out.println("NO");
				}
				else {
					for(int i = 1; i <= 1500; i++) {
						if(check3(numbers, i)) {
							System.out.println("YES");
							System.out.println(i);
							return;
						}
					}
					System.out.println("NO");
					return;
				}
			//}
		}

		else {
			check4(numbers[0], numbers[1], numbers[2], numbers[3]);
			return;
		}
	}

	public static void check4(int a, int b, int c, int d) {
		if ((d-a) == ((b+c)/2) && (d-a) == ((a+b+c+d)/4)) {
				System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}

	public static boolean check3(int[] numbers, int i) {
		int[]num = new int[4];

		int index = 0;

		for(int x: numbers) {
			num[index] = x;
			index++;
		}
		num[index] = i;

		Arrays.sort(num);

		if ( ((num[3]-num[0]) == ((num[1]+num[2])/2.0)) && ((num[3]-num[0]) == ((num[0]+num[1]+num[2]+num[3])/4.0)) ) {
//			for(int x: num) {
//				System.out.println(x);;
//			}
			return true;
		}

		return false;

	}
	public static boolean check2(int[] numbers, int i, int j) {
		int[]num = new int[4];

		int index = 0;

		for(int x: numbers) {
			num[index++] = x;
		}

		num[index++] = i;
		num[index] = j;

		Arrays.sort(num);

		if ((num[3]-num[0]) == ((num[1]+num[2])/2.0) && (num[3]-num[0]) == ((num[0]+num[1]+num[2]+num[3])/4.0)) {
				return true;
		}

		else {
			return false;
		}

	}
}


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

public class Codeforces553B {

	public static void main(String[] args) {
		try {
			BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer st = new StringTokenizer(f.readLine());
			int n = Integer.parseInt(st.nextToken());
			long k = Long.parseLong(st.nextToken()) - 1;
			f.close();
			StringBuffer permutation = new StringBuffer("");
			long[] fibonacci = new long[n + 1];
			fibonacci[1] = 1;
			for(int i = 2; i <= n; i++)
				fibonacci[i] = fibonacci[i - 1] + fibonacci[i - 2];
			int current = 1;
			int counter = n;
			while(counter > 0)
			{
				if(k < fibonacci[counter])
				{
					permutation.append(current + " ");
					current++;
					counter--;
				}
				else
				{
					permutation.append((current + 1) + " " + current + " ");
					k -= fibonacci[counter];
					current += 2;
					counter -= 2;
				}
				//System.out.println(permutation.toString().trim());
			}
			System.out.println(permutation.toString().trim());
			//System.out.println(Arrays.toString(binary));
			//System.out.println(Arrays.toString(groups));
		}
		catch(IOException e) {
			e.printStackTrace();
		}
	}

}


import static java.util.Arrays.sort;
import java.util.Scanner;

public class third
{
	public static void main(String arr[])
	{
		Scanner sc= new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long count=0;
		if(b==1)
		{
			System.out.println(a);
			return ;
		}
		while(a%b!=1)
		{
			count+=a/b;
			long temp=b;
			b=a%b;
			a=temp;
		}
		count+=a/b;
		count+=b;
		System.out.println(count);

	}
}


import java.io.PrintWriter;
import java.util.Scanner;

public class A {
   public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);
    String s = sc.next();
    int t = Integer.valueOf(s.substring(0,1));
    int h = Integer.valueOf(s.substring(1,2));
    int [] a = {2,7,2,3,3,4,2,5,1,2};
    pw.print(a[t] * a[h]);
    pw.flush();
}
}


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

public class Main {
    public static void main (String[] args) throws java.lang.Exception {
		InputReader scan = new InputReader(System.in);
		PrintWriter writer = new PrintWriter(System.out, true);
		(new Main(scan, writer)).run();
		writer.close();
    }

    private InputReader jin;
    private PrintWriter jout;

    public Main(InputReader in, PrintWriter out) {
    	this.jin  = in;
    	this.jout = out;
    }

    public void run() throws Exception {
		int n = jin.integer();
		if(n == 0) {
			jout.println("0 0 0");
		} else if(n == 1) {
		 	jout.println("0 0 1");
		} else {
			int[] fib = new int[(int)1e6];
			fib[0] = 0; fib[1] = 1;
			int i = 2;
			for(; fib[i - 1] < n; i++) {
				fib[i] = fib[i - 1] + fib[i - 2];
			}
			jout.println(fib[0] + " " + fib[i - 2] + " " + fib[i - 3]);
		}

    }
}

class InputReader {
    private static final int bufferMaxLength = 1024;
    private InputStream in;
    private byte[] buffer;
    private int currentBufferSize;
    private int currentBufferTop;
    private static final String tokenizers = " \t\r\f\n";

    public InputReader(InputStream stream) {
        this.in = stream;
        buffer = new byte[bufferMaxLength];
        currentBufferSize = 0;
        currentBufferTop = 0;
    }

    private boolean refill() throws IOException {
        this.currentBufferSize = this.in.read(this.buffer);
        this.currentBufferTop = 0;
        return this.currentBufferSize > 0;
    }

    private Byte readChar() throws IOException {
        if(currentBufferTop < currentBufferSize) {
            return this.buffer[this.currentBufferTop++];
        } else {
            if(!this.refill()) {
                return null;
            } else {
                return readChar();
            }
        }
    }

    public String token() throws IOException {
        StringBuffer tok = new StringBuffer();
        Byte first;
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) != -1));
        if(first == null) return null;
        tok.append((char)first.byteValue());
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) == -1)) {
            tok.append((char)first.byteValue());
        }
        return tok.toString();
    }

    public String line() throws IOException {
		Byte first;
		StringBuffer line = new StringBuffer();
		while ((first = readChar()) != null && (char)first.byteValue() != '\n') {
			line.append((char)first.byteValue());
		}
		return (first == null && line.length() == 0)? null : line.toString();
    }

    public Integer integer() throws NumberFormatException, IOException {
        String tok = token();
        return tok == null? null : Integer.parseInt(tok);
    }

}


import java.util.Scanner;

public class RectanglePuzzleII {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double n = sc.nextDouble();
		double m = sc.nextDouble();
		double x = sc.nextDouble();
		double y = sc.nextDouble();
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double abgcd = gcd(a,b);

		if (abgcd>1) {
			a = a/abgcd;
			b = b/abgcd;
		}

		double ratio = 1;

		if ((Math.abs(n))/a > (Math.abs(m))/b) {
			ratio = Math.floor((Math.abs(m))/b);
		} else if ((Math.abs(n))/a < (Math.abs(m))/b) {
			ratio = Math.floor((Math.abs(n))/a);
		} else if ((Math.abs(n))/a == (Math.abs(m))/b) {
			ratio = Math.floor((Math.abs(m))/b);
		}

		double xxsize = a*ratio;
		double xx1 = x-Math.ceil(xxsize/2);
		double xx2 = x+Math.floor(xxsize/2);
		if (n > 0) {
			if (xx1 <= 0) {
				double move = 0-xx1;
				xx1 += move;
				xx2 += move;
			} else if (xx2 >= n) {
				double move = xx2-n;
				xx1 -= move;
				xx2 -= move;
			}
		} else if (n < 0) {
			if (xx1 >= 0) {
				double move = xx1;
				xx1 -= move;
				xx2 -= move;
			} else if (xx2 <= n) {
				double move = xx2-n;
				xx1 += move;
				xx2 += move;
			}
		}

		double yysize = b*ratio;
		double yy1 = y-Math.ceil(yysize/2);
		double yy2 = y+Math.floor(yysize/2);
		if (m > 0) {
			if (yy1 <= 0) {
				double move = 0-yy1;
				yy1 += move;
				yy2 += move;
			} else if (yy2 >= m) {
				double move = yy2-m;
				yy1 -= move;
				yy2 -= move;
			}
		} else if (m < 0) {
			if (yy1 >= 0) {
				double move = yy1;
				yy1 -= move;
				yy2 -= move;
			} else if (yy2 <= m) {
				double move = yy2-m;
				yy1 += move;
				yy2 += move;
			}
		}

		System.out.printf("%.0f %.0f %.0f %.0f",xx1,yy1,xx2,yy2);

	}

	public static double gcd(double x ,double y ) {

	    if ( y == 0 )
	        return x;
	    else if ( x >= y && y > 0)
	        return gcd ( y , x % y );
	    else return gcd ( y , x );

	}
}


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

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

public class C {

	static Long t = System.currentTimeMillis() ;
	public static void main(String[] args) throws IOException {

//		Random r = new Random() ;
//		int n = 1000 ;
//		out.println(n) ;
//		for( int i = 1 ; i < n ; i++ )
//			out.println(i + " " + (i+1)) ;
//		for( int i = 0 ; i < n ; i++ )
//			out.println(r.nextInt() + " " + r.nextInt()) ;
//

		new C().solveProblem();
		time() ;
		out.close();
	}

	static void time() {
		//out.println(System.currentTimeMillis()-t);
	}
	static Scanner in = new Scanner(new InputStreamReader(System.in));
	static BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	static PrintStream out = new PrintStream(new BufferedOutputStream(System.out));

	int n ;

	public void solveProblem() throws IOException {

		n = Int() ;
		t = System.currentTimeMillis() ;
		bouwGraaf(n,n-1) ;

		Point[] ps = new Point[n];

		for( int i = 0 ; i < n ; i++ )
			ps[i] = new Point(Long(),Long(),i) ;
		opl = new int[n] ;

		kind = new int[n][] ;
		ak = new int[n] ;
		dfs(0,-1) ;

		int van = 0 ;
		int tot = n ;
		int pi = van ;
		Point pivot = ps[van] ;
		for( int i = van + 1 ; i < tot; i++ ){
			Point pnu = ps[i] ;
			if( pnu.y < pivot.y || (pnu.y == pivot.y && pnu.x < pivot.x)){
				pi = i ;
				pivot = ps[i] ;
			}
		}

		ps[pi] = ps[van] ;
		ps[van] = pivot ;

		losOp(ps,0,0,n) ;
		wr(opl) ;
	}

	private int dfs(int u,int p) {

		int nk = buren[u].size() ;
		if( p != -1 )
			nk-- ;
		kind[u] = new int[nk] ;

		int som = 1 ;
		int t = 0 ;
		for( int v : buren[u] )
			if( v != p ){
				kind[u][t++] = v ;
				som += dfs(v,u) ;
			}

		return ak[u] = som  ;
	}

	int[][] kind ;
	int[] ak ;
	private void losOp(Point[] ps, int u, int van, int tot) {

		Point pivot = ps[van] ;

		Point.pivot = pivot ;
		sort(ps,van+1,tot) ;

//		p((u+1),van,tot,pivot.index) ;
//		p(ps);
		opl[pivot.index] = u + 1 ;

		int t = van + 1 ;
		for( int v : kind[u]){
			losOp(ps,v,t,t+ak[v]) ;
			t += ak[v] ;
		}

	}

	int[] opl ;

	ArrayList<Integer>[] buren ;
	void bouwGraaf(int nv, int ne){

		buren = new ArrayList[nv] ;
		for( int i = 0 ; i < nv ; i++ )
			buren[i] = new ArrayList<Integer>() ;

		for( int i = 0 ; i < ne ; i++ ){
			int u = Int() - 1 ;
			int v = Int() - 1 ;
			buren[u].add(v) ;
			buren[v].add(u) ;
		}
	}

	static String Line() throws IOException{
		return buf.readLine() ;
	}

	static int bufI = 0 ;
	static int[] bufInts = new int[0] ;

	static int Int() {
		if( bufI == bufInts.length )
			bufReaderNInts() ;
		return bufInts[bufI++] ;
	}

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

	static void bufReaderNInts() {
		String[] ss;
		try {
			ss = buf.readLine().split(" ");
			bufInts = new int[ss.length] ;
			for( int i = 0 ; i < ss.length ; i++ ){
				bufInts[i] = Integer.parseInt(ss[i]) ;
			}
			bufI = 0 ;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	static int bufL = 0 ;
	static long[] bufLongs = new long[0] ;

	static long Long() {
		if( bufL == bufLongs.length )
			bufReaderNLongs() ;
		return bufLongs[bufL++] ;
	}

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

	static void bufReaderNLongs(){
		String[] ss;
		try {
			ss = buf.readLine().split(" ");
			bufLongs = new long[ss.length] ;
			for( int i = 0 ; i < ss.length ; i++ ){
				bufLongs[i] = Long.parseLong(ss[i]) ;
			}
			bufL = 0 ;
		} catch (IOException e) {

		}

	}

	static int[] toArray( ArrayList<Integer> lijst ){
		int[] res = new int[lijst.size()] ;
		int t = 0 ;
		for( int i : lijst)
			res[t++] = i;
		return res ;
	}

	static void p( Object ...p){
		System.out.println(Arrays.deepToString(p));
	}

	static void wr( int[] rij ){
		for( int i = 0 ; i < rij.length - 1 ; i++ )
			out.print(rij[i] + " ") ;
		out.println(rij[rij.length-1]);

	}

	static void wr( long[] rij ){
		for( int i = 0 ; i < rij.length - 1 ; i++ )
			out.print(rij[i] + " ") ;
		out.println(rij[rij.length-1]);

	}

}
class Point implements Comparable<Point>{

	static double EPS = 1e-11 ;

	long x ;
	long y ;
	int index ;
	static Point pivot ;
	public Point(long x, long y, int index) {
		this.x = x;
		this.y = y;
		this.index = index;
	}

	@Override
	public int compareTo(Point o) {

		long a = (x-pivot.x)*(o.y-pivot.y) - (o.x-pivot.x)*(y-pivot.y)  ;
		if( a > 0 )	return -1 ;
		else if( a == 0 ) return 0 ;
		else return 1 ;

	}

	private double pretty(double v) {
		v %= 2 * Math.PI;
		if (v < 0)
			v += 2 * Math.PI;
		return v;
	}

	public String toString(){
		return "[" + x + "," + y + "]" ;
	}
}


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

public class p926J {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer st;
		int times = Integer.parseInt(f.readLine());
		IntervalList list = new IntervalList();
		while(times-- > 0)
		{
			st = new StringTokenizer(f.readLine());
			int s = Integer.parseInt(st.nextToken());
			int e = Integer.parseInt(st.nextToken());
			list.add(s, e);
			out.println(list.size());
		}
		out.close();
	}

	static class IntervalList
	{
		public TreeSet<Interval> set;
		public IntervalList()
		{
			set = new TreeSet<Interval>();
		}

		public void add(int s, int e)
		{
			Iterator<Interval> iter = set.tailSet(new Interval(s, s), true).iterator();
			while(iter.hasNext())
			{
				Interval i = iter.next();
				if(i.s > e)
					break;
				if(i.s < s)
					s = i.s;
				if(i.e > e)
					e = i.e;
				iter.remove();
			}
			set.add(new Interval(s, e));
		}

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

	static class Interval implements Comparable<Interval>
	{
		int s, e;
		public Interval(int s, int e)
		{
			this.s = s;
			this.e = e;
		}

		public int compareTo(Interval i)
		{
			return e - i.e;
		}

		public String toString()
		{
			return s + " " + e;
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        ExpectedEarnings solver = new ExpectedEarnings();
        solver.solve(1, in, out);
        out.close();
    }
    static class ExpectedEarnings {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), X = in.nextInt();
            double c = X / 1_000_000.0;
            double[] cprob = new double[n + 1];
            for (int i = 0; i <= n; i++) {
                cprob[i] = in.nextInt();
            }
            double[] dp = new double[n + 1];
            for (int nballs = n - 1; nballs >= 0; nballs--) {
                double[] next = new double[nballs + 1];
                double[] nprob = new double[nballs + 1];
                for (int red = 0; red <= nballs; red++) {
                    if (cprob[red] < 1e-10 && cprob[red + 1] < 1e-10) continue;
                    int black = nballs - red;
                    double probred = cprob[red + 1] * (red + 1) / (cprob[red + 1] * (red + 1) + cprob[red] * (black + 1));
                    nprob[red] = ((red + 1) * cprob[red + 1] + (black + 1) * cprob[red]) / (double) (nballs + 1);
                    next[red] = Math.max(0, -c + probred * (1 + dp[red + 1]) + (1 - probred) * dp[red]);
                }
                dp = next;
                cprob = nprob;
            }
            out.printf("%.10f\n", dp[0]);
        }
    }
    static 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 (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;
                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException var2) {
                        throw new InputMismatchException();
                    }
                    if (this.numChars <= 0) {
                        return -1;
                    }
                }
                return this.buf[this.curChar++];
            }
        }
        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }
            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }
            int res = 0;
            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }
            throw new InputMismatchException();
        }
        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;
        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }
        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }
        public void printf(String format, Object... objects) {
            writer.printf(format, objects);
        }
        public void close() {
            writer.close();
        }
    }
}


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

public class q5 {

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

		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int x=Reader.nextInt(),y=Reader.nextInt(),z=Reader.nextInt();
		int x1=Reader.nextInt(),y1=Reader.nextInt(),z1=Reader.nextInt();
		int v1=Reader.nextInt(),v2=Reader.nextInt(),v3=Reader.nextInt();
		int v4=Reader.nextInt(),v5=Reader.nextInt(),v6=Reader.nextInt();
		long ans=0;
		if(y<0) ans+=v1;
		else if(y>y1) ans+=v2;
		if(z<0) ans+=v3;
		else if(z>z1) ans+=v4;
		if(x<0) ans+=v5;
		else if(x>x1) ans+=v6;
		out.print(ans);
		out.flush();
	}
}

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


import java.util.Scanner;

public class Main {
 public static void main(String[] args){
  Scanner in = new Scanner(System.in);
  long b, c=0, i;
   b = in.nextLong();

    for (i = 1; i * i <= b; i++) {
       if (b % i == 0) {
      	 c += 2;
       }
       if (i * i == b) {
      	 c--;
       }
    }

    System.out.println(c);
 }
}


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

public class C {

    long mod = 1000000007;
    long memo[] = new long[101];
    long memoNot[] = new long[101];
    int n;
    int k;
    int d;

    long go(int curr, boolean contains, String space) {
        //System.out.println(space + curr + " " + contains);
        if (curr < 0) return 0;
        if (curr == 0 && contains) return 1;
        if (curr == 0 && !contains) return 0;
        if (memo[curr] > -1 && contains)
            return memo[curr];
        if (memoNot[curr] > -1 && !contains)
            return memoNot[curr];

        long ans = 0;
        for (int i = 1; curr - i >= 0 && i <= k; i++) {
            ans += go(curr - i, ((i >= d) ? true : contains), space + " ");
        }

        ans = ans % mod;
        if (contains)
            memo[curr] = ans;
        else
            memoNot[curr] = ans;
        return ans;

    }

    public void solve() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        d = sc.nextInt();

        Arrays.fill(memo, -1);
        Arrays.fill(memoNot, -1);

        System.out.println(go(n, false, "") % mod);
    }

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

}


import java.util.Scanner;

public class Main {

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

      Scanner scanner=new Scanner(System.in);
      long n=scanner.nextLong();
      long m=scanner.nextLong();
      long  build=scanner.nextLong();
      long dem=scanner.nextLong();
      long rem=n%m;
      long  a=rem*dem;
      long  b=(m-rem)*build;
      if (a>b)
      {
          System.out.println(b);
      }
      else
      {
          System.out.println(a);
      }

    }
}


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

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

    static class SwapPrefixesDp {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next(), t = in.next();
            List<Integer> ans1 = solve("a" + s, "b" + t);
            List<Integer> ans2 = solve("b" + s, "a" + t);
            if (ans1.size() > ans2.size()) {
                ans1 = ans2;
            }
            out.println(ans1.size() / 2);
            for (int i = 0; i < ans1.size(); i += 2) {
                out.println(ans1.get(i) + " " + ans1.get(i + 1));
            }
        }

        private void makeSwap(List<Integer> realAns, List<Pair> compressedS, List<Pair> compressedT, int lenS, int lenT) {
            List<Pair> newS = new ArrayList<>();
            List<Pair> newT = new ArrayList<>();

            int realLenS = 0, realLenT = 0;
            for (int i = 0; i < lenS; i++) {
                realLenS += compressedS.get(i).count;
            }
            for (int i = 0; i < lenT; i++) {
                realLenT += compressedT.get(i).count;
            }
            realAns.add(realLenS - 1);
            realAns.add(realLenT - 1);
            concatLists(compressedS, compressedT, lenS, lenT, newS);
            concatLists(compressedT, compressedS, lenT, lenS, newT);
            compressedS.clear();
            compressedS.addAll(newS);
            compressedT.clear();
            compressedT.addAll(newT);
        }

        private void concatLists(List<Pair> compressedS, List<Pair> compressedT, int lenS, int lenT, List<Pair> newS) {
            newS.addAll(compressedT.subList(0, lenT));
            newS.addAll(compressedS.subList(lenS, compressedS.size()));
            if (lenT < newS.size() && newS.get(lenT - 1).ch == newS.get(lenT).ch) {
                newS.get(lenT - 1).count += newS.get(lenT).count;
                newS.remove(lenT);
            }
        }

        private List<Integer> solve(String s, String t) {
            List<Pair> compressedS = compress(s);
            List<Pair> compressedT = compress(t);
            if (compressedS.size() == 1 && compressedT.size() == 1) {
                return new ArrayList<>();
            }
            int curI = compressedS.size(), curJ = compressedT.size();

            int bestI = -1, bestJ = -1;
            int bestCost = Integer.MAX_VALUE;

            for (int lenI = 1; lenI <= compressedS.size(); lenI++) {
                for (int lenJ = 1; lenJ <= compressedT.size(); lenJ++) {
                    if (lenI % 2 != lenJ % 2) {
                        continue;
                    }
                    if (lenI > 3 && lenJ > 3) {
                        break;
                    }
                    int nextI = lenJ + (curI - lenI) - ((curI != lenI && lenJ % 2 == lenI % 2) ? 1 : 0);
                    int nextJ = lenI + (curJ - lenJ) - ((curJ != lenJ && lenJ % 2 == lenI % 2) ? 1 : 0);

                    int cost = 1 + Math.max(nextI, nextJ);
                    if (cost < bestCost) {
                        bestCost = cost;
                        bestI = lenI;
                        bestJ = lenJ;
                    }
                }
            }

            List<Integer> ans = new ArrayList<>();
            makeSwap(ans, compressedS, compressedT, bestI, bestJ);

            int nextI = compressedS.size(), nextJ = compressedT.size();

            int prefixA = 0, prefixB = 0;
            for (int i = 0; i < Math.max(nextI, nextJ) - 1; i++) {
                if (i % 2 == 0) {
                    prefixA += i >= compressedS.size() ? 0 : compressedS.get(i).count;
                    prefixB += i >= compressedT.size() ? 0 : compressedT.get(i).count;
                    ans.add(prefixA - 1);
                    ans.add(prefixB - 1);
                } else {
                    prefixA += i >= compressedT.size() ? 0 : compressedT.get(i).count;
                    prefixB += i >= compressedS.size() ? 0 : compressedS.get(i).count;
                    ans.add(prefixB - 1);
                    ans.add(prefixA - 1);
                }
            }

            return ans;
        }

        private List<Pair> compress(String s) {
            List<Pair> result = new ArrayList<>();
            for (int i = 0; i < s.length(); ) {
                int j = i;
                while (j < s.length() && s.charAt(i) == s.charAt(j)) {
                    j++;
                }
                result.add(new Pair(s.charAt(i), j - i));
                i = j;
//                System.err.println(result);
            }
            return result;
        }

        class Pair {
            char ch;
            int count;

            public Pair(char ch, int count) {
                this.ch = ch;
                this.count = count;
            }

            @Override
            public String toString() {
                return "Pair{" +
                        "ch=" + ch +
                        ", count=" + count +
                        '}';
            }
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

    }
}


//package codeforces.R462;

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

public class D
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		long p = sc.nextLong();
		int k = sc.nextInt();
		long[] arr = new long[1000];
		boolean neg = true;
		long cur = p;
		for (int i = 0; i < 100; i++)
		{
			if(cur == 0)
				break;
			long res = 0;
			if(neg)
				res = cur/k;
			else
				res = (cur+k-1)/k;
			arr[i] = res;
			cur = arr[i];
			neg = neg?false:true;
		}

		BigInteger[] ans = new BigInteger[100];
		for (int i = 0; i < ans.length; i++)
		{
			BigInteger v1 = BigInteger.valueOf(arr[i]);
			v1 = v1.multiply(BigInteger.valueOf(k));
			BigInteger v2 = BigInteger.ZERO;
			if(i > 0)
				v2 = v2.add(BigInteger.valueOf(arr[i-1]));

			if(i%2 == 0)
				v1 = v1.multiply(BigInteger.valueOf(-1));
			if(i > 0 && (i-1)%2 == 0)
				v2 = v2.multiply(BigInteger.valueOf(-1));
			v1 = v1.add(v2);
			ans[i] = v1;
		}

		ans[0] = ans[0].add(BigInteger.valueOf(p));

		int lst = 0;
		boolean ok = true;
		for (int i = 0; i < 100; i++)
		{
			if(!ans[i].equals(new BigInteger("0")))
				lst = i;
			if(ans[i].compareTo(BigInteger.valueOf(k)) != -1)
				ok = false;
		}

		if(!ok)
			System.out.println(-1);
		else
		{
			pw.println(lst+1);
			for (int i = 0; i <= lst; i++)
			{
				pw.print(ans[i] + " ");
			}
			pw.println();

		}

		pw.flush();
		pw.close();
	}

	static int[][] packD(int n, int[] from, int[] to) {
		int[][] g = new int[n][];
		int[] p = new int[n];
		for (int f : from) p[f]++;
		for (int i = 0; i < n; i++) g[i] = new int[p[i]];
		for (int i = 0; i < from.length; i++) {g[from[i]][--p[from[i]]] = to[i];}
		return g;
	}
	static class Scanner
	{
		StringTokenizer st; BufferedReader br;
		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public String next() throws IOException {while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());return st.nextToken();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public boolean ready() throws IOException {return br.ready();}
	}
}


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

public class Solution {

    static long maxCnt = 0, maxX = 0;

    static void calc(long m, long cnt, long x) {
        if (m <= 7) {
            cnt += m;
            x += m;

            if (cnt > maxCnt || (cnt == maxCnt && x > maxX)) {
                maxCnt = cnt;
                maxX = x;
            }
            return;
        }

        long a = (long) Math.floor(Math.pow(m, 1.0 / 3));
        calc(m - (long) Math.pow(a, 3), cnt + 1, x + (long) Math.pow(a, 3));
        calc((long) Math.pow(a, 3) - 1 - (long) Math.pow(a - 1, 3), cnt + 1, x + (long) Math.pow(a - 1, 3));
    }

    static void solve(InputReader in, OutputWriter out) {
        long m = in.nextLong();
        calc(m, 0, 0);
        out.print(maxCnt + " " + maxX);
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        solve(in, out);
        in.close();
        out.close();
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }

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

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String line = nextLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

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

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

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

        void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    static class OutputWriter {
        BufferedWriter bw;

        OutputWriter(OutputStream os) {
            bw = new BufferedWriter(new OutputStreamWriter(os));
        }

        void print(int i) {
            print(Integer.toString(i));
        }

        void println(int i) {
            println(Integer.toString(i));
        }

        void print(long l) {
            print(Long.toString(l));
        }

        void println(long l) {
            println(Long.toString(l));
        }

        void print(double d) {
            print(Double.toString(d));
        }

        void println(double d) {
            println(Double.toString(d));
        }

        void print(boolean b) {
            print(Boolean.toString(b));
        }

        void println(boolean b) {
            println(Boolean.toString(b));
        }

        void print(char c) {
            try {
                bw.write(c);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(char c) {
            println(Character.toString(c));
        }

        void print(String s) {
            try {
                bw.write(s);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(String s) {
            print(s);
            print('\n');
        }

        void close() {
            try {
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


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

public class Main

{
    class Pair<S extends Comparable<S>, T extends Comparable<T>> implements Comparable<Pair<S, T>>
    {
        S first;
        T second;

        Pair(S f, T s)
        {
            first = f;
            second = s;
        }

        @Override
        public int compareTo(Pair<S, T> o)
        {
            int t = first.compareTo(o.first);
            if (t == 0) return second.compareTo(o.second);
            return t;
        }

        @Override
        public int hashCode()
        {
            return (31 + first.hashCode()) * 31 + second.hashCode();
        }

        @Override
        public boolean equals(Object o)
        {
            if (!(o instanceof Pair)) return false;
            if (o == this) return true;
            Pair p = (Pair) o;
            return first.equals(p.first) && second.equals(p.second);
        }

        @Override
        public String toString()
        {
            return "Pair{" + first + ", " + second + "}";
        }
    }
    static 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;
        }
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        try
        {
            System.setIn(new FileInputStream("input.txt"));
            System.setOut(new PrintStream(new FileOutputStream("output.txt")));
        }
        catch (Exception e)
        {
            System.err.println("Error");
        }

        FastReader sc = new FastReader();

        int t = sc.nextInt();
        PrintWriter out = new PrintWriter(System.out);
        while(t-- > 0)
        {
            solve(sc, out);
        }
        out.close();
    }
    static void solve(FastReader sc, PrintWriter out)
    {
        long n = sc.nextLong();
        long k = sc.nextInt();

        out.println(binpow(n,k));

    }
    static long binpow(long a, long b)
    {
        long m = 1000000007;
        long res = 1;
        while (b > 0)
        {
            if (b %2== 1)
                res = res * a % m;
            a = a * a % m;
            b >>= 1;
        }
        return res % m;
    }
}


import java.util.*;

public class C {

	public static void main(String[] args) {

		Scanner qwe = new Scanner(System.in);

		int N = qwe.nextInt();
		String[] cards = new String[N];
		for (int i = 0; i < cards.length; i++) {
			cards[i] =  qwe.next();
		}

		int min = 11;
		char[] colorsnums = {'R', 'G', 'B', 'Y', 'W','1','2','3','4','5'};

		for(int bm = 0; bm < (1 << 10); bm++){
			int bc = Integer.bitCount(bm);
			if(bc >= min) continue;

			int dex =0;
			HashSet<Character> cp = new HashSet<Character>();
			for(int i = 1; i <= bm; i <<= 1,dex++){
				if((i & bm) == i) cp.add(colorsnums[dex]);
			}

			boolean good = true;

			for(int i =0; i < cards.length; i++){
				for(int j = i+1; j < cards.length; j++){
					if(cards[i].equals(cards[j])) continue;
					boolean canTellApart = false;
					if(cards[i].charAt(0) != cards[j].charAt(0)
							&& (cp.contains(cards[i].charAt(0)) || cp.contains(cards[j].charAt(0))  ) )
						canTellApart = true;
					if(cards[i].charAt(1) != cards[j].charAt(1)
							&& (cp.contains(cards[i].charAt(1)) || cp.contains(cards[j].charAt(1))  ) )
						canTellApart = true;

					if(!canTellApart) good = false;
				}
			}

			if(good){
				//System.out.println(cp);
				min = bc;
			}

		}

		System.out.println(min);

		qwe.close();
	}

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.Vector;

public class Test {

	static int n, m, k, t;
	static int[] deg = new int[501];
	static int[] w1 = new int[501];
	static int[] w2 = new int[501];
	static int[][] f = new int[50001][201];
	static int[][] index = new int[50001][201];
	static int[] color = new int[5001];
	static void alter(int y, int c1, int c2)
	{
		//swap f[y][c1] and f[y][c2]
		int temp = f[y][c1];
		f[y][c1] = f[y][c2];
		f[y][c2] = temp;
		temp = index[y][c1];
		index[y][c1] = index[y][c2];
		index[y][c2] = temp;
		color[index[y][c2]] = c2;
		if(f[y][c2] != 0) alter(f[y][c2], c2, c1);
	}

	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);
		StringTokenizer st  = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		int t = Integer.parseInt(st.nextToken());
		int cnt = 0;
		for(int i = 1; i <= k; i++)
		{
			st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			if(deg[a]%t == 0) w1[a] = ++cnt;
			if(deg[n+b]%t == 0) w2[n+b] = ++cnt;
			++deg[a];
			++deg[n+b];
			int x = w1[a];
			int y = w2[n+b];
			int c1 = -1;
			int c2 = -1;
			for(int j = 1; j <= t; j++) if(f[x][j] == 0) { c1 = j; break; }
			for(int j = 1; j <= t; j++) if(f[y][j] == 0) { c2 = j; break; }

			if(f[y][c1] != 0) alter(y, c1, c2);
			f[x][c1] = y;
			f[y][c1] = x;
			index[x][c1] = i;
			index[y][c1] = i;
			color[i] = c1;
		}
		int uneven = 0;
		for(int i = 1; i <= n; i++) if(deg[i]%t != 0) uneven++;
		for(int i = n+1; i <= n+m; i++) if(deg[i]%t != 0) uneven++;
		writer.println(uneven);
		for(int i = 1; i <= k; i++) writer.print(color[i]+" ");
		br.close();
		writer.close();
	}

}


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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            long n = in.nextLong();

            ArrayList<Long> primes = new ArrayList<>();
            int m = (int) 1e6;
            boolean notPrime[] = new boolean[m];
            for (int i = 2; i < m; i++) {
                if (!notPrime[i]) {
                    primes.add((long) i);
                    for (int j = 2 * i; j < m; j += i) {
                        notPrime[j] = true;
                    }
                }
            }

            long res = 1;

            for (Long l : primes) {
                if (n % l == 0) {
                    if (n % 2L != 0) {
                        n -= l;
                        res += (n / 2L);
                        break;
                    } else {
                        res = (n / l);
                        break;
                    }
                }
            }

            out.println(res);
        }

    }

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

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

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

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

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

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

        }

    }
}


import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class A implements Runnable {

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

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

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

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

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

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

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

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

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new A().run();
    }

    long timeBegin, timeEnd;

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

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    boolean[][] a;
    int[] color;
    int n;

    boolean foundError = false;

    void dfs(int v, int c) {
        color[v] = c;
        for (int to = 0; to < n; to++) {
            if (a[v][to]) {
                if (color[to] == -1) {
                    dfs(to, 1 - c);
                } else {
                    if (color[to] != 1 - c) {
                        foundError = true;
                        return;
                    }
                }
            }
        }
    }

    private void solve() {
        n = readInt();
        int m = readInt();
        a = new boolean[n][n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(a[i], true);
            a[i][i] = false;
        }
        while (m-->0) {
            int x = readInt() - 1;
            int y = readInt() - 1;
            a[x][y] = false;
            a[y][x] = false;
        }

        boolean[] used = new boolean[n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                used[i] |= a[i][j];
            }
        }

        color = new int[n];
        Arrays.fill(color, -1);

        for (int i = 0; i < n; i++) {
            if (color[i] == -1) {
                if (!used[i]) {
                    color[i] = 2;
                    continue;
                }
                dfs(i, 0);
                if (foundError) {
                    out.println("No");
                    return;
                }
            }
        }
        if (foundError) {
            out.println("No");
            return;
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j && !a[i][j]) {
                    if (color[i] == 1 - color[j]) {
                        foundError = true;
                        break;
                    }
                }
            }
        }
        if (foundError) {
            out.println("No");
            return;
        }

        out.println("Yes");
        for (int i = 0; i < n; i++) {
            out.print(color[i] == 0 ? 'a' : (color[i] == 1 ? 'c' : 'b'));
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Collection;
import java.util.Set;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.HashSet;
import java.util.Queue;
import java.util.LinkedList;
import java.io.InputStream;

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

    static class DNavigationSystem {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            int m = s.nextInt();
            DNavigationSystem.Graph g = new DNavigationSystem.Graph(n, true, false);
            g.takeInput(m, s);
//        out.println(g.neighbours);
            int size = s.nextInt();
            int[] arr = s.nextIntArray(size);
            int src = arr[size - 1];
            int dest = arr[0];
//        g.neighbours.remove(dest);
            HashMap<Integer, HashSet<Integer>> parent = new HashMap<>();
            HashMap<Integer, Integer> distance = new HashMap<>();
            HashSet<Integer> visited = new HashSet<>();
            Queue<Integer> q = new LinkedList<>();
            q.add(src);
            visited.add(src);
            distance.put(src, 0);
            HashMap<Integer, HashMap<Integer, Long>> neighbours = g.neighbours;
            while (!q.isEmpty()) {
                int curr = q.poll();
                HashMap<Integer, Long> neighb = neighbours.getOrDefault(curr, new HashMap<>());
                Iterator<Integer> iter = neighb.keySet().iterator();
                int currD = distance.get(curr);
                while (iter.hasNext()) {
                    int next = iter.next();
                    if (!visited.contains(next)) {
                        distance.put(next, currD + 1);
                        visited.add(next);
                        HashSet<Integer> list = new HashSet<>();
                        list.add(curr);
                        parent.put(next, list);
                        q.add(next);
                    } else {
                        if (distance.get(next) == currD + 1) {
                            HashSet<Integer> list = parent.get(next);
                            list.add(curr);
                            parent.put(next, list);
                        } else if (distance.get(next) > currD + 1) {
                            HashSet<Integer> list = parent.get(next);
                            list.clear();
                            list.add(curr);
                            distance.put(next, currD + 1);
                            parent.put(next, list);
                        }
                    }
                }

            }

//        out.println(parent);

            int worst = 0;
            int best = 0;
            for (int i = 0; i < size - 1; i++) {
                int next = arr[i + 1];
                int curr = arr[i];

                HashSet<Integer> set = parent.get(curr);
                if (set.contains(next)) {
                    if (set.size() != 1) {
                        best++;
                    }
                } else {
                    worst++;
                    best++;
                }
            }
            out.println(worst + " " + best);
        }

        private static class Graph {
            HashMap<Integer, HashMap<Integer, Long>> neighbours;
            int numVertices;
            boolean isDirected;
            boolean isWeighted;

            public Graph(int numVertices, boolean isDirected, boolean isWeighted) {
                neighbours = new HashMap<>();
                this.numVertices = numVertices;
                this.isDirected = isDirected;
                this.isWeighted = isWeighted;
            }

            public void takeInput(int n, FastReader s) {
                for (int i = 0; i < n; i++) {
                    int dest = s.nextInt();
                    int src = s.nextInt();

//                if (dest == )
                    long wt;
                    if (isWeighted) {
                        wt = s.nextLong();
                    } else {
                        wt = 1;
                    }
                    HashMap<Integer, Long> list = neighbours.getOrDefault(src, new HashMap<>());
                    list.put(dest, wt);
                    neighbours.put(src, list);
                    if (!isDirected) {
                        list = neighbours.getOrDefault(dest, new HashMap<>());
                        list.put(src, wt);
                        neighbours.put(dest, list);
                    }
                }
            }

        }

    }

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

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

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

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

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

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

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

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

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

        }

    }
}


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

public class intro{
	public static void main(String[] args) throws IOException{
		BufferedReader vod=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(vod.readLine());
		char[] mas=vod.readLine().toCharArray();
		int ans=0;
		for (int i=0; i<n; i++){
			int a=0,b=0;
			for (int j=i; j<n; j++){
				if (mas[j]=='U') a++;
				if (mas[j]=='D') a--;
				if (mas[j]=='L') b--;
				if (mas[j]=='R') b++;
				if ((a==0)&(b==0)) ans++;
			}
		}
		System.out.println(ans);
	}
}


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

public class A {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double f = (double) (Math.floor((n * 1.0) / k)) + 1;
		System.out.println((int) f * k);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
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);
            CUpgradingTree solver = new CUpgradingTree();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class CUpgradingTree {
        List<int[]> seq = new ArrayList<>(200000);
        List<Node> centers = new ArrayList<>();
        Node top;
        Node target;
        Node last;

        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            Node[] nodes = new Node[n];
            for (int i = 0; i < n; i++) {
                nodes[i] = new Node();
                nodes[i].id = i;
            }
            for (int i = 0; i < n - 1; i++) {
                Node a = nodes[in.readInt() - 1];
                Node b = nodes[in.readInt() - 1];
                a.adj.add(b);
                b.adj.add(a);
            }

            dfsForSize(nodes[0], null);
            dfsForCenter(nodes[0], null, nodes[0].size);
            if (centers.size() == 2) {
                Node a = centers.get(0);
                Node b = centers.get(1);
                a.adj.remove(b);
                b.adj.remove(a);
            }

            for (Node center : centers) {
                for (Node node : center.adj) {
                    top = center;
                    target = node;
                    last = node;
                    dfs(node, center);
                    focus(target);
                }
            }

            out.println(seq.size());
            for (int[] s : seq) {
                for (int x : s) {
                    out.append(x + 1).append(' ');
                }
                out.println();
            }
        }

        public void dfsForSize(Node root, Node p) {
            root.size = 1;
            for (Node node : root.adj) {
                if (node == p) {
                    continue;
                }
                dfsForSize(node, root);
                root.size += node.size;
            }
        }

        public void dfsForCenter(Node root, Node p, int total) {
            int max = total - root.size;
            for (Node node : root.adj) {
                if (node == p) {
                    continue;
                }
                max = Math.max(node.size, max);
                dfsForCenter(node, root, total);
            }
            if (max * 2 <= total) {
                centers.add(root);
            }
        }

        public void add(Node x, Node y, Node yy) {
            seq.add(new int[]{x.id, y.id, yy.id});
        }

        public void focus(Node next) {
            if (next == last) {
                return;
            }
            add(top, last, next);
            last = next;
        }

        public void dfs(Node root, Node p) {
            for (Node node : root.adj) {
                if (node == p) {
                    continue;
                }
                dfs(node, root);
            }

            if (root != target && p != target) {
                focus(root);
                add(root, p, target);
            }
        }

    }

    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, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

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

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

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

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

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

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

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

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

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

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

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

    }

    static class Node {
        List<Node> adj = new ArrayList<>();
        int id;
        int size;

        public String toString() {
            return "" + id;
        }

    }
}


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

/**
 *
 * @author brown
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class Missbo {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] papu = (br.readLine()).split(" ");
        long limit = Long.parseLong(papu[0]);
        long counter = Long.parseLong(papu[1]);

        if (counter <= (limit + 1) / 2)
	    {
        	System.out.println(counter*2 - 1);
        }
    	else
    	{
    		System.out.println((counter - (limit + 1) / 2) * 2 );
     	}
    }
}


import java.util.Scanner;

public class Polyline {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt(), y1 = sc.nextInt(),
                x2 = sc.nextInt(), y2 = sc.nextInt(),
                x3 = sc.nextInt(), y3 = sc.nextInt();
        sc.close();
        int result = 1;
        if ((x1 == x2 && x2 == x3) || (y1 == y2 && y2 == y3)) result = 1;
        else
            if ((x1 == x2 && !between(y3, y1, y2)) ||
                (x2 == x3 && !between(y1, y3, y2)) ||
                (x1 == x3 && !between(y2, y1, y3)) ||
                (y1 == y2 && !between(x3, x1, x2)) ||
                (y2 == y3 && !between(x1, x2, x3)) ||
                (y3 == y1 && !between(x2, x1, x3))) result = 2;
        else result = 3;
        System.out.println(result);
    }

    static boolean between(int a, int b, int c) {
        int min = Math.min(b, c), max = Math.max(b, c);
        return a > min && a < max;
    }

}


// Author @ BlackRise :) //
// Birla Institute of Technology, Mesra//
import java.io.*;
import java.util.*;

public class ehabAndCounstructionProblem {
    static Calendar ts, te;                                                  //For time calculation
    static int mod9 = (int) 1e9 + 7;
    static Lelo input = new Lelo(System.in);
    static PrintWriter pw = new PrintWriter(System.out, true);

    public static void main(String[] args) {                                 //threading has been used to increase the stack size.

        new Thread(null, null, "BlackRise", 1<<25)  //the last parameter is stack size which is desired,
        {
            public void run() {

                try {
                    Blackrise();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }

    static void Blackrise() {                                                //The name Blackrise is my pen name... you can change the name according to your wish

        tsc();                                                               //calculates the starting time of execution

        int n=ni();
        int a=n+1;
        int flag=0;
        while(a-->0 && flag==0)
        for(int i=1;i<=n && flag==0;i++)
        {
            if(a%i==0 && (a*i)>n && (i/a)<n){pl(a+ " "+i);flag=1;}

        }
        if(flag==0)pl(-1);

        tec();                  //calculates the ending time of execution
        //pwt();                //prints the time taken to execute the program
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class Lelo {                                              //Lelo class for fast input
        private InputStream ayega;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public Lelo(InputStream ayega) {
            this.ayega = ayega;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = ayega.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

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

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

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

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

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

            return res.toString();
        }

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

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

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

    // functions to take input//
    static int ni() {
        return input.nextInt();
    }

    static long nl() {
        return input.nextLong();
    }

    static double nd() {
        return input.nextDouble();
    }

    static String ns() {
        return input.readString();
    }

    //functions to give output
    static void pl() {
        pw.println();
    }

    static void p(Object o) {
        pw.print(o + " ");
    }

    static void pws(Object o){
        pw.print(o+"");
    }

    static void pl(Object o) {
        pw.println(o);
    }

    static void tsc()                                          //calculates the starting time of execution
    {
        ts = Calendar.getInstance();
        ts.setTime(new Date());
    }

    static void tec()                                          //calculates the ending time of execution
    {
        te = Calendar.getInstance();
        te.setTime(new Date());
    }

    static void pwt()                                          //prints the time taken for execution
    {
        pw.printf("\nExecution time was :- %f s\n", (te.getTimeInMillis() - ts.getTimeInMillis()) / 1000.00);
    }
}