// Developer: Srinidhi Krishnamurthy
// Codeforces Handle: @SrinidhiK
// Organization: TJHSST
// Twitter Handle: @datechnoguru

import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class A {
	    public static void main(String[] args) throws Exception {
	        //BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	        Scanner scan = new Scanner(System.in);
	        // PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
	        //n = Integer.parseInt(bf.readLine());
			// StringTokenizer st = new StringTokenizer(bf.readLine());
	        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
	        // int n = Integer.parseInt(st.nextToken());
	        int n = scan.nextInt();
	        String[] ar = new String[]{"O-|-OOOO","O-|O-OOO","O-|OO-OO","O-|OOO-O","O-|OOOO-","-O|-OOOO","-O|O-OOO","-O|OO-OO","-O|OOO-O","-O|OOOO-"};	        if (n==0){
	        	System.out.println(ar[0]);
	        }
	        while (n>0){
	        	System.out.println(ar[n%10]);
	        	n /= 10;
	        }

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


import java.io.*;
public class AboutBacteria {
	public static void main(String[] args) throws IOException {
		BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
		String[] temp = buff.readLine().split(" ");
		int k = Integer.parseInt(temp[0]);
		int b = Integer.parseInt(temp[1]);
		int n = Integer.parseInt(temp[2]);
		int t = Integer.parseInt(temp[3]);
		System.out.println(getTime(k, b, n, t));
	}
	public static int getTime(int k, int b, int n, int t) {
		int ans = 0;
		long x = 1;
		while (x < t && ans < n){
			x = k*x +b;
			ans++;
		}
		if (x > t)
			ans--;
		return n - ans;
	}
}


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

public class Main {

    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException {
        int[] a = new int[4];
        a[0] = in.nextInt();
        a[1] = in.nextInt();
        a[2] = in.nextInt();
        a[3] = in.nextInt();
        Arrays.sort(a);
        if (a[3] > a[1] + a[2] && a[2] > a[1] + a[0]) {
            out.println("IMPOSSIBLE");
            return;
        }
        if (a[3] < a[1] + a[2] || a[2] < a[1] + a[0]) {
            out.println("TRIANGLE");
            return;
        }
        out.println("SEGMENT");
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            solve();
            out.close();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                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());
        }
    }

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


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

public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int f=0;
		for(int i=0;i<8;i++)
		{
			String s=in.next();
			in.nextLine();
			for(int j=0;j<7;j++)
			{
				if(s.charAt(j)==s.charAt(j+1))
				{
					f++;
				}
			}
		}
		if(f==0)
		System.out.println("YES");
		else
		System.out.println("NO");
	}
}


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

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

	void main() {
		int r = sc.nextInt();
		if (r < 1200)
			r = 1200;
		else if (r < 1400)
			r = 1400;
		else if (r < 1600)
			r = 1600;
		else if (r < 1900)
			r = 1900;
		else if (r < 2100)
			r = 2100;
		else if (r < 2300)
			r = 2300;
		else if (r < 2400)
			r = 2400;
		else if (r < 2600)
			r = 2600;
		else
			r = 3000;
		println(r);
	}
}


/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

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

        long N = sc.nextLong();
        long M = sc.nextLong();
        long L = sc.nextLong();
        long R = sc.nextLong();

        long E = (R - L + 1) / 2 + (R % 2 == 0 && L % 2 == 0 ? 1 : 0);
        long O = (R - L + 1) - E;
        // Key thing to observe: if we have any valid starting position
        // with an EVEN number of ODD-heighted blocks, then it'll be possible.
        /** actually, it's more subtle than that. You need to just have everything
         * be the SAME at the end. This means an even number of AT LEAST ONE of them
         * will allow for a solution. All that matters is that everything is
         * neutralized into the other type, so if one of them has even count, then
         * we turn it all into the other. However, if NM is even, then the odd odd case fails
         */
        // Basically, we notice that we can flip any pair of OE blocks, and
        // then in this way we can move any odd blocks together, then flip those
        // OO into an EE pair. So, the starting position just needs an even number
        // of odd blocks for this invariant of the same parity of number of ODD
        // blocks to be satisfied

        // This can be visualized as the generating function (E+O)^(NM)
        // since this illustrates the distribution of ways to make each of the NM cells
        // However, we only want the O^(2k) terms for all k. So, we use
        // the trick of adding it to (E-O)^(NM), since all odd terms will cancel
        // Then, we divide by 2, and we have the total answer!
        long ans;
        if (N * M % 2 == 1) {
            ans = fastExpo(E + O, N * M);
        }
        else {
            ans = (fastExpo(E + O, N * M) + fastExpo(E - O, N * M)) % mod;
            ans = (ans * modInv(2)) % mod; // divide by 2 now
        }
        out.println(ans);
        out.close();
    }

    static long mod = 998244353;

    static long modInv(long x) {
        return fastExpo(x, mod - 2);
    }

    static long fastExpo(long x, long k) {
        if (k == 0) {
            return 1;
        }
        else if (k == 1) {
            return x;
        }
        else {
            long root = fastExpo(x, k / 2);
            long ans = (root * root) % mod;
            if (k % 2 == 1) {
                ans = (ans * x) % mod;
            }
            return ans;
        }
    }

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

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

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

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

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

        public int[] nextInts(int N, int dx) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong() + dx;
            }
            return res;
        }

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

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

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

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

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

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


//Coins
import java.io.*;
import java.util.*;
public class Coins{
static int t,n;
static int[] arr;
static ArrayList<String> list=new ArrayList<>();
static StringBuilder ans=new StringBuilder();
static void  solve(){
	int[] count=new int[3];
	for(int i=0;i<3;i++){
		String str=list.get(i);
		if(str.charAt(1)=='<'){count[str.charAt(2)-'A']++;}
		else{count[str.charAt(0)-'A']++;}
	}
	if(count[0]==1&&count[1]==1&&count[2]==1){
		ans.append("Impossible");
		return;
	}
	for(int i=0;i<3;i++){
		if(count[i]==0){ans.append((char)(i+65));}
	}
	for(int i=0;i<3;i++){
		if(count[i]==1){ans.append((char)(i+65));}
	}
	for(int i=0;i<3;i++){
		if(count[i]==2){ans.append((char)(i+65));}
	}

}
public static void main(String[] args) throws IOException{
		// BufferedReader br = new BufferedReader(new
  //      FileReader("sampleinp.txt"));
    	BufferedReader br = new BufferedReader(
                             new InputStreamReader(System.in));

	   for(int i=1;i<=3;i++){
	   		String str=br.readLine();
	   		list.add(str);
	    }
	    solve();
		System.out.println(ans.toString());

    }
}


import java.lang.*;
import java.util.*;
import java.io.*;
public class fraction
{

  Scanner sc=new Scanner(System.in);
  PrintWriter pr=new PrintWriter(System.out,true);
  public static void main(String... args)
  {
       fraction c=new fraction();
       c.prop();
  }
  public void prop()
  {
    int n,a=0,b=0;
    n=sc.nextInt();
     for (int i=n/2;i>=1 ;--i) {
        a=i ;
        b=n-i ;
         if(a>=b)
           continue ;
       b=gcd(a,b);
        if(b==1)
        {
          b=n-i ;
          break ;
        }

     }
      pr.println(a+" "+b);
  }
  public int gcd(int a,int b)
  {
     if(a%b==0)
       return b ;
     return gcd(b,a%b);
  }
}


import java.io.IOException;
import java.util.NoSuchElementException;

public class Main{

	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		long w1 =sc.nextLong();
		long h1 =sc.nextLong();
		long w2 =sc.nextLong();
		long h2 =sc.nextLong();
		if(w1==w2){
			System.out.println((w1+2) * (h1+h2+2) - w1 * (h1+h2));
		}else{
			System.out.println((w1+2) * (h1+h2+2) - w1 * (h1+h2));
		}
	}

}

class FastScanner {
    private final java.io.InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}


import java.io.*;

public class Task689A {

    private static int _numberCount;

    private static int[] _numbers;

    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            _numberCount = Integer.parseInt(in.readLine());
            _numbers = new int[_numberCount];
            String line = in.readLine();
            for (int i = 0; i < _numberCount; i++) {
                _numbers[i] = Integer.parseInt(String.valueOf(line.charAt(i)));
            }
            in.close();
            String result = getResult();
            PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
            out.print(result);
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static String getResult() {
        if (_numberCount == 1) {
            return "NO";
        }
        VectorCustom[] vectors = getVectors();
        boolean unique = testMultipleCombinations(vectors);
        if (unique) {
            return "YES";
        }
        return "NO";
    }

    private static boolean testMultipleCombinations(VectorCustom[] vectors) {
        int successCount = 0;
        for (int i = 0; i < 10; i++) {
            boolean success = true;
            int cursorX = getButtonXCoord(i);
            int cursorY = getButtonYCoord(i);
            for (VectorCustom vector : vectors) {
                cursorX += vector.getX();
                cursorY += vector.getY();
                if (!checkFingerInRange(cursorX, cursorY)) {
                    success = false;
                    break;
                }
            }
            if (success) {
                successCount++;
            }
        }
        return successCount == 1;
    }

    private static boolean checkFingerInRange(int cursorX, int cursorY) {
        if (cursorY == 4) {
            return cursorX == 2;
        }
        boolean xOk = (cursorX >= 1 && cursorX <= 3);
        boolean yOk = (cursorY >= 1 && cursorY <= 3);
        return xOk && yOk;
    }

    private static VectorCustom[] getVectors() {
        VectorCustom[] result = new VectorCustom[_numberCount - 1];
        for (int i = 0; i < _numberCount - 1; i++) {
            int x1 = getButtonXCoord(_numbers[i]);
            int x2 = getButtonXCoord(_numbers[i + 1]);
            int xVect = x2 - x1;

            int y1 = getButtonYCoord(_numbers[i]);
            int y2 = getButtonYCoord(_numbers[i + 1]);
            int yVect = y2 - y1;
            result[i] = new VectorCustom(xVect, yVect);
        }
        return result;
    }

    private static int getButtonXCoord(int number) {
        if (number == 0) {
            return 2;
        } else {
            if (number % 3 == 0) {
                return 3;
            } else {
                return number % 3;
            }
        }
    }

    private static int getButtonYCoord(int number) {
        if (number == 0) {
            return 4;
        } else {
            if (number % 3 == 0) {
                return number / 3;
            }
            return (int) (Math.floor(((double) number) / 3) + 1);
        }
    }

    private static class VectorCustom {
        private int x;
        private int y;

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

        int getX() {
            return x;
        }

        int getY() {
            return y;
        }

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

}


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

import static java.lang.Math.*;

// Solution is at the bottom of code

public class ProblemC_010 implements Runnable{

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

	BufferedReader in;
	OutputWriter out;
	StringTokenizer tok = new StringTokenizer("");

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

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

	void init() throws FileNotFoundException{
		Locale.setDefault(Locale.US);

		if (ONLINE_JUDGE){
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new OutputWriter(System.out);
		}else{
			in = new BufferedReader(new FileReader("input.txt"));
			out = new OutputWriter("output.txt");
		}
	}

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

	long timeBegin, timeEnd;

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

	void debug(Object... objects){
		if (ONLINE_JUDGE){
			for (Object o: objects){
				System.err.println(o.toString());
			}
		}
	}

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

	public void run(){
		try{
			timeBegin = System.currentTimeMillis();
			Locale.setDefault(Locale.US);

			init();
			solve();

			out.close();
			time();
		}catch (Exception e){
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}

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

	String delim = " ";

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

		return tok.nextToken(delim);
	}

	String readLine() throws IOException{
		return in.readLine();
	}

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

	final char NOT_A_SYMBOL = '\0';

	char readChar() throws IOException{
		int intValue = in.read();

		if (intValue == -1){
			return NOT_A_SYMBOL;
		}

		return (char) intValue;
	}

	char[] readCharArray() throws IOException{
		return readLine().toCharArray();
	}

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

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

	int[] readIntArray(int size) throws IOException{
		int[] array = new int[size];

		for (int index = 0; index < size; ++index){
			array[index] = readInt();
		}

		return array;
	}

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

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

	long[] readLongArray(int size) throws IOException{
		long[] array = new long[size];

		for (int index = 0; index < size; ++index){
			array[index] = readLong();
		}

		return array;
	}

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

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

	double[] readDoubleArray(int size) throws IOException{
		double[] array = new double[size];

		for (int index = 0; index < size; ++index){
			array[index] = readDouble();
		}

		return array;
	}

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

	Point readPoint() throws IOException{
		return new Point(readInt(), readInt());
	}

	Point[] readPointArray(int size) throws IOException{
		Point[] array = new Point[size];

		for (int index = 0; index < size; ++index){
			array[index] = readPoint();
		}

		return array;
	}

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

	List<Integer>[] readGraph(int vertexNumber, int edgeNumber)
	throws IOException{
		List<Integer>[] graph = new List[vertexNumber];

		for (int index = 0; index < vertexNumber; ++index){
			graph[index] = new ArrayList<Integer>();
		}

		while (edgeNumber-- > 0){
			int from = readInt() - 1;
			int to = readInt() - 1;

			graph[from].add(to);
			graph[to].add(from);
		}

		return graph;
	}

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

	class OutputWriter extends PrintWriter{

		final int DEFAULT_PRECISION = 12;

		int precision;
		String format, formatWithSpace;

		{
			precision = DEFAULT_PRECISION;

			format = createFormat(precision);
			formatWithSpace = format + " ";
		}

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

		public OutputWriter(String fileName) throws FileNotFoundException {
			super(fileName);
		}

		public int getPrecision() {
			return precision;
		}

		public void setPrecision(int precision) {
			this.precision = precision;

			format = createFormat(precision);
			formatWithSpace = format + " ";
		}

		private String createFormat(int precision){
			return "%." + precision + "f";
		}

		@Override
		public void print(double d){
			printf(format, d);
		}

		public void printWithSpace(double d){
			printf(formatWithSpace, d);
		}

		public void printAll(double...d){
			for (int i = 0; i < d.length - 1; ++i){
				printWithSpace(d[i]);
			}

			print(d[d.length - 1]);
		}

		@Override
		public void println(double d){
			printlnAll(d);
		}

		public void printlnAll(double... d){
			printAll(d);
			println();
		}
	}

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

	int[][] steps = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

	boolean check(int index, int lim){
		return (0 <= index && index < lim);
	}

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

	void solve() throws IOException{
		int n = readInt();

		long[] count = new long[10];
		for (int i = 1; i <= 9; ++i){
			count[i] = count(i, n);
		}

		int[][] d = new int[10][10];
		for (int i = 1; i <= 9; ++i){
			for (int j = 1; j <= 9; ++j){
				d[i][j] = (i * j) % 9;
				if (d[i][j] == 0) d[i][j] = 9;
			}
		}

		long ans = 0;
		for (int a = 1, s = 1; a <= n; ++a, s = (s == 9? 1: s + 1)){
			int k = n / a;

			for (int b = 1; b <= 9; ++b){
				int c = d[s][b];

				long res = count[b] * count[c] - count(b, k);

//				long resStress = stress(a, b, c, n);

//				if (res != resStress){
//					System.err.println(a + " " + b + " " + res + " " + resStress);
//				}

				ans += res;
			}
		}

		out.println(ans);
	}

	int d(int x){
		int res = x % 9;

		return (res == 0? 9: res);
	}

	long count(int d, int n){
		long res = n / 9;

		int md = n % 9;
		if (md > 0 && md >= d) ++res;

		return res;
	}

	long stress(int a, int b, int c, int n){
		long res = 0;

		for (int i = b; i <= n; i += 9){
			for (int j = c; j <= n; j += 9){
				if (a * i != j){
					++res;
				}
			}
		}

		return res;
	}
}


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

public class Main {
	boolean eof;

	public String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "-1";
			}
		}
		return st.nextToken();
	}

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

	void solve() {
		String s = nextToken();
		int ans = 0;
		char last = ' ';
		int kol = 0;

		for (int i = 0; i < s.length(); ++i){
			char c = s.charAt(i);
			if (c == last){

				if (kol == 5){
					++ans;
					kol = 0;
				}
				++kol;
			} else {
				++ans;
				last = c;
				kol = 1;
			}
		}
		out.print(ans);
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));

			//br= new BufferedReader(new FileReader("input.txt"));
			//out = new PrintWriter(new FileWriter("output.txt"));
			solve();
			br.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import static java.util.Collections.reverseOrder;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

/**
 *
 * @author Ahmed_Naser
 */
public class HelloWorld {

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

        int matchboxes[] = new int[m];
        int matches[]= new int[m];

        for(int i = 0 ; i < m ; i++)
        {
            matchboxes[i] =in.nextInt();
            matches[i] = in.nextInt();
        }

        int max = matches[0];
        int index = 0 ;
        int count = 0 ;
        while( n > 0)
        {

           for( int j = 0 ; j < m ; ++j)
        {
            if( matches[j] >= max)
            {
                max= matches[j];
                index = j;

            }
        }
           if(  matchboxes[index] <= n)
           {
               n = n - matchboxes[index];
               count = count + (matches[index] * matchboxes[index] );
               matches[index] = 0 ;
           }
           else
           {

               count = count + (n * matches[index]);
               n = 0 ;
           }
           max = matches[0];
        }

        System.out.println(count);

    }
}


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

public class Main {
/*

 */
	public static void main(String[] args) throws Exception {
		uu.s1();
	}
	public static class uu {
		public static BR in = new BR();
		public static boolean bg = true;
		public static void s1() throws Exception {
			int n1 = in.ni();
			int n2 = in.ni();
			int t = in.ni();
			BigInteger fin = bi(0);
			for (int i = 4;i<=t-1;i++){
				BigInteger q1 = Comb.combination(n1, i);
				BigInteger q2 = Comb.combination(n2, t-i);
				BigInteger q3 = q1.multiply(q2);
				fin = fin.add(q3);
			}
			pn(fin);
		}
		public static void s2() throws Exception {
		}
		public static void s3() throws Exception {

		}
		private static BigInteger bi(long n1) {
			return BigInteger.valueOf(n1);
		}

		private static void pn(Object o1) {
			System.out.println(o1);
		}

		public static boolean allTrue(boolean ... l1){
			for (boolean e: l1) if (!e) return false;
			return true;
		}
		public static boolean allFalse(boolean ... l1){
			for (boolean e: l1) if (e) return false;
			return true;
		}
	}
	private static class Comb {
		public static BigInteger bi(long n1){
			return BigInteger.valueOf(n1);
		}
		public static BigInteger factorial(int n1){
			return factorial(n1, n1);
		}
		public static BigInteger factorial(int n1, int k1){
			BigInteger fin = bi(1);
			BigInteger mult = bi(n1);
			for (int i = 0;i<k1;i++){
				fin = fin.multiply(mult);
				mult = mult.subtract(bi(1));
			}
			return fin;
		}
		public static BigInteger combination(int n1, int k1){
			return factorial(n1,k1).divide(factorial(k1));
		}
	}

	private static class BR {
		BufferedReader k1 = null;
		StringTokenizer k2 = null;

		public BR() {
			k1 = new BufferedReader(new InputStreamReader(System.in));
		}
		public String nx() throws Exception {
			for (;;) {
				if (k2 == null || !k2.hasMoreTokens()) {
					String temp = k1.readLine();
					if (temp == null)
						return null;
					k2 = new StringTokenizer(temp);
				}
				else
					break;
			}

			return k2.nextToken();
		}

		public int ni() throws Exception {
			return Integer.parseInt(nx());
		}
	}
}


/* Rajkin Hossain */

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

public class C{

    FastInput k = new FastInput(System.in);
    FastOutput z = new FastOutput();
    Template t = new Template();

    int n;
    int [] y;

    int [][][][] dp;

    int even, odd;

    int ans;

    void takeInputsFromFile() {
        //k = new FastInput("/home/rajkin/Desktop/input.txt");
    }

    int rec(int prevParity, int i, int odd, int even) {
    	if(even < 0 || odd < 0) {
    		return 100000;
    	}

    	if(i == n) {
    		if(even == 0 && odd == 0) {
    			return 0;
    		}

    		return 100000;
    	}

    	if(dp[prevParity][i][odd][even] != -1) {
    		return dp[prevParity][i][odd][even];
    	}

    	if(y[i] != 0) {
    		int sum = 0;

    		int currentParity = (y[i] % 2);

    		if(prevParity != currentParity) {
    			sum = 1;
    		}

    		return dp[prevParity][i][odd][even] = rec(currentParity, i+1, odd, even) + sum;
    	}

    	int extraSumForOdd = prevParity == 1 ? 0 : 1;
    	int extraSumForEven = prevParity == 0 ? 0 : 1;

    	int oddPart = rec(1, i+1, odd-1, even) + extraSumForOdd;
    	int evenPart = rec(0, i+1, odd, even-1) + extraSumForEven;

    	return dp[prevParity][i][odd][even] = min(oddPart, evenPart);
    }

    void startProgram() {
    	takeInputsFromFile();

    	while(k.hasNext()) {
    		n = k.nextInt();
    		y = k.getInputIntArray(n);

    		if(n % 2 != 0) {
    			odd = (n/2) + 1;
    		}
    		else {
    			odd = n/2;
    		}

    		even = n - odd;

    		for(int v : y) {
    			if(v != 0) {
    				if(v % 2 == 0) even--;
    				else odd--;
    			}
    		}

    		ans = Integer.MAX_VALUE;

    		dp = new int[2][n][n+1][n+1];

    		t.fill4DArray(dp, -1);

    		z.println(min(rec(0, 0, odd, even), rec(1, 0, odd, even)));
    	}

    	z.flush();
    	System.exit(0);
    }

    public static void main(String [] args) throws IOException {
        new Thread(null, new Runnable(){
            public void run(){
            	try{
            		new C().startProgram();
            	}
            	catch(Exception e){
            		e.printStackTrace();
            	}
            }
        },"Main",1<<28).start();
    }

    /* MARK: Template class implementation */

    class Template {

	    HashSet<Integer> generateSet(int [] y) {
			HashSet<Integer> set = new HashSet<Integer>();

			for(Integer key : y) {
				set.add(key);
			}

			return set;
		}

	    HashSet<Long> generateSet(long [] y) {
			HashSet<Long> set = new HashSet<Long>();

			for(Long key : y) {
				set.add(key);
			}

			return set;
		}

		HashMap<Integer, Integer> generateCountMap(int [] y) {
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

			for(int key : y) {
				map.putIfAbsent(key, 0);
				map.put(key, map.get(key) + 1);
			}

			return map;
		}

		HashMap<Long, Integer> generateCountMap(long [] y) {
			HashMap<Long, Integer> map = new HashMap<Long, Integer>();

			for(long key : y) {
				map.putIfAbsent(key, 0);
				map.put(key, map.get(key) + 1);
			}

			return map;
		}

		int [] shrink(int[] a) {
	        int n = a.length;
	        long [] b = new long[n];

	        for (int i = 0; i < n; i++) b[i] = (long) a[i] << 32 | i;

	        shuffleAndSort(b);

	        int[] ret = new int[n];
	        int p = 0;

	        for (int i = 0; i < n; i++) {
	            if (i > 0 && (b[i] ^ b[i - 1]) >> 32 != 0) p++;
	            ret[(int) b[i]] = p;
	        }

	        for (int i = 0; i < n; i++) {
	            ret[i]++;
	        }

	        return ret;
	    }

		long [] shrink(long [] a) {
	        int n = a.length;
	        long[] b = new long[n];

	        for (int i = 0; i < n; i++) b[i] = (long) a[i] << 32 | i;

	        shuffleAndSort(b);

	        long [] ret = new long[n];
	        int p = 0;

	        for (int i = 0; i < n; i++) {
	            if (i > 0 && (b[i] ^ b[i - 1]) >> 32 != 0) p++;
	            ret[(int) b[i]] = p;
	        }

	        for (int i = 0; i < n; i++) {
	            ret[i]++;
	        }

	        return ret;
	    }

		int getMax(int [] a) {
			int maxValue = Integer.MIN_VALUE;

			for(int v : a) {
				maxValue = max(v, maxValue);
			}

			return maxValue;
		}

		long getMax(long [] a) {
			long maxValue = Long.MIN_VALUE;

			for(long v : a) {
				maxValue = max(v, maxValue);
			}

			return maxValue;
		}

		int getMin(int [] a) {
			int minValue = Integer.MAX_VALUE;

			for(int v : a) {
				minValue = min(v, minValue);
			}

			return minValue;
		}

		long getMin(long [] a) {
			long minValue = Long.MAX_VALUE;

			for(long v : a) {
				minValue = min(v, minValue);
			}

			return minValue;
		}

	    void shuffleAndSort(ArrayList<Integer> a) {
	        Random rnd = new Random();

	        int size = a.size();

	        for (int i = size - 1; i >= 1; i--) {
	            int j = rnd.nextInt(i + 1);
	            int t = a.get(i);
	            a.set(i, a.get(j));
	            a.set(j, t);
	        }

	        Collections.sort(a);
	    }

	    void shuffleAndSortLongList(ArrayList<Long> a) {
	        Random rnd = new Random();

	        int size = a.size();

	        for (int i = size - 1; i >= 1; i--) {
	            int j = rnd.nextInt(i + 1);
	            long t = a.get(i);
	            a.set(i, a.get(j));
	            a.set(j, t);
	        }

	        Collections.sort(a);
	    }

	    void shuffleAndSort(int [] a) {
	        Random rnd = new Random();

	        for (int i = a.length - 1; i >= 1; i--) {
	            int j = rnd.nextInt(i + 1);
	            int t = a[i];
	            a[i] = a[j];
	            a[j] = t;
	        }

	        Arrays.sort(a);
	    }

	    void shuffleAndSort(long [] a) {
	        Random rnd = new Random();

	        for (int i = a.length - 1; i >= 1; i--) {
	            int j = rnd.nextInt(i + 1);
	            long t = a[i];
	            a[i] = a[j];
	            a[j] = t;
	        }

	        Arrays.sort(a);
	    }

		int[] getIntArray(ArrayList<Integer> list) {

			int [] array = new int[list.size()];

			int size = array.length;

			for(int i = 0; i<size; i++) {
				array[i] = list.get(i);
			}

			return array;
		}

		long[] getLongArray(ArrayList<Long> list) {

			long [] array = new long[list.size()];

			int size = array.length;

			for(int i = 0; i<size; i++) {
				array[i] = list.get(i);
			}

			return array;
		}

        void fill2DArray(int [][] array, int value) {
        	for(int i = 0; i<array.length; i++) {
            	for(int j = 0; j<array[0].length; j++) {
                	array[i][j] = value;
            	}
        	}
        }

        void fill2DArray(long [][] array, long value) {
        	for(int i = 0; i<array.length; i++) {
            	for(int j = 0; j<array[0].length; j++) {
                	array[i][j] = value;
            	}
        	}
        }

        void fill3DArray(int [][][] array, int value) {
        	for(int i = 0; i<array.length; i++) {
            	for(int j = 0; j<array[0].length; j++) {
                	for(int k = 0; k<array[0][0].length; k++) {
                		array[i][j][k] = value;
                	}
            	}
        	}
        }

        void fill3DArray(long [][][] array, long value) {
        	for(int i = 0; i<array.length; i++) {
            	for(int j = 0; j<array[0].length; j++) {
                	for(int k = 0; k<array[0][0].length; k++) {
                		array[i][j][k] = value;
                	}
            	}
        	}
        }

        void fill4DArray(int [][][][] array, int value) {
        	for(int i = 0; i<array.length; i++) {
            	for(int j = 0; j<array[0].length; j++) {
                	for(int k = 0; k<array[0][0].length; k++) {
                    	for(int l = 0; l<array[0][0][0].length; l++) {
                    		array[i][j][k][l] = value;
                    	}
                	}
            	}
        	}
        }

        void fill4DArray(long [][][][] array, long value) {
        	for(int i = 0; i<array.length; i++) {
            	for(int j = 0; j<array[0].length; j++) {
                	for(int k = 0; k<array[0][0].length; k++) {
                    	for(int l = 0; l<array[0][0][0].length; l++) {
                    		array[i][j][k][l] = value;
                    	}
                	}
            	}
        	}
        }
    }

    /* MARK: FastInput and FastOutput */

    class FastInput {
        BufferedReader reader;
        StringTokenizer tokenizer;

        FastInput(InputStream stream){
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        FastInput(String path){
            try {
                reader = new BufferedReader(new FileReader(path));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            tokenizer = null;
        }

        String next() {
            return nextToken();
        }

        String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return null;
        }

        boolean hasNext(){
            try {
                return reader.ready();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return false;
        }

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

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

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

        int [] getInputIntArray(int n) {

        	int [] input = new int[n];

        	for(int i = 0; i<n; i++) {
        		input[i] = nextInt();
        	}

        	return input;
        }

        long [] getInputLongArray(int n) {

        	long [] input = new long[n];

        	for(int i = 0; i<n; i++) {
        		input[i] = nextLong();
        	}

        	return input;
        }

        int [] getInputIntArrayOneBasedIndex(int n) {

        	int [] input = new int[n+1];

        	for(int i = 1; i<=n; i++) {
        		input[i] = nextInt();
        	}

        	return input;
        }

        long [] getInputLongArrayOneBasedIndex(int n) {

        	long [] input = new long[n+1];

        	for(int i = 1; i<=n; i++) {
        		input[i] = nextLong();
        	}

        	return input;
        }
    }

    class FastOutput extends PrintWriter {
		FastOutput() {
			super(new BufferedOutputStream(System.out));
		}

		public void debug(Object...obj) {
		    System.err.println(Arrays.deepToString(obj));
		}
    }
}


//package marbles;

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

/**
 *
 * @author Adreno
 */
public class Marbles {

    public static char reverse(char c) {
        if (c == 'N') return 'S';
        if (c == 'S') return 'N';
        if (c == 'W') return 'E';
        if (c == 'E') return 'W';
        return '-';
    }

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

        int n = scanner.nextInt();
        n--;
        scanner.nextLine();
        String a = scanner.nextLine();
        String b = scanner.nextLine();

        // käännetään merkkijono a
        StringBuilder uusA = new StringBuilder();
        for (int i=n-1; i>=0; i--) {
            uusA.append(reverse(a.charAt(i)));
        }
        a = uusA.toString();

//        StringBuilder buildA = new StringBuilder();
//        buildA.append('N');
//        for (int i=0; i<12; i++) {
//            int size = buildA.length();
//            for (int j=0; j<size; j++) {
//                buildA.append(reverse(buildA.charAt(j)));
//            }
//        }
//        String a = buildA.toString();
//        int n = a.length();
//
//        StringBuilder buildB = new StringBuilder();
//        for (int i=n-1; i>=0; i--) {
//            buildB.append(reverse(a.charAt(i)));
//        }
//        String b = buildB.toString();

        StringHasher sh = new StringHasher();
        ;HashedString ah = sh.hashString(a);
        ;HashedString bh = sh.hashString(b);
        HashedString[] hstrings = sh.hashString(a, b);

        for (int i=0; i<n; i++) {
            if (sh.getHash(hstrings[0], 0, i) == sh.getHash(hstrings[1], n-1-i, n-1)) {
                if (!a.substring(0, i+1).equals(b.substring(n-1-i, n))) {
                    System.out.println("HASH COLLISION DETECTED at i=" + i);
                    continue;
                }
                System.out.println("NO");
                return;
            }
        }

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

}

/**
 * O(1) Instantiate StringHasher()
 * O(N) Use hashString methods to generate hashes
 * O(1) Compare sub string hashes with getHash(hashedString, fromIndex, toIndex)
 * NOTE: Hash collisions (false positives) may occur, might wanna
 *       confirm positives by actually comparing those substrings.
 */
class HashedString {
    long[] hashes;
    long[] modifiers;

    public HashedString(long[] hashes, long[] modifiers) {
        this.hashes = hashes;
        this.modifiers = modifiers;
    }
}
class StringHasher {
    long P;
    long M;

    public StringHasher() {
        initializePandM();
    }

    HashedString hashString(String s) {
        int n = s.length();
        long[] hashes = new long[n];
        long[] modifiers = new long[n];
        hashes[0] = s.charAt(0);
        modifiers[0] = 1;
        for (int i=1; i<n; i++) {
            hashes[i] = (hashes[i-1] * P + s.charAt(i)) % M;
            modifiers[i] = (modifiers[i-1] * P) % M;
        }
        return new HashedString(hashes, modifiers);
    }

    /**
     * Indices are inclusive.
     */
    long getHash(HashedString hashedString, int startIndex, int endIndex) {
        long[] hashes = hashedString.hashes;
        long[] modifiers = hashedString.modifiers;
        long result = hashes[endIndex];
        if (startIndex > 0) result -= (hashes[startIndex-1] * modifiers[endIndex-startIndex+1]) % M;
        if (result < 0) result += M;
        return result;
    }

    // Less interesting methods below

    /**
     * Efficient for 2 input parameter strings in particular.
     */
    HashedString[] hashString(String first, String second) {
        HashedString[] array = new HashedString[2];
        int n = first.length();
        long[] modifiers = new long[n];
        modifiers[0] = 1;

        long[] firstHashes = new long[n];
        firstHashes[0] = first.charAt(0);
        array[0] = new HashedString(firstHashes, modifiers);

        long[] secondHashes = new long[n];
        secondHashes[0] = second.charAt(0);
        array[1] = new HashedString(secondHashes, modifiers);

        for (int i=1; i<n; i++) {
            modifiers[i] = (modifiers[i-1] * P) % M;
            firstHashes[i] = (firstHashes[i-1] * P + first.charAt(i)) % M;
            secondHashes[i] = (secondHashes[i-1] * P + second.charAt(i)) % M;
        }
        return array;
    }

    /**
     * Efficient for 3+ strings
     * More efficient than multiple hashString calls IF strings are same length.
     */
    HashedString[] hashString(String... strings) {
        HashedString[] array = new HashedString[strings.length];
        int n = strings[0].length();
        long[] modifiers = new long[n];
        modifiers[0] = 1;
        for (int j=0; j<strings.length; j++) {
            // if all strings are not same length, defer work to another method
            if (strings[j].length() != n) {
                for (int i=0; i<n; i++) {
                    array[i] = hashString(strings[i]);
                }
                return array;
            }

            // otherwise initialize stuff
            long[] hashes = new long[n];
            hashes[0] = strings[j].charAt(0);
            array[j] = new HashedString(hashes, modifiers);
        }
        for (int i=1; i<n; i++) {
            modifiers[i] = (modifiers[i-1] * P) % M;
            for (int j=0; j<strings.length; j++) {
                String s = strings[j];
                long[] hashes = array[j].hashes;
                hashes[i] = (hashes[i-1] * P + s.charAt(i)) % M;
            }
        }
        return array;
    }

    void initializePandM() {
        ArrayList<Long> modOptions = new ArrayList<>(20);
        modOptions.add(353873237L);
        modOptions.add(353875897L);
        modOptions.add(353878703L);
        modOptions.add(353882671L);
        modOptions.add(353885303L);
        modOptions.add(353888377L);
        modOptions.add(353893457L);
        P = modOptions.get(new Random().nextInt(modOptions.size()));

        modOptions.clear();
        modOptions.add(452940277L);
        modOptions.add(452947687L);
        modOptions.add(464478431L);
        modOptions.add(468098221L);
        modOptions.add(470374601L);
        modOptions.add(472879717L);
        modOptions.add(472881973L);
        M = modOptions.get(new Random().nextInt(modOptions.size()));
    }
}


import java.util.*;
public class Tanya
{
    public static void main(String arg[])
    {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long k=sc.nextLong();
        long a=sc.nextLong();
        long b=sc.nextLong();

        long s=0;
        if(k==1)
        {
            System.out.println((n-1)*a);
            return;
        }
        while(n!=1)
        {
            if(n<k)
            {
                s+=(n-1)*a;
                n=1;
            }
            else
            {
            long r=n%k;
            s+=(r*a);
            n-=r;
            n/=k;
            s+=Math.min(b,((n*(k-1)*a)));
            }
        }
        System.out.println(s);

    }
}


// Codeforces 208A
import java.util.Scanner;

public class CF208A {
    static final Scanner SC = new Scanner(System.in);
    public static void main(String[] args) {
        String remix = SC.next();
        String actualWords = getActualWords(remix);
        System.out.println(actualWords);
    }

    // Gets actual words from the remix provided
    static String getActualWords(String remix) {
        StringBuilder sb = new StringBuilder();
        int subStart = 0, subEnd = 0; // Start and end of substring to be appended
        int uptoIdx = remix.length();
        for (int i = 0; i < uptoIdx; ++i) {
            int skip = skipWUBs(remix, i, uptoIdx);
            if (skip > 0) {
                subEnd = i;
                sb.append(remix.substring(subStart, subEnd));
                if (subEnd > 0) // No ' ' to be added at the beginning
                    sb.append(' ');
                i += skip;
                subStart = i;
            }
        }
        sb.append(remix.substring(subStart, remix.length()));
        return sb.toString();
    }

    // Returns characters to be skipped to remove WUBs
    static int skipWUBs(String remix, int idx, int uptoIdx) {
        int skip = 0;
        boolean foundWUB;
        if (idx + 3 > uptoIdx)
            foundWUB = false;
        else {
            boolean checkW = remix.charAt(idx) == 'W';
            boolean checkU = remix.charAt(idx+1) == 'U';
            boolean checkB = remix.charAt(idx+2) == 'B';
            if (checkW && checkU && checkB)
                foundWUB = true;
            else
                foundWUB = false;
        }
        if (foundWUB)
            return 3 + skipWUBs(remix, idx+3, uptoIdx);
        else
            return 0;
    }
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
public class A {
	 public static long n;
	 public static long h=(long) 1e10;
		    public static void main(String[] args) throws IOException {
		    	FastReader sc=new FastReader();
		    	 n=sc.nextLong();

		    	f(0,0,0);
		    	System.out.println(h);
}
		    public static void f(long x,int count4,int count7){
		    	if(x>100*n) return;
		    	if(x>=n && count4==count7) h=Math.min(h,x);

		    	f(10*x+4,count4+1,count7);
		    	f(10*x+7,count4,count7+1);

		    }

       static class FastReader
		    {
		        BufferedReader br;
		        StringTokenizer st;

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

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

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

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

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

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


import java.util.HashMap;
import java.util.Scanner;

public class que2 {

	public static void main(String[] args) {
    Scanner scn=new Scanner(System.in);
    int test=scn.nextInt();
    for(int t=1;t<=test;t++){
    	int n=scn.nextInt();
    	int d=scn.nextInt();
    	int k=scn.nextInt();
    HashMap<Integer,Integer> map=new HashMap<>();
    int []arr=new int[n];
    for(int i=0;i<n;i++){
    	arr[i]=scn.nextInt();

    }

    for(int i=0;i<k;i++){
    	map.put(arr[i], map.getOrDefault(arr[i], 0)+1);
    }
    int min=map.size();
    for(int i=k;i<n;i++){
   int fr=map.get(arr[i-k]);
   if(fr==1){
	   map.remove(arr[i-k]);
   }else{
	   map.put(arr[i-k], map.get(arr[i-k])-1);
   }
   map.put(arr[i], map.getOrDefault(arr[i], 0)+1);
   min=Math.min(min, map.size());
    }
    System.out.println(min);
    }

	}

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sn = new Scanner(System.in);
        int k = sn.nextInt();
        int r = sn.nextInt();
        int count  = 1;
        while((count*k)%10!=r && (count*k)% 10 != 0)
        {
            count++;
        }
        System.out.println(count);
    }
}


//package abbyy3.f;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		int[] dp = new int[n+1];
		Arrays.fill(dp, 9999999);
		dp[n] = 0;
		for(int i = n;i >= 0;i--){
			for(int j = i;j > 0;j /= 10){
				dp[i-j%10] = Math.min(dp[i-j%10], dp[i] + 1);
			}
		}
		out.println(dp[0]);
	}

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

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

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

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

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

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

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

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

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

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

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

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

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

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

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

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


 import java.io.*;

import java.util.*;
import java.util.Collections;
import java.util.Arrays;

public class Codechef {

  public static void main(String[] args) throws IOException {
	Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	if(n==1){
		System.out.println(1);
		return;
	}
	long arr[]=new long[100000];
	arr[0]=1;
	for(int i=1;i<100000;i++){
		arr[i]=(int)Math.pow(2,i);
		arr[i]=arr[i-1]+arr[i];
		//System.out.println(arr[i]);
	}
	int j=0;
	while(arr[j]<n){
		j++;
	}
	System.out.println(j+1);

  }

   }


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

public class Prob237C {
	public static void main(String[] Args) {
		boolean[] isPrime = new boolean[2000000];
		Arrays.fill(isPrime, true);
		isPrime[0] = false;
		isPrime[1] = false;
		for (int i = 2; i < isPrime.length; i++)
			if (isPrime[i])
				for (int j = 2; j * i < isPrime.length; j++)
					isPrime[i * j] = false;

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int numPrimes = scan.nextInt();

		int tempNum = 0;
		for (int i = a; i <= b; i++)
			if (isPrime[i])
				tempNum++;

		if (tempNum < numPrimes)
			System.out.println(-1);
		else {
			int[] arr = new int[tempNum];
			tempNum = 0;
			for (int i = a; i <= b; i++)
				if (isPrime[i])
					arr[tempNum++] = i;

			int max = Math.max(arr[numPrimes - 1] - a, b - arr[tempNum - numPrimes]) + 1;
			for (int i = numPrimes; i < tempNum; i++)
				max = Math.max(max, arr[i] - arr[i - numPrimes]);
			System.out.println(max);
		}
	}
}


import java.util.Scanner;

public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scanner=new Scanner(System.in);
        int lemon = scanner.nextInt();
        int apple = scanner.nextInt();
        int pear = scanner.nextInt();

         int result=0;

        for(int i=lemon;i>0;i--){
             if(2*i<=apple&&4*i<=pear){
                result=i+(2*i)+(4*i);
                System.out.println(result+"");
                return;
            }else if(i==1){
                 System.out.println(result+"");
            }

        }

    }

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int year = in.nextInt();

		boolean found = false;
		do {

			year++;
			int digit_4 = year % 10;
			int digit_3 = year % 100 - digit_4;
			int digit_2 = year % 1000 - (digit_4 + digit_3);
			int digit_1 = year - (digit_4 + digit_3 + digit_2);

			digit_3 /= 10;
			digit_2 /= 100;
			digit_1 /= 1000;

			if (digit_1 != digit_2) {

				if (digit_1 != digit_3 && digit_2 != digit_3) {
					if (digit_1 != digit_4 && digit_2 != digit_4
							&& digit_3 != digit_4) {
						found = true;
					}
//					else {
//						year++;
//					}
				}
//				else {
//					year += 10;
//				}
			}
//			else {
//				year += 100;
//			}

//			System.err.println(digit_4);
//			System.err.println(digit_3);
//			System.err.println(digit_2);
//			System.err.println(digit_1);
//			System.exit(0);
		}
		while (!found);

		System.out.println(year);
	}
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.Stack;

public class distinctsub{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;

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

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

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

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

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

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

	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

	public static FastReader sc = new FastReader();

	static int mod = (int) (1e9+7);
	static List<Integer>[] edges ;
	static int n;
	static long k;
	static char[] s;
	static Long[][][] dp;

	public static void main(String[] args) {
		n = sc.nextInt();
		k = sc.nextLong();
		s = sc.next().toCharArray();
		dp = new Long[n+1][n+1][n+1];
		long cost = 0;
		for(int i=n;i>=0;--i) {
			long cnt = f(0,-1,i);
			if(cnt >= k) {
			   cost+= k*(n-i);
			   k = 0;
			   break;
			}else {
				k-=cnt;
				cost+= cnt*(n-i);
			}
		}
		if(k > 0) cost = -1;
		out.print(cost);

	out.close();
}

	private static long f(int i, int prev, int len) {
		if(len < 0) return 0;
		if(i == n) {
			if(len == 0) return 1;
			return 0;
		}
		if(dp[i][prev+1][len] != null) return dp[i][prev+1][len];

		long ans = 0;
		if(prev!=-1 && s[i] == s[prev])
			ans = f(i+1,i,len-1);
		else ans = f(i+1,i,len-1) + f(i+1,prev,len);
		return dp[i][prev+1][len] = ans;
	}

}


import java.io.*;
import java.util.*;
/**
 *
 * @author cybros.ru
 */
public class Main {
     PrintWriter cout;
    Scanner cin;
    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() throws IOException{
     cout =new PrintWriter(new OutputStreamWriter(System.out));
     cin = new Scanner(System.in);
     solve();
     cout.flush();
    }

    void solve() throws IOException{
        int r1=cin.nextInt();
        int r2=cin.nextInt();
        int c1=cin.nextInt();
        int c2=cin.nextInt();
        int d1=cin.nextInt();
        int d2=cin.nextInt();
        boolean f=false;
        loop:{
        for(int g1=1;g1<10;g1++){
            for(int g2=1;g2<10;g2++){
                for(int g3=1;g3<10;g3++){
                    for(int g4=1;g4<10;g4++){
                        if(g1+g2==r1&&g3+g4==r2&&g1+g3==c1&&g2+g4==c2&&g1+g4==d1&&g2+g3==d2){
                            if(g1!=g2&&g1!=g3&&g1!=g4&&g2!=g3&&g2!=g4&&g3!=g4){
                            cout.println(g1+" "+g2);
                            cout.println(g3+" "+g4);
                            f=true;
                           break loop;
                            }
                    }
                }

            }
            }
        }
        }
        if(f==false){
         cout.println("-1");
        }
     }
}


import static java.lang.Double.parseDouble;
import static java.lang.Integer.MAX_VALUE;
import static java.lang.Integer.max;
import static java.lang.Long.max;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static java.lang.Math.toRadians;
import static java.lang.System.exit;
import static java.lang.System.gc;

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

public class A {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    int n, a[] = new int[20];

    boolean fun(int i, int deg) {
        return i == n ? (deg + 360) % 360 == 0 : fun(i + 1, deg + a[i]) || fun(i + 1, deg - a[i]);
    }

    void solve() throws Exception {
        n = nextInt();
        a = na(n);
        out.println(fun(0, 0) ? "YES" : "NO");
    }

    public int lower_bound(long[] a, long v) {
        int low = -1, high = a.length;
        while (high - low > 1) {
            int h = high + low >>> 1;
            if (a[h] >= v) {
                high = h;
            } else {
                low = h;
            }
        }
        return high;
    }

    private int gcd(int a, int b) {
        while (b > 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    private int lcm(int a, int b) {
        return a * (b / gcd(a, b));
    }

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

    private long[] nal(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        return a;
    }

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

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

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

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

    public static void main(String[] args) throws Exception {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            //long lStartTime = System.currentTimeMillis();
            new A().solve();
            //long lEndTime = System.currentTimeMillis();
            //out.println("Elapsed time in seconds: " + (double)(lEndTime - lStartTime) / 1000.0);
            in.close();
            out.close();
        } catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}


import java.util.Scanner;

/**
 * Created by amitchh on 2/18/2015.
 */
public class A515Div2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int y = input.nextInt();
        int s = input.nextInt();
        int steps = Math.abs(x) + Math.abs(y);
        if( (s >= steps) && ((s - steps) % 2 == 0))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

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

		int[] colors = new int[4];

		int ans = 4;

		for(int i = 0; i < 4; i++)
		{
			colors[i] = in.nextInt();

			boolean unique = true;

			for(int j = 0; j < i; j++)
			{
				if(colors[i] == colors[j])
				{
					unique = false;
				}
			}

			if(unique)
			{
				ans--;
			}
		}

		System.out.println(ans);
	}
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long res = (n / 2) + (n / 3) - (n / 6) + (n / 42)
                  +(n / 5) + (n / 7) + (n/ 30) + (n / 70) + (n / 105)
                  -(n / 10) - (n / 15) - (n / 14) - (n / 21) - (n / 35) - (n / 210);
        System.out.println(n - res);
    }
}


import java.util.Scanner;

public class P1 {
	private static final Scanner IN = new Scanner(System.in);
	private static final int TOT = 3000;
	private static final boolean primos[] = new boolean[TOT+1];

	private static final void fillCriba(){
		primos[0]=true;
		primos[1]=true;
		int tope = (int)Math.sqrt(TOT)+1;
		for (int i = 2; i <= tope; i++) {
			if(isPrimo(i)){
				if((i*i)>=TOT) return;
				for (int j = i; j <= (TOT/2)+1; j++) {
					if (j*i > TOT) break;
					primos[j*i]=true;
				}
			}
		}
	}

	public static void main(String[] args) {
		fillCriba();
		int c = 0;
		int n = IN.nextInt();
		for (int i = 6; i <= n; i++) {
			if(isAlmost(i)) c++;
		}
		System.out.println(c);
	}

	private static boolean isAlmost(int n){
		int c = 0;
		for (int i = 2; i < n; i++) {
			if (c>2) return false;
			if(n%i==0)
				if(isPrimo(i)) c++;
		}
		return c==2;
	}

	private static boolean isPrimo(int n){
		return !primos[n];
	}
}


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

public class PetrAndBook {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(f.readLine());
        int[] a = new int[7];
        int sum = 0;
        StringTokenizer st = new StringTokenizer(f.readLine());
        for (int i = 0; i < 7; i++)
            sum += a[i] = Integer.parseInt(st.nextToken());
        n %= sum;
        if (n == 0)
            n = sum;
        int i = 0;
        while (n > 0)
            n -= a[i++];
        System.out.println(i);
    }
}


import java.util.*;
public class A59 {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int cnt=0;
		for(int i =0;i<s.length();i++){
			Character c = s.charAt(i);
			if (Character.isUpperCase(c)){
				cnt++;
			}
		}
		if (cnt>(s.length()-cnt))System.out.println(s.toUpperCase());
		else System.out.println(s.toLowerCase());
	}

}


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

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

    System.out.print((n>k && k>0) ? 1 : 0 );
    if(k!=n){
        if(k>1) System.out.print(" " + (  ( (k>=(n/2)) ? n-k : ( (n>=k*3) ? k*2 : n-k ) ) ) );
    	if(k==1) System.out.print( ( n-k==1 ? (" " + 1) : (" "+2) ) );
    	if(k==0) System.out.print(" " + 0);
    }else{System.out.print(" " + 0);}

    }
}


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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long s = in.nextLong();
            long x = in.nextLong();
            out.println(f2(s, x));
        }

        long f2(long s, long x) {
            int[] cnt = new int[1 << 21];
            long rx = x & ((1 << 20) - 1);
            for (long ra = 0; ra < (1 << 20); ++ra) {
                long rb = rx ^ ra;
                ++cnt[(int) (ra + rb)];
            }
            long lx = x >> 20;
            long res = 0;
            for (long la = 0; la < (1 << 20); ++la) {
                long lb = lx ^ la;
                long rem = s - (la << 20) - (lb << 20);
                if (rem >= 0 && rem < cnt.length) {
                    res += cnt[(int) rem];
                }
            }
            if (s == x) {
                res -= 2;
            }
            return res;
        }

    }

    static class InputReader {
        BufferedReader bufReader;
        StringTokenizer stringTokenizer;
        boolean isEof = false;

        public InputReader(InputStream stream) {
            bufReader = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    String line = bufReader.readLine();
                    if (line == null) {
                        isEof = true;
                        return null;
                    }
                    stringTokenizer = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return stringTokenizer.nextToken();
        }

        public long nextLong() {
            String s = next();
            if (s == null) {
                return 0;
            }
            return Long.parseLong(s);
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

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

    static class TaskC {
        public static boolean angle(TaskC.Point a, TaskC.Point b) {
            double amag = a.mag();
            double bmag = b.mag();
            double abmag = a.v * b.v + a.w * b.w + a.x * b.x + a.y * b.y + a.z * b.z;
            double angle = Math.toDegrees(Math.acos(abmag / (amag * bmag)));
            if (angle < 90) {
                return true;
            }
            return false;
        }

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            if (n > 11) {
                out.println("0");
            } else {
                HashSet<Integer> good = new HashSet<Integer>();
                ArrayList<TaskC.Point> arr = new ArrayList<>();
                for (int i = 0; i < n; i++) {
                    int a = in.nextInt();
                    int b = in.nextInt();
                    int c = in.nextInt();
                    int d = in.nextInt();
                    int e = in.nextInt();
                    TaskC.Point p = new TaskC.Point(a, b, c, d, e);
                    arr.add(p);
                }
                for (int i = 0; i < n; i++) {
                    boolean b = true;
                    for (int j = 0; j < n; j++) {
                        for (int k = 0; k < n; k++) {
                            if (i != j && i != k && j != k) {
                                TaskC.Point one = arr.get(j);
                                TaskC.Point two = arr.get(k);
                                TaskC.Point three = arr.get(i);
                                TaskC.Point lol2 = new TaskC.Point(one.v - three.v, one.w - three.w, one.x - three.x, one.y - three.y, one.z - three.z);
                                TaskC.Point lol1 = new TaskC.Point(two.v - three.v, two.w - three.w, two.x - three.x, two.y - three.y, two.z - three.z);
                                if (angle(lol1, lol2)) {
                                    b = false;
                                }
                            }
                        }
                    }
                    if (b) {
                        good.add(i + 1);
                    }
                }
                if (good.size() == 0) {
                    out.println("0");
                } else {
                    out.println(good.size());
                    for (int i : good) {
                        out.println(i);
                    }
                }
            }
        }

        public static class Point {
            int v;
            int w;
            int x;
            int y;
            int z;

            public Point(int a, int b, int c, int d, int e) {
                v = a;
                w = b;
                x = c;
                y = d;
                z = e;
            }

            public double mag() {
                return Math.sqrt(v * v + w * w + x * x + y * y + z * z);
            }

        }

    }

    static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}


import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int k = in.nextInt();
        int x = in.nextInt();
        int max = 0;
        ArrayList<Integer> balls = new ArrayList<>();
        for (int i = 0; i < n; ++i)
            balls.add(in.nextInt());
        ArrayList<Integer> copy = new ArrayList<>(balls);
        int ind = 0;
        while (index(balls, x, ind) != -1) {
            ind = index(balls, x, ind) + 1;
            balls.add(ind, x);
            while (has(balls))
                destroy(balls);
            max = Math.max(max, n - balls.size());
            balls = new ArrayList<>(copy);
        }
        out.println(max);
        out.close();
    }
    static int index(ArrayList<Integer> balls, int x, int st) {
        for (int i = st; i < balls.size() - 1; ++i)
            if (balls.get(i) == balls.get(i + 1) && balls.get(i) == x)
                return i;
        return -1;
    }
    static void destroy(ArrayList<Integer> balls) {
        for (int i = 0; i < balls.size() - 2; ++i)
            if (balls.get(i) == balls.get(i + 1) && balls.get(i) == balls.get(i + 2)) {
                int temp = balls.get(i);
                while (i < balls.size() && balls.get(i) == temp)
                    balls.remove(i);
            }
    }
    static boolean has(ArrayList<Integer> balls) {
        for (int i = 0; i < balls.size() - 2; ++i)
            if (balls.get(i) == balls.get(i + 1) && balls.get(i) == balls.get(i + 2))
                return true;
        return false;
    }
}


import java.util.Scanner;

public class Divisibility {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double ans = Math.floor(a/2520);

		System.out.printf("%.0f",ans);

	}

}


import java.util.Scanner;

public class code {
      public static void main(String[] args){
        code cc = new code();
        int x,c=0,num=0,r=0;
        Scanner n=new Scanner(System.in);
        x=n.nextInt();
        for(int i=1;num<x;i++){
            for(int j=1;j<=i;j++){
                r=r+j;
            }

            num=num+r;
            if(num<=x){
            c++;}
            r=0;
        }
        System.out.println(c);
      }
}


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

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        try {
            line = br.readLine();
            Integer n = Integer.parseInt(line);
            System.out.println(BigInteger.valueOf(3).pow(3 * n).subtract(BigInteger.valueOf(7).pow(n))
                    .mod(BigInteger.valueOf(10).pow(9).add(BigInteger.valueOf(7))));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


/**
 *
 * @author Yesha Shah
 */

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

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

        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        if(k==0) {
            System.out.println(0);
            return;
        }
        int[] arr = new int[12];

        for(int i=0; i<12; i++) {
            arr[i] = sc.nextInt();
        }

        Arrays.sort(arr);

        int count = 0;

        int sum = 0;
        int i =11;
        boolean b = false;
        do {
            if(i<0) {
                b = true;
                count = -1;
                break;
            }
            sum+=arr[i];
            i--;
            count++;
        } while(sum < k);

        System.out.println(count);
    }

}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;
	private PrintWriter pw;
	private long mod = 1000000000 + 7;

	private StringBuilder ans_sb;
	private int size = 1000005;
	private long[] fact;
	private void soln() {
		long n = nextLong();
		fact = new long[20];
		fact[0] = 1;
		for(long i=1;i<=19;i++) {
			fact[(int)i] = fact[(int)i-1]*i;
		}
		long[] cnt = new long[10];
		while(n!=0) {
			int dig = (int)(n%10);
			n /= 10;
			cnt[dig]++;
		}
		int[] cc = new int[10];
		func(cnt, 0, 1L, cc);
		pw.println(ma);
	}
	private long ma = 0;
	private void func(long[] cnt, int j, long ans, int[] cc) {
		if(j == 10) {
			int tot = 0;
			long mul = 1;
			for(int i=0;i<10;i++) {
				mul *= fact[cc[i]];
				tot += cc[i];
			}
			long aa = fact[tot]/mul;
			if(cc[0] == 0)
				ma += aa;
			else {
				mul /= fact[cc[0]];
				mul *= (fact[cc[0]-1]);
				long aa1 = fact[tot-1]/mul;
				aa -= aa1;
				ma += aa;
			}
			//debug(cc);
			return;
		}
		long n1 = cnt[j];
		if(n1 == 0) {
			func(cnt, j+1, ans, cc);
		}else {
			for(int i=1;i<=n1;i++) {
				cc[j] = i;
				func(cnt, j+1, ans, cc);
			}
		}
	}
	private int contains(int[] arr, int x) {
		for(int i=0;i<arr.length;i++) {
			if(arr[i] == x) {
				return i;
			}
		}
		return -1;
	}
	private class Query implements Comparable<Query>{
		int i, idx, x, y, mul;
		public Query(int a, int b, int c, int d, int m) {
			i = a;
			idx = b;
			x = c;
			mul = m;
			y = d;
		}
		@Override
		public int compareTo(
				Query o)
		{
			return this.i - o.i;
		}
	}
	private long[][] pow(int a, int b, int n) {
		long[][] mat = {{a,0,b},{1L,0,0},{0,1L,0}};
		if(n == 1)
			return mat;
		long[][] res = pow(a,b,n/2);
		res = multiply(res,res);
		if((n&1) != 0)
			res = multiply(mat, res);
		return res;
	}
	private long[][] multiply(long[][] a, long[][] b) {
		long[][] ret = new long[3][3];
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					ret[i][j] = (ret[i][j] + ((a[i][k]*b[k][j])%mod))%mod;
		return ret;
	}
	private class Node{
		Node left,right;
		int sum;
		public Node(int v) {
			sum=v;
		}
		public Node (Node left,Node right){
			this.left = left;
			this.right = right;
			if (left != null)
				sum = sum + left.sum;
			if (right != null)
				sum = sum + right.sum;
		}
	}
	public Node build(int l,int r) {
		if(l==r)
			return new Node(0);
		int mid=l+((r-l)>>1);
		Node left=build(l,mid);
		Node right=build(mid+1,r);
		return new Node(left,right);
	}
	public int query(int l,int r, Node root) {
		return queryutil(l,r,root,0,size-1);
	}
	public int queryutil(int x,int y,Node node,int l,int r) {
		if(l>y || x>r)
			return 0;
		if(x <= l && r<=y)
			return node.sum;
		int mid=l+((r-l)>>1);
		return queryutil(x,y,node.left,l,mid) + queryutil(x,y,node.right,mid+1,r);
	}
	public Node newNode(int pos,int val,Node node) {
		return newNodeUtil(pos,val,node,0,size-1);
	}
	public Node newNodeUtil(int pos,int val,Node node,int l, int r) {
		if(l==r)
			return new Node(val);
		int mid=l+((r-l)>>1);
		if(pos<=mid) {
			Node left=newNodeUtil(pos,val,node.left,l,mid);
			return new Node(left,node.right);
		}else {
			Node right=newNodeUtil(pos,val,node.right,mid+1,r);
			return new Node(node.left,right);
		}
	}
	private void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
	private long pow(long a, long b, long c) {
		if (b == 0)
			return 1;
		long p = pow(a, b / 2, c);
		p = (p * p) % c;
		return (b % 2 == 0) ? p : (a * p) % c;
	}

	private long gcd(long n, long l) {
		if (l == 0)
			return n;
		return gcd(l, n % l);
	}

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

	public StringBuilder solve() {
		InputReader(System.in);
		/*
		 * try { InputReader(new FileInputStream("C:\\Users\\hardik\\Desktop\\in.txt"));
		 * } catch(FileNotFoundException e) {}
		 */
		pw = new PrintWriter(System.out);
		// ans_sb = new StringBuilder();
		soln();

		pw.close();
		// System.out.println(ans_sb);
		return ans_sb;
	}

	public void InputReader(InputStream stream1) {
		stream = stream1;
	}

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

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

	private 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++];
	}

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

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

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

	private 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();
	}

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

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

	private void pArray(int[] arr) {
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private void pArray(long[] arr) {
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

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

	private char nextChar() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		char c1 = (char) c;
		while (!isSpaceChar(c))
			c = read();
		return c1;
	}

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


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

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

        int x = Integer.valueOf(sc.nextLine());
        String str = sc.nextLine();
        int result = 0;

        for (int i = 1; i < str.length(); i++){
            if (str.charAt(i) == str.charAt(i - 1))
                result++;
        }

        pw.print(result);
        pw.flush();
    }
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class AndSumBig {

    private static long solve(int n, int k)
    {

        int e= (int)1e9 +7;
        long res =1;

        for( int i=1; i <= k  ;i++)
        {
            res = mMul(res,n,e);

        }
        return res;
    }

    public static void main(String[] args)
            throws IOException {
        Scanner s = new Scanner();
        int t = 1;
        t = s.nextInt();
        StringBuilder ans = new StringBuilder();
        int count = 0;
        while (t-- > 0) {
            int n = s.nextInt();
            int m = s.nextInt();
            ans.append(solve(n, m)).append("\n");
        }
        System.out.println(ans.toString());
    }

    static class Scanner {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Scanner() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Scanner(String file_name) throws IOException {
            din = new DataInputStream(
                    new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    if (cnt != 0) {
                        break;
                    } else {
                        continue;
                    }
                }
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0,
                    BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null)
                return;
            din.close();
        }
    }

    public static long norm(long a, long MOD) {
        return ((a % MOD) + MOD) % MOD;
    }

    public static long msub(long a, long b, long MOD) {
        return norm(norm(a, MOD) - norm(b, MOD), MOD);

    }

    public static long madd(long a, long b, long MOD) {
        return norm(norm(a, MOD) + norm(b, MOD), MOD);

    }

    public static long mMul(long a, long b, long MOD) {
        return norm(norm(a, MOD) * norm(b, MOD), MOD);

    }

    public static long mDiv(long a, long b, long MOD) {
        return norm(norm(a, MOD) / norm(b, MOD), MOD);
    }

    public static String formattedArray(int a[]) {
        StringBuilder res = new StringBuilder("");
        for (int e : a)
            res.append(e).append(" ");
        return res.toString().trim();

    }

    private static void getInputs(Scanner s, int[] a, int n) throws IOException {
        for (int i = 0; i < n; i++) {
            a[i] = s.nextInt();
        }
    }
}


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

public class Luckysubstring {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String input = in.nextLine();
        int count4 = 0;
        int count7 = 0;
        in.close();
        if (input.contains("4") || input.contains("7")) {
            for (int i = 0; i < input.length(); i++) {
                if (input.charAt(i) == '4') {
                    count4++;
                } else if (input.charAt(i) == '7') {
                    count7++;
                }
            }
            if (count4 >= count7) {
                System.out.println(4);
            } else {
                System.out.println(7);
            }
        } else {
            System.out.println(-1);
        }

    }
}


import java.util.*;
public class johny {
	public static long gcd(long a, long b)
	{
	    for (;;)
	    {
	        if (a == 0) return b;
	        b %= a;
	        if (b == 0) return a;
	        a %= b;
	    }
	}
	public static long lcm(long a, long b)
	{
	    long temp = gcd(a, b);

	    return temp!=0 ? (a / temp * b) :0;
	}
	public static void main(String args[]){
		Scanner s= new Scanner(System.in);
		long n=s.nextInt();
		long a=s.nextInt();
		long b=s.nextInt();
		long p=s.nextInt();
		long q=s.nextInt();
		long cnt1=0,cnt2=0;
		/*for(int i=1;i<=n;i++){
			if(i%a==0 && i%b==0){
				if(p>q)
					cnt1++;
				else
					cnt2++;
			}
			else if(i%a==0)
				cnt1++;
			else if(i%b==0)
				cnt2++;
		}*/
		cnt1=n/a;
		cnt2=n/b;
		long sum;
		long cnt=n/lcm(a,b);
		if(p>q)
		 sum=(cnt1*p)+(cnt2*q)-(cnt*q);
		else
		 sum=(cnt1*p)+(cnt2*q)-(cnt*p);
		System.out.println(sum);

	}
}


import java.util.Scanner;

public class Tetrahedron {

	private static final long MODULO = (long) Math.pow(10, 9) + 7;

	/*
	 * T(n) = 3 * (T(n - 1) + (-1)^n)
	 */
	public static long numPaths(int steps) {
		long paths = 1;
		for (int i = 1; i <= steps; i++) {
			paths = (3*(paths + (int) Math.pow(-1, i))) % MODULO;
			//System.out.println(i + ": " + paths);
		}
		return paths;
	}

	/*
	 * M(i, j) = M(i - 1, k) for all k s.t j != k
	 * i.e. number of paths of length i ending at vertex j (A, B, C, or D)
	 */
	/*
	public static long numPaths(int steps) {
		long[] memo = new long[4]; //A = 0,  B = 1, C = 2, D = 3
		for (int i = 0; i < 4; i++) {
			memo[i] = 0;
		}
		memo[3] = 1; //start at vertex D

		//System.out.println("Steps: " + 0 + " A: " + memo[0] + " B: " + memo[1] + " C: " + memo[2] + " D: " + memo[3] );

		for (int i = 1; i <= steps; i++) {
			long[] next = new long[4];
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					if (k != j) {next[j] += memo[k];}
					next[j] %= MODULO;
				}
			}
			memo = next;
			//System.out.println("Steps: " + i + " A: " + memo[0] + " B: " + memo[1] + " C: " + memo[2] + " D: " + memo[3]);
		}

		return memo[3];
	}
	*/

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

		int steps = in.nextInt();

		System.out.println(numPaths(steps));

	}

}


import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.LinkedList;

// 10^6 ~ 2 sec
public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine().trim());
        int lastSymbol = n - 1;
        String s = reader.readLine().trim();
        int res = 0;

        for (int start = 0; start <= lastSymbol; start++) {
            for (int end = start; end <= lastSymbol; end++) {
                int[] current = calculateDiff(s, start, end);
                if (current[0] == 0 && current[1] == 0) {
                    res++;
                }
            }
        }
        System.out.println(res);
        reader.close();
    }

    private static int[] calculateDiff(String s, int start, int end) {
        int x = 0;
        int y = 0;
        for (int i = start; i <= end; i++) {
            char cmd = s.charAt(i);
            if (cmd == 'U') {
                y++;
            } else if (cmd == 'D') {
                y--;
            } else if (cmd == 'R') {
                x++;
            } else {
                x--;
            }
        }
        return new int[]{x, y};
    }
}


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.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

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

class Task {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int k = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int v = in.nextInt();
        int ans = 0;
        while (a > 0) {
            int s = 1;
            if (b > k - 1) {
                b -= k - 1;
                s = k;
            } else {
                s = b + 1;
                b = 0;
            }
            a -= s * v;
            ans++;
        }
        out.print(ans);
    }
}

class InputReader {

    public BufferedReader  reader;
    public StringTokenizer tokenizer;

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

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

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

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

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