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

public class TaskD implements Runnable {

	char str[];
	int most, n;
	final int MOD = 1000000003, MUL = 37;
	int hash[], rhash[];
	long power[];

	private long key(int l, int r)
	{
		long ret = (hash[r + 1] - hash[l] * power[r - l + 1]) % MOD;
		if (ret < 0) ret += MOD;
		return ret;
	}

	private long rkey(int l, int r)
	{
		long ret = (rhash[r + 1] - rhash[l]) % MOD;
		if (ret < 0) ret += MOD;
		return ret;
	}

	private boolean par(int l, int r)
	{
		if (l < 0) return false;

		int mid = (l + r) >> 1, len = r - l + 1;
		if (len % 2 == 1)
			return key(l, mid) * power[mid] % MOD == rkey(mid, r);
		return key(l, mid) * power[mid+1]  % MOD== rkey(mid+1, r);
	}

    private void solve() throws IOException {
    	most = nextInt();
    	String s = nextToken();
    	str = s.toCharArray();
    	n = s.length();

    	hash = new int[n + 1];
    	rhash = new int[n + 1];
    	power = new long[n + 1];

    	hash[0] = 0;
    	rhash[0] = 0;
    	power[0] = 1;
    	for (int i = 1; i <= n; ++i)
    		power[i] = power[i-1] * MUL % MOD;

    	int where = n;
    	for (int i = 0; i < n; ++i)
    	{
    		hash[i+1] = (int)((hash[i] * (long)MUL + (str[i] - 'a')) % MOD);
    		rhash[i+1] = (int)((rhash[i] + power[i] * (str[i] - 'a')) % MOD);

    		if (par(i - most + 1, i) || par(i - most, i))
    		{
    			where = i;
    			break;
    		}
    	}

    	while (where >= 0)
    	{
    		boolean ok = false;
    		for (char i = (char) (str[where] + 1); !ok && i <= 'z'; ++i)
    		{
    			hash[where+1] = (int)((hash[where] * (long)MUL + (i - 'a')) % MOD);
        		rhash[where+1] = (int)((rhash[where] + power[where] * (i - 'a')) % MOD);
    			str[where] = i;

    			ok = true;
        		if (par(where - most + 1, where) || par(where - most, where))
        			ok = false;
    		}

    		if (ok) break;
    		--where;
    	}

    	if (where < 0)
    	{
    		writer.println("Impossible");
    		return;
    	}

    	for (int p = where+1; p < n; ++p)
    	{
    		for (char i = 'a'; i <= 'z'; ++i)
    		{
    			hash[p+1] = (int)((hash[p] * (long)MUL + (i - 'a')) % MOD);
        		rhash[p+1] = (int)((rhash[p] + power[p] * (i - 'a')) % MOD);
    			str[p] = i;

        		if (!par(p - most + 1, p) && !par(p - most, p))
        			break;
    		}
    	}

    	writer.println(String.valueOf(str));
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

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

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

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

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

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


import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CanadaC {
    public static ArrayList<String> singleChar = new ArrayList<String>();
    public static int n;
    public static int m;
    public static void main(String[] args){
        initializeSingleChar();
        Scanner scanner =  new Scanner(System.in);

        String input = scanner.nextLine();
        int[] poses = findPair(input);
        int LENGTH = 13;
        int pos1 = poses[0];
        int pos2 = poses[1];
        if (pos1 == -1 && pos2 == -1) {
            System.out.println ("Impossible");
            return;
        }
        int midRange = 0;
        if ((pos2-pos1) % 2 == 1) midRange = (pos2 - pos1)/2 + 1;
        else midRange = (pos2 -pos1)/2;

        char[] row1 =  new char [13];
        char[] row2  = new char[13];

        /*
         * Contruct characters between pair
         */
        row1[LENGTH-midRange] = input.charAt(pos1);
        int count = 1;
        int c = pos1 + count;
        for (int i = LENGTH-midRange + 1 ; i < LENGTH ; i++){
            row1[i] = input.charAt(c);
            count++;
            c++;
        }
        int p = LENGTH -1;
        while (c < pos2){
            row2[p] = input.charAt(c);
            c++;
            p--;
        }
        int temp = pos2 + 1;
        int temp2 = LENGTH - midRange -1 ;
        while (temp < input.length() && temp2 >= 0){
            row1[temp2] = input.charAt(temp);
            temp++;
            temp2--;
        }
        if (temp == input.length()){                //END OF INPUT
                int tt = 0;
                while (temp2 >= 0 ){
                    row1[temp2] = input.charAt(tt);
                    tt++;
                }
                int ttt = 0 ;
                while (tt < pos1){
                    row2[ttt] = input.charAt(tt);
                    ttt++;
                    tt++;
                }
        }else if (temp2 < 0 ){
            int t = 0;
            while (temp < input.length()){
                row2[t] = input.charAt(temp);
                temp++;
                t++;
            }
            int tt = 0;
            for (tt = 0 ; tt < pos1; tt++){
                row2[t] = input.charAt(tt);
                t++;
            }
        }
        for (int i = 0 ; i < LENGTH ; i++){
            System.out.print(row1[i]);
        }
        System.out.println();
        for (int i = 0 ; i < LENGTH ; i++){
            System.out.print(row2[i]);
        }
        System.out.println();
    }
    public static void initializeSingleChar() {
        singleChar.add("A");singleChar.add("B");singleChar.add("C");singleChar.add("D");singleChar.add("E");singleChar.add("F");
        singleChar.add("G");singleChar.add("H");singleChar.add("I");singleChar.add("J");singleChar.add("K");singleChar.add("L");
        singleChar.add("M");singleChar.add("N");singleChar.add("O");singleChar.add("P");singleChar.add("Q");singleChar.add("R");
        singleChar.add("S");singleChar.add("T");singleChar.add("U");singleChar.add("V");singleChar.add("W");singleChar.add("X");
        singleChar.add("Y");singleChar.add("Z");
    }
    public static int[] findPair(String str) {
        int[] output = new int[2];
        for (String c : singleChar) {
            String regex = c + "[A-Z]+" + c;
            if (isMatches(str, regex)) {
                output[0] = str.indexOf(c);
                output[1] = output[0] + 2 + str.substring(output[0] + 2).indexOf(c);
                return output;
            }
        }
        output[0] = -1;
        output[1] = -1;
        return output;

    }
    public static boolean isMatches(String text, String regex) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        // Check all occurrences
        if (matcher.find()) {
            return true;
        }
        return false;
    }

}


public class Main{

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

        int l1 = in.nextInt();
        int r1 = in.nextInt();
        int l2 = in.nextInt();
        int r2 = in.nextInt();
        int k = in.nextInt();

        int time = Math.min(r1, r2) - Math.max(l1, l2) + 1;

        if( k <= Math.min(r1, r2) && k >= Math.max(l1, l2)){
            time--;
        }

        System.out.println( Math.max(0,time));

   }

}


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

public class Solution{
    public static void main(String[] args){
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] arr = in.readLine().trim().split(" ");
        Set<Integer> s = new HashSet<Integer>();

        for(int i = 0 ; i < n ; i++){
            s.add(Integer.parseInt(arr[i]));
        }
        ArrayList<Integer> x =  new ArrayList<Integer>(s);
        ArrayList<PriorityQueue<Integer>> res = new ArrayList<PriorityQueue<Integer>>();
        for(int i = 0 ; i< x.size(); i++){
            int t = x.get(i);
            int m =  res.size(),j=0;
            for(j = 0 ; j < m ; j++){
                PriorityQueue<Integer> temp  = res.get(j);
                if(gcd(temp.get(0),t)!=1) {
                    temp.add(t);
                    break;
                }
            }
            if(j == m){
                res.add(new PriorityQueue<Integer>());
                res.get(res.size()-1).add(t);
            }

        }
        System.out.println(res.size());
    }
    public static int gcd(int a, int b){
        if(a==0) return b;
        if(b==0) return a;
        return gcd(b, a%b);
    }
}


import java.io.*;

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

public class main2 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		String s="ACTG";
        int x = 2 + 2;
		String in=sc.next();
        boolean pl = false;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<(in.length()-3);i++)
		{
			int cost=0;
            if(cost)
                pl =true;
			for(int j=i;j<(i+4);j++)
			{
				if(s.charAt(j-i)==in.charAt(j))
				{}
				else
				{
					cost+=Integer.min(Math.abs(s.charAt(j-i)-in.charAt(j)),26-Integer.max(s.charAt(j-i), in.charAt(j))+Integer.min(s.charAt(j-i),in.charAt(j)));
				}
			//	System.out.println((s.charAt(j)+""+in.charAt(j)+" "+(26-Integer.max(s.charAt(i), in.charAt(j))+Integer.min(s.charAt(i),in.charAt(j)))));
			}
			if(cost<min)
				min=cost;

		}
        if(min)
            pl = true;
		System.out.println(min);

	}
}


import java.util.*;

public class Housing{
 public static void main(String[] s){
  Scanner scan = new Scanner(System.in);
  int n = scan.nextInt();
  int h = scan.nextInt();
  int m = scan.nextInt();
  int[] height = new int[n];
  int[][] house = new int[m][3];
  for(int i = 0; i < m; i++){
    for(int j = 0; j < 3; j++){
      house[i][j] = scan.nextInt();
    }
  }
  Arrays.fill(height,h);
  for(int i = 0; i < m ; i++){
    for(int j = [house[i][0]-1; j < house[i][1];j++){
	  height[j] = house[i][2];
    }
  }
  int tot = 0;
  for(int i = 0 ; i < n ; i++){
    tot+=Math.pow(height[i],2);
  }
  System.out.println(tot);
 }
}


import java.util.*;
public class Interview
{
    public static void main(String [] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        String a = "ogogogo";
        String b = "ogogo";
        String c = "ogo";
        String str = s.next();
        str.replaceAll(a,"***");
        str.replaceAll(b,"***");
        str.replaceAll(c,"***");
        System.out.pritnln(str);

    }
}


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

public class Exercise {
    public static void main(String[] args) throws IOException {
        String trump;
        String temp;
        Scanner in = new Scanner(System.in);
        trump = in.nextLine();
        temp = in.nextLine();
        String cards[] = temp.split(" ");

        if(cards[0].substring(1,2).equals(cards[1].substring(1,2))) {
            if(Integer.parseInt(cards[0].substring(0,1)) > Integer.parseInt(cards[1].substring(0,1))) System.out.println("YES");
            else System.out.println("NO");
        }
        else if(cards[0].substring(1,2).equals(trump)) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}


import java.util.Scanner;

public class program {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int result[]=new int[n];
        result[0]=1;
        int mod=1000000+3;
        for (int i = 1; i < n; i++) {
            result[i]=3*result[i-1]%mod;
        }
        System.out.println(result[n-1]);
    }
}


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

public class C0017 {

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

    final int MOD = 51123987;
    int[][] delta = new int[][] {
        {1, 0, 0},
        {0, 1, 0},
        {0, 0, 1}
    };

    C0017() throws Exception {
        PandaScanner sc = null;
        PrintWriter out = null;
        try {
            sc = new PandaScanner(System.in);
            out = new PrintWriter(System.out);
        } catch (Exception ignored) {
        }

        int n = sc.nextInt();
        String s = sc.next();
        char[] c = s.toCharArray();

        int max = (n + 2) / 3 + 1;
        long dp[][][][] = new long[n][max + 1][max + 1][max + 1];
        dp[c[0] - 'a'][0][0][0] = 1;

        for (int z = 0; z < c.length; z++) {
            for (int i = 0; i < max; i++) {
                for (int j = 0; j < max; j++) {
                    for (int k = 0; k < max; k++) {
                        if (dp[z][i][j][k] == 0) {
                            continue;
                        }
                        for (int a = 0; a < 3; a++) {
                            int next = s.indexOf((char) (a + 'a'), z);
                            if (next == -1) {
                                continue;
                            }
                            int[] d = delta[a];
                            dp[next][i + d[0]][j + d[1]][k + d[2]] += dp[z][i][j][k];
                            dp[next][i + d[0]][j + d[1]][k + d[2]] %= MOD;
                        }
                    }
                }
            }
        }

        long res = 0;
        for (int x = 0; x < n; x++) {
            for (int i = max - 2; i < max; i++) {
                for (int j = max - 2; j < max; j++) {
                    for (int k = max - 2; k < max; k++) {
                        if (i + j + k != n) {
                            continue;
                        }
//                        out.println(x + " " + i + " " + j + " " + k + " " + dp[x][i][j][k]);
                        res += dp[x][i][j][k];
                        res %= MOD;
                    }
                }
            }
        }
        out.println(res);

        out.close();
        System.exit(0);
    }

    //The PandaScanner class, for Panda fast scanning!
    public class PandaScanner {
        BufferedReader br;
        StringTokenizer st;
        InputStream in;

        PandaScanner(InputStream in) throws Exception {
            br = new BufferedReader(new InputStreamReader(this.in = in));
        }

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

        public boolean hasNext() throws Exception {
            return (st != null && st.hasMoreTokens()) || in.available() > 0;
        }

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

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


import java.util.*;
public class Chocolate {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
         Scanner s=new Scanner(System.in);
         int n=s.nextInt();
         int[] arr=new int[n];

         for(int i=0;i<n;i++)
         arr[i]=s.nextInt();
         int count=1;
         long prod=1;
         boolean flag=false;

         for(int j=0;j<n;j++)
         {

          if(arr[j]==1)
          {
        	  prod*=count;
        	  count=1;
              flag=true;

          }
          else
          {   if(flag!=false)
        	  count++;
          }}
  if(flag==false)
         {
        	 System.out.println(0);
        	 break;
         }
         System.out.println(prod);
	}

}


import java.util.*;

import com.sun.xml.internal.fastinfoset.util.CharArray;
import com.sun.xml.internal.ws.api.pipe.NextAction;

public class Employee {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n;
		int count=0;
		n=input.nextInt();
		String s=input.next();
		char[] t =s.toCharArray();
		char[] k = new char [n];
		for (int i = 0; i < n; i++) {
			if(t[i]=='0')
			{
				k[i]='1';
			}
			else if (t[i]=='1')
			{
				k[i]='0';

			}
		}
		t[n-1]=k[n-1];
		for (int i = 0; i < k.length; i++) {
			if(t[i]!=k[i])
			{
				count++;
			}
		}
		System.out.println(count);
	}
}


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

public class Code{
    public static void main (String args[]) {
        Scanner sc=new Scanner (System.in);
        String s=sc.nextLine();
        String temp[]=s.split(" ");
        String s=temp[0];
        System.out.println(s);
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
        final StringBuilder sb = new StringBuilder();

        int n = Integer.parseInt(st.nextToken());
        int p = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());

        int start = p - k > 1 ? p-k : 1;
        int end = p + k > n ? n : p+k;

        if(start > 1) sb.append("<< ");
        for(int i = start; i <= end; i++)
            sb.append(i == p ? "(" + i + ")" : i).append(" ");
        if(end < n) sb.append(">>");

        return sb.toString();
    }
}


import java.util.Scanner;

public class HocJava {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n,mod=1000000007;
        n=sc.nextLong();
        long res=0;
        long[][] c=new long[4050][4050];
        long[] dp=new long[4050];
        for(int i=0;i<=4000;i++){
            c[i][0]=1;
        }
        for(int i=1;i<=4000;i++){
            for(int j=1;j<=i;j++){
                c[i][j]=(c[i-1][j-1]+c[i][j-1])%mod;
            }
        }
        dp[0]=1;
        for(int i=1;i<n;i++){
            for(int j=0;j<i;j++) dp[i]=(dp[i]+dp[i]*c[i-1][j])%mod;
        }
        for(int i=0;i<n;i++) {
            long g = dp[i]*c[n][i];
            res=(res+g)%mod;
        }
        System.out.println(res);
    }

}


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

public class main {

    public void solve() {
        Scan sn = new Scan();
        long n;
        n = sn.nextLong();
        long temp = (long)Math.sqrt(n);
        for(long i=temp ;i>=1;i--)
        {
            long te = i*i;
            long num = n;
            int count =0;
            String s = String.valueOf(num);
            for(int j=s.length()-1;j>=0;j--){
                long t = te%10;
                if(s.charAt(j)-'0'==t){
                    count++;
                    te = te/10;
                }
            }
            if(count==String.valueOf(i*i).length()){
                System.out.println(String.valueOf(n).length()-count);
/*
                System.out.println(i);
*/
                return;
            }
        }
        System.out.println(-1);
    }

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

    class Scan {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Collection;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.io.IOException;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Objects;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Queue;
import java.util.LinkedList;
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);
        DChocolate solver = new DChocolate();
        solver.solve(1, in, out);
        out.close();
    }

    static class DChocolate {
        private HashMap<Long, Util.Triplet<Long>> hm = new HashMap<>();
        private HashMap<Long, Util.Triplet<Long>> hm2 = new HashMap<>();
        long minDis = Integer.MAX_VALUE;
        private Util.Pair<Long> pair1;
        private Util.Pair<Long> pair2;

        private void bfs(long x, long y) {
            long area = x * y;
            hm.put(area, new Util.Triplet<>(0L, x, y));
            Queue<Util.Pair<Long>> queue = new LinkedList<>();
            queue.offer(new Util.Pair<>(x, y));
            while (!queue.isEmpty()) {
                Util.Pair<Long> P = queue.poll();
                long area1;
                long distance = hm.get(P.x * P.y).x;
                if (P.x % 2 == 0) {
                    area1 = P.y * P.x / 2;
                    queue.offer(new Util.Pair<>((P.x) / 2, P.y));
                    if (hm.containsKey(area1)) {
                        long dis = hm.get(area1).x;
                        if (distance + 1 < dis) {
                            hm.put(area1, new Util.Triplet<>(distance + 1, P.x / 2, P.y));
                        }
                    } else hm.put(area1, new Util.Triplet<>(distance + 1, P.x / 2, P.y));
                }
                if (P.y % 2 == 0) {
                    area1 = P.x * P.y / 2;
                    queue.offer(new Util.Pair<>(P.x, P.y / 2));
                    if (hm.containsKey(area1)) {
                        long dis = hm.get(area1).x;
                        if (distance + 1 < dis) {
                            hm.put(area1, new Util.Triplet<>(distance + 1, P.x, P.y / 2));
                        }
                    } else hm.put(area1, new Util.Triplet<>(distance + 1, P.x, P.y / 2));
                }
                if (P.x % 3 == 0) {
                    area1 = 2 * P.y * P.x / 3;
                    queue.offer(new Util.Pair<>(2 * (P.x) / 3, P.y));
                    if (hm.containsKey(area1)) {
                        long dis = hm.get(area1).x;
                        if (distance + 1 < dis) {
                            hm.put(area1, new Util.Triplet<>(distance + 1, 2 * P.x / 3, P.y));
                        }
                    } else hm.put(area1, new Util.Triplet<>(distance + 1, 2 * P.x / 3, P.y));
                }
                if (P.y % 3 == 0) {
                    area1 = 2 * P.x * P.y / 3;
                    queue.offer(new Util.Pair<>(P.x, 2 * P.y / 3));
                    if (hm.containsKey(area1)) {
                        long dis = hm.get(area1).x;
                        if (distance + 1 < dis) {
                            hm.put(area1, new Util.Triplet<>(distance + 1, P.x, 2 * P.y / 3));
                        }
                    } else hm.put(area1, new Util.Triplet<>(distance + 1, P.x, 2 * P.y / 3));
                }
            }
        }

        private void bfs2(long x, long y) {
            long area = x * y;
            hm2.put(area, new Util.Triplet<>(0L, x, y));
            if (hm.containsKey(area)) {
                if (minDis > hm.get(area).x + hm2.get(area).x) {
                    minDis = hm.get(area).x + hm2.get(area).x;
                    pair1 = new Util.Pair<>(hm.get(area).y, hm.get(area).z);
                    pair2 = new Util.Pair<>(x, y);
                }
            }
            Queue<Util.Pair<Long>> queue = new LinkedList<>();
            queue.offer(new Util.Pair<>(x, y));
            while (!queue.isEmpty()) {
                Util.Pair<Long> P = queue.poll();
                long area1;
                long distance = hm2.get(P.x * P.y).x;
                if (P.x % 2 == 0) {
                    area1 = P.y * P.x / 2;
                    queue.offer(new Util.Pair<>((P.x) >> 1, P.y));
                    if (hm2.containsKey(area1)) {
                        long dis = hm2.get(area1).x;
                        if (distance + 1 < dis) {
                            hm2.put(area1, new Util.Triplet<>(distance + 1, P.x / 2, P.y));
                        }
                    } else hm2.put(area1, new Util.Triplet<>(distance + 1, P.x / 2, P.y));
                    if (hm.containsKey(area1)) {
                        if (minDis > hm.get(area1).x + hm2.get(area1).x) {
                            minDis = hm.get(area1).x + hm2.get(area1).x;
                            pair1 = new Util.Pair<>(hm.get(area1).y, hm.get(area1).z);
                            pair2 = new Util.Pair<>(P.x / 2, P.y);
                        }
                    }

                }
                if (P.y % 2 == 0) {
                    area1 = P.x * P.y / 2;
                    queue.offer(new Util.Pair<>(P.x, P.y / 2));
                    if (hm2.containsKey(area1)) {
                        long dis = hm2.get(area1).x;
                        if (distance + 1 < dis) {
                            hm2.put(area1, new Util.Triplet<>(distance + 1, P.x, P.y / 2));
                        }
                    } else hm2.put(area1, new Util.Triplet<>(distance + 1, P.x, P.y / 2));
                    if (hm.containsKey(area1)) {
                        if (minDis > hm.get(area1).x + hm2.get(area1).x) {
                            minDis = hm.get(area1).x + hm2.get(area1).x;
                            pair1 = new Util.Pair<>(hm.get(area1).y, hm.get(area1).z);
                            pair2 = new Util.Pair<>(P.x, P.y / 2);
                        }
                    }
                }
                if (P.x % 3 == 0) {
                    area1 = 2 * P.y * P.x / 3;
                    queue.offer(new Util.Pair<>(2 * (P.x) / 3, P.y));
                    if (hm2.containsKey(area1)) {
                        long dis = hm2.get(area1).x;
                        if (distance + 1 < dis) {
                            hm2.put(area1, new Util.Triplet<>(distance + 1, 2 * P.x / 3, P.y));
                        }
                    } else hm2.put(area1, new Util.Triplet<>(distance + 1, 2 * P.x / 3, P.y));
                    if (hm.containsKey(area1)) {
                        if (minDis > hm.get(area1).x + hm2.get(area1).x) {
                            minDis = hm.get(area1).x + hm2.get(area1).x;
                            pair1 = new Util.Pair<>(hm.get(area1).y, hm.get(area1).z);
                            pair2 = new Util.Pair<>(2 * P.x / 3, P.y);
                        }
                    }
                }
                if (P.y % 3 == 0) {
                    area1 = 2 * P.x * P.y / 3;
                    queue.offer(new Util.Pair<>(P.x, 2 * P.y / 3));
                    if (hm2.containsKey(area1)) {
                        long dis = hm2.get(area1).x;
                        if (distance + 1 < dis) {
                            hm2.put(area1, new Util.Triplet<>(distance + 1, P.x, 2 * P.y / 3));
                        }
                    } else hm2.put(area1, new Util.Triplet<>(distance + 1, P.x, 2 * P.y / 3));
                    if (hm.containsKey(area1)) {
                        if (minDis > hm.get(area1).x + hm2.get(area1).x) {
                            minDis = hm.get(area1).x + hm2.get(area1).x;
                            pair1 = new Util.Pair<>(hm.get(area1).y, hm.get(area1).z);
                            pair2 = new Util.Pair<>(P.x, 2 * P.y / 3);
                        }
                    }
                }
            }
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long a1 = in.nextLong(), b1 = in.nextLong();
            long a2 = in.nextLong(), b2 = in.nextLong();
            bfs(a1, b1);
            bfs2(a2, b2);
//        out.println(hm.toString());
//        out.println(hm2.toString());
            if (minDis == Integer.MAX_VALUE) out.println(-1);
            else {
                out.println(minDis);
                out.printsc(pair1.x, pair1.y);
                out.println();
                out.printsc(pair2.x, pair2.y);
                out.println();
            }

            out.flush();
        }

    }

    static class Util {
        public static class Pair<T> {
            public T x;
            public T y;

            public Pair(T x, T y) {
                this.x = x;
                this.y = y;
            }

            public boolean equals(Object obj) {
                if (!(obj instanceof Util.Pair)) return false;
                Util.Pair<T> pair = (Util.Pair<T>) obj;
                return this.x.equals(pair.x) && this.y.equals(pair.y);
            }

            public String toString() {
                return ("(" + this.x + "," + this.y + ")");
            }

            public int hashCode() {
                return Objects.hash(x, y);
            }

        }

        public static class Triplet<T> {
            public T x;
            public T y;
            public T z;

            public Triplet(T x, T y, T z) {
                this.x = x;
                this.y = y;
                this.z = z;
            }

            public boolean equals(Object obj) {
                if (!(obj instanceof Util.Triplet)) return false;
                Util.Triplet<T> triplet = (Util.Triplet<T>) obj;
                return this.x.equals(triplet.x) && this.y.equals(triplet.y) && this.z.equals(triplet.z);
            }

            public String toString() {
                return ("(" + this.x + "," + this.y + "," + this.z + ")");
            }

            public int hashCode() {
                return Objects.hash(x, y, z);
            }

        }

    }

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

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

        public InputReader(FileInputStream file) {
            this.stream = file;
        }

        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 = (res << 3) + (res << 1) + c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

    }

    static class OutputWriter {
        private final PrintWriter writer;
        private ArrayList<String> res = new ArrayList<>();
        private StringBuilder sb = new StringBuilder("");

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

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

        public void println(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                sb.append(objects[i]);
            }
            res.add(sb.toString());
            sb = new StringBuilder("");
        }

        public void printsc(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                sb.append(objects[i]).append(' ');
            }
        }

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

        public void flush() {
            for (String str : res) writer.printf("%s\n", str);
            res.clear();
            sb = new StringBuilder("");
        }

    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *cf244b_uln
 * @author zulkan
 */
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;

public class cf244b_uln {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static Scanner sc = new Scanner(System.in);

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        StringBuilder out = new StringBuilder();
        int temp = a;
        while (temp > 0) {
            //out = temp % base + out;
            out.insert(0, temp % base);
            temp /= base;
        }
        return out.toString();
    }

    public static void main(String[] ar) {

        int n = getInt();
        int out = 0;

        if(n <= 100){
            print(n);
            return;
        }

        boolean all[] = new boolean[n + 1];

        for (int i = 0; i < 10; i++) {
            for (int j = i; j < 10; j++) {
                if (i != 0 || j != 0) {
                    ArrayList<Integer> last = new ArrayList<Integer>();
                    last.add(i);
                    last.add(j);
                    all[i] = true;
                    all[j] = true;

                    int ls = j;
                    while (ls < n) {
                        ArrayList<Integer> last2 = new ArrayList<Integer>();
                        for (int ii = 0; ii < last.size(); ii++) {
                            int a = last.get(ii) * 10 + i;
                            int b = last.get(ii) * 10 + j;
                            last2.add(a);
                            last2.add(b);
                            //print(a + " " + b);
                            if (b <= n) {

                                all[b] = true;
                            }
                            if (a <= n) {
                                all[a] = true;
                            }
                            ls = b;
                        }
                       // print(ls + " " + last2);
                        last = last2;

                    }

                }
            }
        }
        for (int i = 1; i <= n; i++) {
            //print(i + " " + all[i]);
            if (all[i]) {
                out++;
            }
        }
        print(out);

    }
}


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

public class A {

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

        String s = in.next();

        String[] aa ={"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"};
        ArrayList <String > al = new ArrayList<>();
        ArrayList <String > al2 = new ArrayList<>();
        for (int i = 0; i < n; i++) {

            if (s.length() == aa[i].length()) {
                al.add(aa[i]);
                al2.add(aa[i]);
            }
        }

        for (int i = 0; i < al.size(); i++) {
            for (int j = 0; j < s.length(); j++) {

                if(s.charAt(j) != '.' && s.charAt(j)!= al.get(i).charAt(j)){

                    al2.remove(al.get(i));

                }
            }
        }

        System.out.println(al2.get(0));

    }
}


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        //sc.nextLine();
        int b = sc.nextInt();
        sc.nextLine();
        int c = a / b;
        int[] arr = new int[a];
        int count = 0;
        for (int i = 0; i < a; i++) {
            arr[i] = sc.nextInt();
        }
        for (int t = 0; t < b; t++) {
            int count1 = 0;
            int count2 = 0;
            int[] arrtemp = new int[c];
            for (int j = 0; j < c; j++) {
                arrtemp[j] = arr[j + c * t];

                if (arrtemp[j] == 1) {
                    count1++;
                } else {
                    count2++;
                }
            }
            System.out.println("");
            if (count1 != 0 || count2 != 0) {
                count += count1 > count2 ? count1 - count2 : count2 - count1;
            }
        }

        System.out.println(count);
    }
}


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

public class Solution{
    public static void main(String args[])
    {
        int size = 0,ans = 0;
        Scanner sc = new Scanner(System.in);
        size = sc.nextInt();
        String num  = sc.next();
        int ones = 0,zeroes = 0;
        for(int i=0;i<size;i++)
        {
            if(num.charAt(i) == '0'):
            {
                zeroes +=1;
            }
            else{
                ones+=1;
            }
        }
        if(zeroes == ones)
        {
            System.out.println(2);
        }
        else
        {
            System.out.println(1);
        }
    }
}


package ;

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

public class kok {
	static long MOD = 1000000007;

	static long fastPower(long a, long b){
		long res = 1;

		while(b > 0){
			if(b % 2 == 0){
				a = (a * a) % MOD;
				b /= 2;
			}else{
				res = (res * a) % MOD;
				b--;
			}
		}

		return res % MOD;

	}

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

		//System.out.println(fastPower(2, 4));

		long year = sc.nextL();

		System.out.println((((fastPower(2, year) + fastPower(4, year)) % MOD) / 2) % MOD);

  }

}

class FastReader {
	public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

    public int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
     public long nextL() throws IOException{
        return Long.parseLong(next());
    }
}


import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static int inf = 1000000000;
    static int mod = (int) 10e9 + 7;

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

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

        int n = in.nextInt();

        int privous = in.nextInt();

        int sum = 0;

        for (int i = 1; i < n; i++) {
            int current = in.nextInt();

            if (privous == 1){
                if (current == 2){
                    sum+=3;
                } else {
                    sum+=4;
                }
            } else if (privous == 2){
                if (current == 1){
                    sum += 3;
                } else {
                    sum = -1;
                    break;
                }
            } else {
                if (current == 1){
                    sum += 4;
                } else {
                    sum = -1;
                    break;
                }
            }

            privous = current;

        }
        System.out.println(sum == -1?"Infinite":"Finite\n" + sum);
        out.close();
    }

    }
}


[7:31 PM, 9/7/2020] College: import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	static class ProblemSolver{
		public void solveTheProblem(InputReader in,PrintWriter out){
			//Take the necessary inputs
			int r=in.nextInt(),c=in.nextInt();

			//To keep track of number of rows and column containing strawberries
			HashSet<Integer> rows,cols;
			rows=new HashSet<Integer>();
			cols=new HashSet<Integer>();

			/*
			 * Calculation to keep track of the nubmer of rows
			 * and columns containing strawberries
			 */
			for(int i=0;i<r;++i){
				String s=in.next();
				for(int j=0;j<c;++j){
					if(s.charAt(j)=='S'){
						rows.add(i);
						cols.add(j);
					}
				}
			}

			/*
			 * Normal mathematics for calculating the number of
			 * rows and column to be traversed
			 */
			out.print(((c-cols.size())r)+((r-rows.size())*c)-((r-rows.size())(c-cols.size())));

		}
	}

	//Default template for all the codes
	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }

	//Template.Main method for all the codes
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
		ProblemSolver problemSolver = new ProblemSolver();
		problemSolver.solveTheProblem(in, out);
		out.close();
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Contest1 {
	public static void main (String[]args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int a = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		int [] in = new int [n];
		for (int i = 0 ; i< n ; i++)
			in[i] = Integer.parseInt(st.nextToken());
		int count = 0 ;
		int idx = a-1;
		for (int i = 0 ; i < =idx ; i++){
			if (i == idx && in[i] == 1) count++;
			else
			if (in[i] == 1&& in[idx+i] == 0) count++;
			else if (in[i] == 1&& in[idx+i] == 1) count+=2;
		}
		for (int i = (idx*2)+1 ; i < n ; i++)
			if (in[i] == 1) count++;
		out.println(count);
		out.flush();
		out.close();

	}
}


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

public class Main {

    public static void main(String[] args) {

        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {

            int n = Integer.parseInt(reader.readLine());
            HashMap<Integer, Integer> dels = new HashMap<>();
            int del = 2;
            if(n == 1) {
                println("1 0");
                return;
            }
            while(n > 1) {
                if(n % del == 0) {
                    if(dels.containsKey(del)) {
                        dels.put(del, dels.get(del) + 1);
                    } else {
                        dels.put(del, 1);
                    }
                    n /= del;
                    //println("here2");
                } else
                    del++;
                //println("here1");
            }
            int minNum = 1;
            long two = 1;
            int b = 0;
            HashSet<Integer> set = new HashSet<>();
            for(int i : dels.keySet()) {
                minNum *= i;
                while(two < dels.get(i)) {
                    two *= 2;
                }
                set.add(two);
                if(dels.get(i) != two)
                    b = 1;
            }
            //println(two);
            int ans = 0;
            while(two > 1) {
                two /= 2;
                ans++;
            }
            int add = 1;
            if(b == 0 || set.size() > 1) add = 0;
            println(minNum + " " + (ans + add));

        } catch (IOException e) {
        }
    }

    static String reverse(String s) {
        String ans = "";
        char[] c = s.toCharArray();
        for(int i = s.length() - 1; i >= 0; i--) {
            ans += c[i];
        }
        return ans;
    }

    static long fac(int deg) {
        long ans = 1;
        for(int i = 2; i <= deg; i++) {
            ans *= i;
        }
        return ans;
    }

    static int r(int a, int b) {
        int ans = a / b;
        if(a % b != 0)
            ans++;
        return ans;
    }

    static void print(Object o) {
        System.out.print(o.toString());
    }

    static void println(Object o) {
        System.out.println(o.toString());
    }
}


import java.util.*;
public class lcm{
        public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long store = 0;
        if(n == 1){
            store = 1;
        }else if(n == 2){
            store = 2
        }
        if(n%2 == 0){
            long = Math.max((n-1)*(n-2)*(n-3),n*(n-1)*(n-2));
        }else{
            long = n*(n-1)*(n-2)
        }
        System.out.println(long);
    }
}


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

import CODEFORCES.Aa.Scanner;
import CODEFORCES.Cc.scanner;

public class contest {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int sum=0;int count=0;
		int i=0;
		for( i=0;i<n;i++) {
			if(isPrime(i)||i==2) {
				count++;
				sum+=i;
			}
			if(sum>=n)break;

		}

		System.out.println(sum<n?count+1:count);

	}
	 private static boolean isPrime(int n) {
	        if (n % 2 == 0)
	            return false;
	        for (int i = 3; i*i <= n; i += 2)
	            if (n % i == 0)
	                return false;
	        return true;
	    }
	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 {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

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


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

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

            int n1 = sc.nextInt();
            int n2 = sc.nextInt();
            int n3 = sc.nextInt();

            int sum1 = n1+n1+n2+n2;
            int sum2 = n1+n2+n3;
            int sum3 = n2+n3+n3+n2;
            int sum4 n1+n1+n3+n3;
            if(sum1 < sum2 && sum1 < sum3 && sum1 < sum4)
            {
                  System.out.println(sum1);
            }

            else if(sum2 < sum1 && sum2 < sum3 && sum2 < sum4)
            {
                  System.out.println(sum2);
            }
            else if(sum3 < sum1 && sum3 < sum2 && sum3 < sum4)
            {
                  System.out.println(sum3);
            }
            else
            {
                 System.out.println(sum4);
            }
      }
}


    import java.io.*;
    public class Solution{
        public static void main(String []args) throws IOException{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str[] = br.readLine().split(" ");
            int N = Integer.parseInt(str[0]);
            int K = Integer.parseInt(str[1]);

            sum = 0;

            for(int i = 1; i <= N; i++ ) {
                sum+=i;
                if(sum-(N-i) == K){
                    System.out.println( N - i );
                    break;
                }
            }
        }
    }


By CKreppein, contest: Codeforces Round #378 (Div. 2), problem: (A) Grasshopper And the String, Accepted, #
 import java.util.Scanner;

public class a {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] split = scan.nextLine().split("[AEIOUY]");
		int max = 1;
		for(int i = 0 ; i < split.length ; i++)max = Math.max(max, split[i].length()+1);
		System.out.println(max);
	}
}


import java.util.InputMismatchException;

import java.io.IOException;
import java.io.PrintWriter;

public class tram {

	/**************Scanner********************/
	static class FastReader {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

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

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

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

		public 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 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 int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

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

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

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

	/************main*************/
	public static void main(String args[]) {

		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		/*******************code***********************/
		int s=scan.nextInt();
		int x1=scan.nextInt();
		int x2=scan.nextInt();
		int t1=scan.nextInt();
		int t2=scan.nextInt();
		int p=scan.nextInt();
		int d=scan.nextInt();
		int tfromx1=0;
		int x1tox2=0;
		if(x1>p)
		{
			if(d==1)
			{
				tfromx1=x1-p;
			}
			else
			{
				tfromx1=p+x1;
			}
		}
		if(x1<p)
		{
			if(d==1)
			{
				tfromx1=s-p+s-x1;
			}
			else
			{
				tfromx1=p-x1;
			}
		}
		if((p<x1&&p<x2&&x1<x2)||(p>x1&&p>x2&&x1>x2))
		{
			x1tox2=Math.abs(x1-x2);
		}
		else if(p>x1&&p<=x2)
		{
			x1tox2=x1+x2;
		}
		else if(p>=x2&&p<x1)
		{
			x1tox2=s-x1+s-x2;
		}
		else if(p<x1&&p<x2&&x2<x1)
		{
			x1tox2=s-x1+s-x2;
		}
		else if(p>x1&&p>x2&&x2>x1)
		{
			x1tox2=x1+x2;
		}
		else if(p==x1&&x1<x2)
		{
			if(d==1)
			{
				x1tox2=Math.abs(x1-x2);
			}
			else
			{
				x1tox2=x1+x2;
			}
		}
		else if(p==x1&&x1>x2)
		{
			if(d==-1)
			{
				x1tox2=Math.abs(x1-x2);
			}
			else
			{
				x1tox2=s-x1+s-x2;
			}
		}
		int temp=Math.min(tfromx1*t1+x1tox2*t1,Math.abs(x1-x2)*t2);
		out.println(temp);
		out.close();

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.StringJoiner;
import java.util.stream.IntStream;

import java.io.PrintWriter;
//import java.util.Arrays;

public class A {

	public static FastScanner fs = new FastScanner();
	public static PrintWriter out = new PrintWriter(System.out);

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

	public static void solve(){
		int n = fs.nextInt(), k = fs.nextLong(), index = 1;
		String S = Long.toBinaryString(k);
		for (int i = S.length()-1; i >= 0; i--){
			if (S.charAt(i) == '1'){
				break;
			}
			index ++;
		}
		out.println(index);
		out.flush();
	}

	static void array_space(int[] A){
		StringJoiner sj = new StringJoiner(" ");
		IntStream.of(A).forEach(x -> sj.add(String.valueOf(x)));
		System.out.println(sj.toString());
	}

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

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.util.Scanner;

public class Main extends Give {

    public static void main(String[] args) {
        int inp,inp11,f,s;
        float inp1;
        Scanner sc=new Scanner(System.in);
        inp=sc.nextInt();
        inp1=((float)inp)/10;

        inp=inp/10;
        inp1=inp1-inp;
        inp1=inp1*10;

        inp11=(int) inp1;

        Give g=new Give() {

            @Override
            int give1(int num) {
              if(num==0||num==9||num==6)
        return 2;
     if(num==2||num==3||num==5)
        return 3;
     if(num==1)
        return 7;
     if(num==4)
        return 4;
     if(num==7)
        return 5;
     else
        return 1;
            }
        };
        f=g.give1(inp);
        s=g.give1(inp11);
        System.out.println(""+(f*s));

    }

    @Override
    int give1(int num) {
       if(num==0||num==9||num==6)
        return 2;
     if(num==2||num==3||num==5)
        return 3;
     if(num==1)
        return 7;
     if(num==4)
        return 4;
     if(num==7)
        return 5;
     else
        return 1;
    }

}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {

	static int k;

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {

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

        	 int a1=in.nextInt();
        	 int a2=in.nextInt();
        	 int a3=in.nextInt();
        	 int a4=in.nextInt();
        	 int b1=in.nextInt();
        	 int b2=in.nextInt();
        	 int b3=in.nextInt();
        	 int b4=in.nextInt();
        	 int c1=in.nextInt();
        	 int c2=in.nextInt();
        	 int c3=in.nextInt();
        	 int c4=in.nextInt();

        	 if(  b1>c3 || b3<c1 || b4<c2 || b2>c4  ) {
        		 if((FindPoint(b1,b2,b3,b4,a1,a2) && FindPoint(b1,b2,b3,b4,a3,a4) && FindPoint(b1,b2,b3,b4,a1,a4) && FindPoint(b1,b2,b3,b4,a3,a2))
        				 || (FindPoint(c1,c2,c3,c4,a1,a2) && FindPoint(c1,c2,c3,c4,a3,a4) && FindPoint(c1,c2,c3,c4,a1,a4)
        						 && FindPoint(c1,c2,c3,c4,a3,a2))){
        			 System.out.println("NO");
        		 }
        		 else {
            		 System.out.println("YES");

        		 }
        	 }
        	 else if((FindPoint(b1,b2,b3,b4,a1,a2) || FindPoint(c1,c2,c3,c4,a1,a2)) && (FindPoint(b1,b2,b3,b4,a3,a4) || FindPoint(c1,c2,c3,c4,a3,a4))
    				 && (FindPoint(b1,b2,b3,b4,a1,a4) || FindPoint(c1,c2,c3,c4,a1,a4)) &&
    				 (FindPoint(b1,b2,b3,b4,a3,a2) || FindPoint(c1,c2,c3,c4,a3,a2))){
        		 System.out.println("NO");
        	 }
        	 else {
        		 System.out.println("YES");
        	 }

        }
        static boolean FindPoint(int x1, int y1, int x2,
                int y2, int x, int y)
		{
		if (x > x1 && x < x2 &&
		y > y1 && y < y2)
		return true;

		return false;
		}
        static int gcd(long a, long a2)
        {
            if (a == 0)
                return (int) a2;
            return gcd(a2 % a, a);
        }

    }

    static class InputReader
    {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            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 sort(Node[] a, int low, int high)
    {
        int N = high - low;
        if (N <= 1)
            return;
        int mid = low + N/2;
        // recursively sort
        sort(a, low, mid);
        sort(a, mid, high);
        // merge two sorted subarrays
        Node[] temp = new Node[N];
        int i = low, j = mid;

        for (int k = 0; k < N; k++)
        {
            if (i == mid)
                temp[k] = a[j++];
            else if (j == high)
                temp[k] = a[i++];
            else if (a[j].data<a[i].data)
                temp[k] = a[j++];
            else
                temp[k] = a[i++];
        }
        for (int k = 0; k < N; k++)
            a[low + k] = temp[k];
    }
}


import java.util.Scanner;
public class Read{
public static void main(String ae[]){
Scanner sb=new Scanner(System.in);
String s= sb.nextLine();
int n=Integer.parseInt(s);
String s1=sb.nextLine();
String f[]=s1.split(" ");
int a[]=new int[7];
int sum=0;
for(int i=0;i<7;i++)
{
a[i]=Integer.parseInt(f[i]);

}

while( sum<n)
                 {
                 for(int i=0;i<7;i++)
                            {sum=sum+a[i];
                            if(sum>=n)
                               break;
                             }
              System.out.println(i+1);
              }
              }
              }


import java.util.Scanner;

public class main {

    public static void main(String[] args)
    {
        try
		{

       Scanner s =new Scanner(System.in);
        long n = s.nextLong();
        long ways=0;
        long basic=2;
        if((n-2)%3==0)
          ways++;

        for(int i=1;i<n;i++)
        {
          if(basic<n)
          {
            basic=basic+(i*3+2);
             if((n-basic)>=0 && (n-basic)%3==0)
              ways++;
          }
        }
        System.out.println(" answer "+ways);
       }
           catch(Exception e)
            System.out.println(e.getMessage());
    }
}


import java.util.Scanner;

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

        long a = r.nextInt();
        long b = r.nextInt();
        long mod = r.nextInt();

        long mul = 1000000000;
        a = Math.min(a, 999999999);
        b = Math.min(b, 999999999);

        if(b >= mod-1){
            System.out.println(2);
            return;
        }

        for(long add = 0; add <= a; add++){
            long number = mul*add;

            if(b < (mod - number % mod)%mod){
                System.out.printf("1 %09d\n", add);
                return;
            }
        }
        System.out.println(2);
    }
}


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

public class MainA {

	public static void main(String args[]){
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		int n=in.nextInt();
		int m=in.nextInt();
		int a[]=new int[n];
		int x[]=new int[101];
		boolean isX[]=new boolean[101];
		for(int i=0;i<n;i++){
			a[i]=in.nextInt();
			isX[a[i]]=true;
		}
		int l[]=new int[m];
		int r[]=new int[m];
		for(int i=0;i<m;i++){
			l[i]=in.nextInt();
			r[i]=in.nextInt();
			for(int j=l[i];j<=r[i];j++){
				if(isX[j] && x[j]==0){
					if(isX[j-1]){
						if(x[j-1]==1){
							x[j]=-1;
						}
						else{
							x[j]=1;
						}
					}
					else{
						x[j]=1;
					}
				}
			}
		}
		for(int i=0;i<n;i++){
			if(x[a[i]]==1)
				out.print("0 ");
			else
				out.print("1 ");
		}
		out.println();
		//-------------THE END-------------------
		out.close();
	}

	static class Pair implements Comparable<Pair>{
		int i;
		int v;
		@Override
		public int compareTo(Pair o) {
			if(o.v>this.v) return -1;
			return 0;
		}

	}
	static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;

	    public InputReader(InputStream inputstream) {
	      reader = new BufferedReader(new InputStreamReader(inputstream));
	      tokenizer = null;
	    }

	    public String nextLine(){
	    	String fullLine=null;
	    	while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	              fullLine=reader.readLine();
	            } catch (IOException e) {
	              throw new RuntimeException(e);
	            }
	            return fullLine;
	          }
	          return fullLine;
	    }
		public String next() {
	      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	        try {
	          tokenizer = new StringTokenizer(reader.readLine());
	        } catch (IOException e) {
	          throw new RuntimeException(e);
	        }
	      }
	      return tokenizer.nextToken();
	    }
		public long nextLong() {
		      return Long.parseLong(next());
		    }
	    public int nextInt() {
	      return Integer.parseInt(next());
	    }
	  }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        String d1 = in.nextLine();
        String d2 = in.nextLine();
        SimpleDateFormat format = new SimpleDateFormat("yyyy:MM:dd");
        Date date1 = null;
        Date date2 = null;
        try {
            date1 = format.parse(d2);
            date2 = format.parse(d1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        long difference = Math.round((double)date1.getTime()/ 24/60/60/1000 - (double)date2.getTime()/ 24/60/60/1000));
        long days = difference ;
        out.println(Math.abs(days));

        in.close();
        out.close();
    }


import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.PriorityQueue;
import java.math.BigInteger;

public class Main{

static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;
static final long LINF=Long.MAX_VALUE/2;

public static void main(String[] args) throws IOException{
int t=ir.nextInt();
int s=ir.nextInt();
int q=ir.nextInt();
int ans=1;
int cur=0;
while(true){
s+=q-1;
cur+=q;
if(s>=t) break;
if(cur>s){
ans++;
s=0;
}
}
out.println(ans);
out.flush();
}

public static BigInteger fact(int n){
BigInteger a=BigInteger.ONE;
for(int i=2;i<=n;i++){
a=a.multiply(BigInteger.valueOf(i));
}
return a;
}

static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;

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

public int readByte() {
if(lenbuf==-1) throw new InputMismatchException();
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}
catch (IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0)
return -1;
}
return buffer[curbuf++];
}

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

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

public String next() {
int b=skip();
StringBuilder sb=new StringBuilder();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}

public int nextInt() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

public long nextLong() {
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}

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


//pakage joney_000[let_me_start]
//codeforces
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
 /******************** Pair class ***********************/

 public class Pair implements Comparable<Pair>{
 public int a;
 public int b;

 public Pair(){
  this.a = 0;
  this.b = 0;

 }
 public Pair(int a,int b , int n , long s){
  this.a = a;
  this.b = b;
 }
 public int compareTo(Pair p){
  if(this.a==p.a){
   return this.b-p.b;
  }
  return this.a-p.a;
 }
 public String toString(){
  return "a="+this.a+" b="+this.b;
 }

}
/******************** Main Class ***********************/

public class C
{
    public static InputStream inputStream = System.in;
    public static OutputStream outputStream = System.out;
    public static FastReader in = new FastReader(inputStream);;
    public static PrintWriter out = new PrintWriter(outputStream);;
    /*
    Overhead
    */
    public static int tempints[] = new int[100005];
    public static long templongs[] = new long[100005];
    public static double tempdoubles[] = new double[100005];
   //public static double tempdoubles[] = new double[11];
    public static char tempchars[] = new char[100005];

    public static void main(String[] args) throws java.lang.Exception
    {
        //let_me_start

        int a = i();int b = i();int p = i();int q = i();
        long v= 1;
        long x = 0;
        long y= 0;
        long l = 1;
        long r = 100000000000000000L;

        long z= 0;
        while (l <= r)
        {
         long m = (l + r) / 2;
         v=m;
         x= v-(v/p);
         y =v-v/q;
         z= v-v/p-v/q+v/(p*q);

          //z= v-(v/g);
        //If the search key on the left half
        if (x>a&&y>b&&x+y-z>a+b)
        {
            //Update right index
            r = m - 1;
        }
        //If the search key on the right half
        else if (x<a||y<b||x+y-z<a+b)
        {
            //Update the left index
            l = m + 1;
        }
        //We found the key
        else
        {
            v= m;
            break;
        }
    }
        out.write(""+v);
          out.flush();

}

//****************************** Utilities ***********************//
 public static boolean isPrime(long n)throws Exception{
  if(n==1)return false;
  if(n<=3)return true;
  if(n%2==0)return false;
  for(int i=2 ;i <= Math.sqrt(n); i++){
   if(n%i==0)return false;
  }
  return true;
 }
 // sieve
 public static int[] primes(int n)throws Exception{       // for(int i=1;i<=arr.length-1;i++)out.write(""+arr[i]+" ");
  boolean arr[] = new boolean[n+1];
  Arrays.fill(arr,true);
  for(int i=1;i<=Math.sqrt(n);i++){
    if(!arr[i])continue;
    for(int j = 2*i ;j<=n;j+=i){
        arr[i]=false;
    }
  }
  LinkedList<Integer> ll = new LinkedList<Integer>();
  for(int i=1;i<=n;i++){
   if(arr[i])ll.add(i);
  }
  n = ll.size();

  int primes[] = new int[n+1];
  for(int i=1;i<=n;i++){
    primes[i]=ll.removeFirst();
  }
  return primes;
 }
 public static long gcd (long a , long b)throws Exception{
  if(b==0)return a;
  return gcd(b , a%b);
 }
 public static long lcm (long a , long b)throws Exception{
  if(a==0||b==0)return 0;
  return (a*b)/gcd(a,b);
 }
 public static long mulmod(long a , long b ,long mod)throws Exception{
   if(a==0||b==0)return 0;
   if(b==1)return a;
   long ans = mulmod(a,b/2,mod);
   ans = (ans*2)% mod;
   if(b%2==1)ans = (a + ans)% mod;
   return ans;
 }
 public static long pow(long a , long b ,long mod)throws Exception{
   if(b==0)return 1;
   if(b==1)return a;
   long ans = pow(a,b/2,mod);
   ans = (ans * ans)% mod;
   if(b%2==1)ans = (a * ans)% mod;
   return ans;
 }
 // 20*20   nCr Pascal Table
 public static long[][] ncrTable()throws Exception{
  long ncr[][] = new long[21][21];
  for(int i=0 ;i<=20 ;i++){ncr[i][0]=1;ncr[i][i]=1;}
  for(int j=0;j<=20 ;j++){
   for(int i=j+1;i<= 20 ;i++){
    ncr[i][j] = ncr[i-1][j]+ncr[i-1][j-1];
   }
  }
  return ncr;
 }
//*******************************I/O******************************//
public static int i()throws Exception{
 //return Integer.parseInt(br.readLine().trim());
 return in.nextInt();
}
public static int[] is(int n)throws Exception{
  //int arr[] = new int[n+1];
  for(int i=1 ; i <= n ;i++)tempints[i] = in.nextInt();
 return tempints;
}
public static long l()throws Exception{
 return in.nextLong();
}
public static long[] ls(int n)throws Exception{
  //long arr[] = new long[n+1];
  for(int i=1 ; i <= n ;i++)templongs[i] = in.nextLong();
 return templongs;
}

public static double d()throws Exception{
 return in.nextDouble();
}
public static double[] ds(int n)throws Exception{
  //double arr[] = new double[n+1];
  for(int i=1 ; i <= n ;i++)tempdoubles[i] = in.nextDouble();
 return tempdoubles;
}
public static char c()throws Exception{
 return in.nextCharacter();
}
public static char[] cs(int n)throws Exception{
  //double arr[] = new double[n+1];
  for(int i=1 ; i <= n ;i++)tempchars[i] = in.nextCharacter();
 return tempchars;
}
public static String s()throws Exception{
 return in.nextLine();
}
public static BigInteger bi()throws Exception{
 return in.nextBigInteger();
}
//***********************I/O ENDS ***********************//
//*********************** 0.3%f [precision]***********************//
/* roundoff upto 2 digits
   double roundOff = Math.round(a * 100.0) / 100.0;
                    or
   System.out.printf("%.2f", val);

*/
/* print upto 2 digits after decimal
  val = ((long)(val * 100.0))/100.0;

*/
}

class FastReader{

    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private 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 peek(){
        if (numChars == -1){
            return -1;
        }
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read (buf);
            } catch (IOException e){
                return -1;
            }
            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==','){
                c = read();
            }
            if (c < '0' || c > '9'){
                throw new InputMismatchException ();
            }
            res *= 10;
            res += c - '0';
            c = read ();
        } while (!isSpaceChar (c));
        return res * sgn;
    }

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

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

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

    private String readLine0(){
        StringBuilder buf = new StringBuilder ();
        int c = read ();
        while (c != '\n' && c != -1){
            if (c != '\r'){
                buf.appendCodePoint (c);
            }
            c = read ();
        }
        return buf.toString ();
    }

    public String nextLine(){
        String s = readLine0 ();
        while (s.trim ().length () == 0)
            s = readLine0 ();
        return s;
    }

    public String nextLine(boolean ignoreEmptyLines){
        if (ignoreEmptyLines){
            return nextLine ();
        }else{
            return readLine0 ();
        }
    }

    public BigInteger nextBigInteger(){
        try{
            return new BigInteger (nextString ());
        } catch (NumberFormatException e){
            throw new InputMismatchException ();
        }
    }

    public char nextCharacter(){
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        return (char) c;
    }

    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 boolean isExhausted(){
        int value;
        while (isSpaceChar (value = peek ()) && value != -1)
            read ();
        return value == -1;
    }

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

    public SpaceCharFilter getFilter(){
        return filter;
    }

    public void setFilter(SpaceCharFilter filter){
        this.filter = filter;
    }

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


import java.util.Scanner;
import java.util.Vector;

public class Modular_Equation_49B {
    public static void main(String[] args) {
        long a,b;
        Scanner sc=new Scanner(System.in);
        a=sc.nextLong();
        b=sc.nextLong();
        long p=a-b;
        Vector<Long>vr=new Vector<>();
        //int arr2[]=new int[p];
        if (a==b){
            System.out.println("infinity");
        }
        else {
            for (long i = b; i <= p; i++) {
                if (p % i ==0 && i>b) {
                  vr.add(i);
                }
            }
            System.out.println(vr.size());
        }

    }
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
            ArrayList<Integer> al =new ArrayList<>();
            String s=sc.next();int j=0;int x=0;
            for(int i=0;i<s.length();i=j)
             {
                 j=i;int count=0;
                 char c=s.charAt(i);
                  while(c==s.charAt(j) && count<=5 && j<s.length())
                  {
                      count++;
                      j++;
                  }

                  x++;
             }
             System.out.println(x);
	}
}


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

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

             String s = sc.next();
             int count = 0;
             for(int i = 0;i < s.length(); i++){
                 if(s.charAt(i) != '1' || s.charAt(i) != '4' || count > 2){
                     System.out.println("NO");
                       return
                 }

                    if(s.charAt(i) == '4'){
                        count++;
                    }else{
                       count = 0;
                    }
                 }

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


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

public class ASwimmingPool {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        PrintWriter out = new PrintWriter(System.out, true);

        try {
            int n_vert = Integer.parseInt(br.readLine());
        }
        catch (IOException e) {
            System.err.println(e);

        }

/*        int[][] verts = new int[n_vert][2];

        for (int i=0; i <n_vert, i++) {
            verts[i][0] = sc.nextint();
            verts[i][1] = sc.nextint();
        }

        for (int[] v: verts) {
            system.out.println(v.tostring());
        } */

        System.out.println(n_vert);
    }
}


import java.util.*;

public class Solution{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] ans = new String[4];
        ans[0] = "A";
        ans[1] = "B";
        ans[2] = "C";
        ans[3] = "D";
        int flag = 0;
        String[] s = new String()[4];
        for(int i=0;i<s.length;i++){
            s[i] = sc.nextLine();
        }
        for(int i=0;i<s.length;i++){
            int n = s[i].length();
            int count_more = 0, count_less = 0;
            for(int j=0;j<s.length;j++){
                if(i==j)
                continue;
                if(s[j].length>=2*n)
                    count_more++;
                if(s[j].length<=(n/2))
                    count_less++;
            }
            if(count_more == s.length-1 || count_less == s.length-1)
            {
                System.out.println(ans[i]);
                flag = 1;
                break;
            }
        }
        if(flag==0)
            System.out.println("C");
    }
}


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

public class Dp {

    public static void main(String args[]) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        while (t-- > 0) {
            long l = in.nextLong();
            long r = in.nextLong();
            out.println(fuc(r) - fuc(l - 1));
        }
        out.close();
    }

    static long fuc(long r) {
        long val[] = new long[18];
        val[1] = 9;
        val[2] = 9;
        for (int i = 3; i < 18; i++) {
            val[i] = val[i - 1] * 10;
        }
        int dig = 0;
        long rr = r;
        ArrayList<Integer> aa = new ArrayList<Integer>();
        while (rr > 0) {
            dig++;
            aa.add((int) (rr % 10));
            rr = rr / 10;
        }
        if (dig <= 1) return r;
        long ans = 0;
        for (int i = 0; i < dig; i++) {
            ans += val[i];
        }
        int i = 0;
        int j = aa.size() - 1;
        Collections.reverse(aa);
        long curr = 0;

        curr = curr + (aa.get(i) - 1) * cal(aa, i + 1, j, 1, 0);
        curr = curr + cal(aa, i + 1, j, 0, aa.get(i));

        return ans + curr;
    }

    static long vc;

    static long cal(ArrayList<Integer> aa, int i, int j, int kk, long vv) {
        if (i == j) {
            if (vv <= aa.get(j))
                return 1L;
            else {
                return 0;
            }
        }
        long curr = 0;
        if (kk == 1) {
            curr = curr + 10 * cal(aa, i + 1, j, kk, vv);
        } else {
            curr = curr + (aa.get(i)) * cal(aa, i + 1, j, 1, 0);
            curr = curr + cal(aa, i + 1, j, 0, vv);
        }
        return curr;
    }

    static int top[];
    static int curr = 0;
    static int visited[];
    static ArrayList<Integer> adj[];

    static void dfs(int i) {
        if (visited[i] == 0) {
            visited[i] = 1;
            for (int j : adj[i]) {
                dfs(j);
            }
            top[curr] = i;
            curr++;
        }
    }

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

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

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

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

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

        public 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.util.*;
public class Solution{
static long number;
static long answer;

public static void main(String[] args){
Scanner sc = new Scanner(System.in);
number = sc.nextInt();
answer = -1;
findNumber(0, 0, 0);
System.out.print(answer);

}
static void findNumber(long num, int fours, int sevens){
if (num > 1000000000){
return;}
if(num >= number && fours == sevens){
if(answer==-1){
amswer = num;
}
else{
answer = Math.min(num, answer);}
}
findNumber(num*10 + 4, fours + 1, sevens);
findNumber(num*10 + 7, fours, sevens + 1);

}

}


mport java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.*;

public class Skateboard {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt(), b = input.nextInt(), p = input.nextInt();
		int bottles = 0, towels = n*p;
		while(n > 1) {
			int k = (int) Math.pow(2, log2(n));
			bottles += b*k + (k/2);
			n -= (k/2);
		}
		System.out.println(bottles + " " + towels);
		input.close();

	}
	public static int log2(int num) {
		return 31 - Integer.numberOfLeadingZeros(num);
	}

}


import java.util.*;
public class Beautiful
{
   public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String S=sc.nextLine();
    String number="";
    int l=S.length();
    for(int i=0;i<l-1;++)
    {
        char ch =S.charAt(i);
        char ch1=S.charAt(i+1);
        if(ch==ch1&&ch=='-')
         number+='2';
        else if(ch=='.'&&ch1=='-')
         number+='1';
        else
         number+='0';
    }
    System.out.println(number);
}
}


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

public class Solution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Integer n = scanner.nextInt();
        int ans = 0;
        scanner.useDelimiter("");
        char old = ' ';
        boolean prev = false;
        for (int i = 0; i < n; i++) {
            if (now != old && !prev){
                ans --;
                prev = true;
            }
            else{
                prev = false;
            }
            old = now;
            ans++;

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


public class Alyona {
    public static void main(String[] args) throws IOException{
        Scanner input=new Scanner(System.in);
        int n1=input.nextInt();
        int n2=input.nextInt();
        int counter=0;
        while(n1!=0 && n2!=0){
            if(counter%2==0){
                n1--;
            }
            else{
                n2--;
            }
            counter++;
        }
        if(n1==0){
            out.println("Second");
        }
        else{
            out.println("First");
        }
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication5;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.*;
//import javax.swing.JOptionPane;
//import javax.swing.JFrame;
import javax.swing.*;
import java.util.Scanner;
import javax.swing.JFileChooser;
/**
 *
 * @author Tasneem
 */
public class JavaApplication5 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
        String s;
        boolean [][]arr=new boolean[4][4];
        for(int i=0;i<4;i++)
        {
            s=input.nextLine();
            char []c=s.toCharArray();
            for(int y=0;y<4;y++)
            {
                //c=input.nextChar();
                if(c[y]=='#')
                {
                    arr[i][y]=true;
                }
            }
        }
        int x=1,x1,x2,x3;
        boolean flag=true;
        for(int i=0;i<3&&flag;i++)
        {
            for(int y=0;y<3&&flag;y++)
            {
                 x=(arr[i][y])? 1:0;
                 x1=(arr[i + 1][y])?1:0;
                 x2=(arr[i][y + 1])?1:0;
                 x3=(arr[i + 1][y + 1])?1:0;
                //System.out.println(x);
                 if(x+x1+x2+x3!=2)
                 {
                     flag=false;
                     System.out.println("YES");
                     System.exit(0);
                     return;
                 }
            }
        }
        if(flag)
        {System.out.println("NO");}
        return;
        System.exit(0);
    }
    }


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

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		BigInteger k = in.nextBigInteger();
		BigInteger b = in.nextBigInteger();
		int n = in.nextInt();
		BigInteger t = in.nextBigInteger();

		BigInteger f[] = new BigInteger[n+1];
		f[0] = BigInteger.ONE;
		BigInteger cur = BigInteger.ONE;
		for(int i=1;i<=n;i++){
			cur = cur.multiply(k);
			f[i] = f[i-1].add(cur);
		}

		BigInteger z = cur.add(b.multiply(f[n-1]));
		cur = BigInteger.ONE;
		for(int i=0;i<=n;i++){
			BigInteger c;
			if (i > 0){
				c = cur.multiply(t).add(b.multiply(f[i-1]));
			}else{
				c = t;
			}
			if (c.compareTo(z) >= 0){
				System.out.println(i);
				return;
			}
			cur = cur.multiply(k);
		}
	}
}


public class HelloWorld{

     public static void main(String []args){
         Scanner file = new Scanner(System.in);
        int times = file.nextInt();
        String s = file.next();
        boolean b = true;
        for (int i = 0; i < times - 1; i++) {
            if (s.charAt(i) == '1' && s.charAt(i + 1) == '1') {
                b = false;
                break;
            }
        }
        int count = 0;
        for (int i = 0; i < times; i++) {
            if (s.charAt(i) == '0') {
                count++;
            }
            if (count >= 3) {
                b = false;
                break;
            }
        }
        System.out.println(b ? "Yes" : "No");
     }
}