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

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        long[][] arr = new long[100000][100000];
        arr[0][0] = 2;
        arr[0][1] = 4;
        arr[1][0] = 4;
        for (int i = 2; i < arr.length; i++) {
        	arr[0][i] = arr[0][i-1] + arr[0][i-2];
        	if (arr[0][i] > 1e9+7) {
        		arr[0][i] %= 1e9+7;
        	}
        }
        for (int i = 2; i < arr.length; i++) {
        	arr[i][0] = arr[i-1][0] + arr[i-2][0];
        	if (arr[i][0] > 1e9+7) {
        		arr[i][0] %= 1e9+7;
        	}
        }
        arr[n-1][1] = arr[n-1][0] + 2;
        for (int i = 2; i < arr.length; i++) {
        	arr[n-1][i] = arr[n-1][i-1] + arr[0][i-2];
        	if (arr[n-1][i] > 1e9+7) {
        		arr[n-1][i] %= 1e9+7;
        	}
        }
//        pw.println(Arrays.deepToString(arr));
        pw.println(arr[n-1][m-1]);

        pw.close();
    }
    static class FastScanner {
    	private boolean finished = false;

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

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

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

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

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

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

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

        private String readLine0() {
            StringBuilder buf = new StringBuilder();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r') {
                    buf.appendCodePoint(c);
                }
                c = read();
            }
            return buf.toString();
        }
        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0) {
                s = readLine0();
            }
            return s;
        }
        public String readLine(boolean ignoreEmptyLines) {
            if (ignoreEmptyLines) {
                return readLine();
            } else {
                return readLine0();
            }
        }

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

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

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

        public boolean isExhausted() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1) {
                read();
            }
            return value == -1;
        }
    public String next() {
            return nextString();
        }

        public SpaceCharFilter getFilter() {
            return filter;
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
        public int[] nextIntArray(int n){
            int[] array=new int[n];
            for(int i=0;i<n;++i)array[i]=nextInt();
            return array;
        }
        public int[] nextSortedIntArray(int n){
            int array[]=nextIntArray(n);
            PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
            for(int i = 0; i < n; i++){
                pq.add(array[i]);
            }
            int[] out = new int[n];
            for(int i = 0; i < n; i++){
                out[i] = pq.poll();
            }
            return out;
        }
        public int[] nextSumIntArray(int n){
            int[] array=new int[n];
            array[0]=nextInt();
            for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
            return array;
        }
        public ArrayList<Integer>[] nextGraph(int n, int m){
            ArrayList<Integer>[] adj = new ArrayList[n];
            for(int i = 0; i < n; i++){
                adj[i] = new ArrayList<Integer>();
            }
            for(int i = 0; i < m; i++){
                int u = nextInt(); int v = nextInt();
                u--; v--;
                adj[u].add(v); adj[v].add(u);
            }
            return adj;
        }
        public ArrayList<Integer>[] nextTree(int n){
            return nextGraph(n, n-1);
        }

        public long[] nextLongArray(int n){
            long[] array=new long[n];
            for(int i=0;i<n;++i)array[i]=nextLong();
            return array;
        }
        public long[] nextSumLongArray(int n){
            long[] array=new long[n];
            array[0]=nextInt();
            for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
            return array;
        }
        public long[] nextSortedLongArray(int n){
            long array[]=nextLongArray(n);
            Arrays.sort(array);
            return array;
        }
    }
	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	static void shuffle(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
}


import java.util.Scanner;

public class ProblemA {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String array[] = {"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
		String a = sc.nextLine().toLowerCase();
		String b = sc.nextLine().toLowerCase();
		int co = 0;
		int c = 0;
		for(int i = 0; i<array.length;i++)
		{
			if(a.equals(array[i]))
			{
				co = i;
				//System.out.println("Value of co is"+co);
				break;
			}
		}
		for(int i = co; i<array.length;)
		{
			if(b.equals(array[i]))
			{

				break;
			}
			i++;
			if(i==array.length-1)
			{
				i=0;
			}
			c++;

		}

		if(c==0||c==2||c==3)
		{
			System.out.println("YES");
		}
		else
		{
			System.out.println("NO");
		}

	}

}


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

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

class TaskC {
    /////////////////////////////////////////////////////////////
    public void solve(int testNumber, FastScanner in, FastPrinter out) {
    int d1=in.nextInt(),a1=in.nextInt();
        int d2=in.nextInt(),a2=in.nextInt();

        int d3=in.nextInt(),a3=in.nextInt();

        int d4=in.nextInt(),a4=in.nextInt();
   int win1=0;
        int t1a,t1d,t2a,t2d;
      t1a=a1;t1d=d2;
     if(Math.max(d3,d4)<t1a&&Math.max(a3,a4)<t1d){
         out.println("Team 1");
         return;

     }
        t1a=a2;t1d=d1;
        if(Math.max(d3,d4)<t1a&&Math.max(a3,a4)<t1d){
            out.println("Team 1");
            return;

        }
    //
     int chk=0;
        t1a=a1;t1d=d2;
        t2a=a3;t2d=a4;
        if(t2a>t1d&&t2d>t1a){
           chk|=1;

        }

        t2a=a4;t2d=d3;
        if(t2a>t1d&&t2d>t1a){
            chk|=1;

        }

        t1a=a2;t1d=d1;
        t2a=a3;t2d=a4;
        if(t2a>t1d&&t2d>t1a){
            chk|=2;

        }

        t2a=a4;t2d=d3;
        if(t2a>t1d&&t2d>t1a){
            chk|=2;

        }
     if(chk==3)
         out.println("Team 2");
      else
         out.println("Draw");
    }
}

class FastScanner extends BufferedReader {

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
//            if (isEOF && ret < 0) {
//                throw new InputMismatchException();
//            }
//            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (c >= 0 && !isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

}

class FastPrinter extends PrintWriter {

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

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

}


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

public class Main{

	static int[][] chart;

	public static void main(String[] args){
		Scan scan = new Scan();
		int n = scan.nextInt();
		int[] arr = new int[n+1];
		chart = new int[n+1][n+1];
		arr[0] = 0;
		for(int i=1;i<=n;i++) arr[i] = scan.nextInt();
		int result = solve(0, n, arr);
		System.out.println(result);
		//		for(int i=0;i<=n;i++){
		//			for(int j=0;j<=n;j++) System.out.print(chart[i][j]+" ");
		//			System.out.println();
		//		}
	}

	static int solve(int begin, int end, int[] arr){
		if(begin + 2 == end) return 0;
		if(chart[begin][end] != 0) return chart[begin][end];
		int result = 0;
		for(int i = begin+1;i<end;i++){
			int temp = 0;
			temp += solve(begin, i, arr);
			temp += solve(i, end, arr);
			if(begin+1 != i) temp += Math.min(arr[begin], arr[i]);
			if(i+1 != end) temp += Math.min(arr[i], arr[end]);
			if(temp > result) result = temp;
		}
		return chart[begin][end] = result;
	}

}

class Scan implements Iterator<String>{

	BufferedReader buffer;
	StringTokenizer tok;

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

	@Override
	public boolean hasNext(){
		while(tok==null || !tok.hasMoreElements()){
			try{
				tok = new StringTokenizer(buffer.readLine());
			}catch(Exception e){
				return false;
			}
		}
		return true;
	}

	@Override
	public String next(){
		if(hasNext()) return tok.nextToken();
		return null;
	}

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

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


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

public class Main{

	//static int[][] chart;

	public static void main(String[] args){
		Scan scan = new Scan();
		int n = scan.nextInt();
		int[] arr = new int[n+1];
		//chart = new int[n+1][n+1];
		arr[0] = 0;
		for(int i=1;i<=n;i++) arr[i] = scan.nextInt();
		int result = solve(0, n, arr);
		System.out.println(result);
		//		for(int i=0;i<=n;i++){
		//			for(int j=0;j<=n;j++) System.out.print(chart[i][j]+" ");
		//			System.out.println();
		//		}
	}

	static int solve(int begin, int end, int[] arr){
		if(begin + 2 == end) return 0;
		//if(chart[begin][end] != 0) return chart[begin][end];
		int result = 0;
		for(int i = begin+1;i<end;i++){
			int temp = 0;
			temp += solve(begin, i, arr);
			temp += solve(i, end, arr);
			if(begin+1 != i) temp += Math.min(arr[begin], arr[i]);
			if(i+1 != end) temp += Math.min(arr[i], arr[end]);
			if(temp > result) result = temp;
		}
		//return chart[begin][end] = result;
		return result;
	}

}

class Scan implements Iterator<String>{

	BufferedReader buffer;
	StringTokenizer tok;

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

	@Override
	public boolean hasNext(){
		while(tok==null || !tok.hasMoreElements()){
			try{
				tok = new StringTokenizer(buffer.readLine());
			}catch(Exception e){
				return false;
			}
		}
		return true;
	}

	@Override
	public String next(){
		if(hasNext()) return tok.nextToken();
		return null;
	}

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

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


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

import static java.lang.Math.*;

public class Main {

    void solve() throws IOException {
        String s = readString();
        Map<String, Integer> dist = new HashMap<>();
        Queue<String> q = new ArrayDeque<>();
        q.add(s);
        dist.put(s, 0);
        while (!q.isEmpty()) {
            String cur = q.remove();
            int curDist = dist.get(cur);
            if (curDist > 1000) {
                break;
            }
            if (Long.parseLong(cur) % 25 == 0) {
                System.out.println(curDist);
                return;
            }
            char[] to = cur.toCharArray();
            for (int i = 0; i < to.length - 1; i++) {
                char tmp = to[i];
                to[i] = to[i + 1];
                to[i + 1] = tmp;

                String toS = new String(to);
                if (toS.charAt(0) != '0' && !dist.containsKey(toS)) {
                    q.add(toS);
                    dist.put(toS, curDist + 1);
                }

                tmp = to[i];
                to[i] = to[i + 1];
                to[i + 1] = tmp;
            }
        }
        System.out.println(-1);
    }

    //-------------------------------------------------

    final boolean ONLINE_JUDGE = !new File("input.txt").exists();

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;

    public void run() {
        Runnable run = () -> {
            try {
                long startTime = System.currentTimeMillis();
                Locale.setDefault(Locale.US);
                if (ONLINE_JUDGE) {
                    in = new BufferedReader(new InputStreamReader(System.in));
                    out = new PrintWriter(System.out);
                } else {
                    in = new BufferedReader(new FileReader("input.txt"));
                    out = new PrintWriter("output.txt");
                }
                tok = new StringTokenizer("");
                solve();
                in.close();
                out.close();
                long endTime = System.currentTimeMillis();
                long totalMemory = Runtime.getRuntime().totalMemory();
                long freeMemory = Runtime.getRuntime().freeMemory();
                System.err.println();
                System.err.println("Time = " + (endTime - startTime) + " ms");
                //System.err.println("Memory = " + ((totalMemory - freeMemory) / 1024) + " KB");
            } catch (Throwable e) {
                e.printStackTrace(System.err);
                System.exit(-1);
            }
        };
        new Thread(null, run, "run", 256 * 1024 * 1024).start();
    }

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

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

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

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

    void debug(Object... o) {
        if (!ONLINE_JUDGE) {
            System.err.println(Arrays.deepToString(o));
        }
    }

    long binpow(int a, int n) {
        long r = 1;
        while (n > 0) {
            if ((n & 1) > 0) {
                r *= a;
            }
            a *= a;
            n /= 2;
        }
        return r;
    }

    static long gcd(long x, long y) {
        return y == 0 ? x : gcd(y, x % y);
    }

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


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

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

    static class TaskC {
        private static final int MAX = (int) 1e7;
        private static int[] pi;
        private static int[] rub;
        private static double[] ratio;

        public TaskC() {
            boolean[] isPrime = new boolean[MAX + 1];
            pi = new int[MAX + 1];
            rub = new int[MAX + 1];
            ratio = new double[MAX + 1];
            Arrays.fill(isPrime, true);
            isPrime[0] = isPrime[1] = false;
            for (int i = 2; i <= MAX; i++) {
                if (!isPrime[i]) continue;
                for (int j = 2 * i; j <= MAX; j += i)
                    isPrime[j] = false;
            }

            for (int i = 1; i <= MAX; i++) {
                pi[i] = pi[i - 1];
                if (isPrime[i]) pi[i]++;
            }

            for (int i = 1; i <= MAX; i++) {
                rub[i] = rub[i - 1];
                if (isPalindrome(i)) rub[i]++;
            }

            for (int i = 0; i <= MAX; i++) {
                if (rub[i] == 0) ratio[i] = -1;
                else ratio[i] = (pi[i] * 1.0) / (rub[i] * 1.0);
            }
        }

        private static boolean isPalindrome(int n) {
            String s = Integer.toString(n);
            return check(s, 0, s.length() - 1);
        }

        private static boolean check(String s, int low, int high) {
            if (low >= high) return true;
            else return (s.charAt(low) == s.charAt(high)) && check(s, low + 1, high - 1);
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int p = in.nextInt();
            int q = in.nextInt();
            double r = (p * 1.0) / (q * 1.0);
            out.println(searchFloor(ratio, r));
        }

        private static int searchFloor(double[] ratio, double r) {
            if (r < ratio[1]) return -1;
            int low = 1;
            int high = MAX;
            while (low < high) {
                int mid = (low + high) / 2;
                if ((low + high) % 2 == 1) mid++;
                if (ratio[mid] <= r) low = mid;
                else high = mid - 1;
            }
            return low;
        }

    }

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

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

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

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

    }
}


//Written by Shagoto
import java.util.Scanner;
//import java.math.RoundingMode;
//import com.google.common.math.IntMath;
public class Main
{
  public static void main(String[]args)
  {
    Scanner read = new Scanner(System.in);

    int n = read.nextInt();
    int count = 0;

    if(n < 6)
    {
      System.out.println(0);
    }
    else
    {
      for(int x = 6; x<=n; x++)
      {
        int primeCount = 0;
        for(int i = 2; i<=x; i++)
        {
          int temp = 0;
          for(int j = 1; j<i; j++)
          {
            if(i % j == 0)
            {
              temp++;
            }
          }

          if(temp == 1)
          {
            if(x % i == 0)
            {
              primeCount++;
              if(primeCount > 2)
              {
                break;
              }
            }
          }
        }

        if(primeCount == 2)
        {
          count++;
        }
      }

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


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

public class TaskA {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        while (true) {
            if (eql(a)) {
                break;
            } else {
                Arrays.sort(a);
                a[n - 1] -= a[n - 2];
            }
        }
        int sum = 0;
        for (int e: a) {
            sum += e;
        }
        out.print(sum);
        out.close();
    }
    public static boolean eql (int[] a) {
        for (int i = 1; i < a.length; i++) {
            if (a[i] != a[i - 1]) {
                return false;
            }
        }
        return true;
    }
}


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

public class RockC
{

private static StringTokenizer st;

    public static void nextLine(BufferedReader br) throws IOException
    {
        st = new StringTokenizer(br.readLine());
    }

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

    public static String next()
    {
        return st.nextToken();
    }

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

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

    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        nextLine(br);
        int n = nextInt();
        int[] left = new int[n];
        int[] right = new int[n];
        for (int i = 0; i < n; i++)
        {
            nextLine(br);
            left[i] = nextInt();
            right[i] = nextInt();
        }
        double[] e = new double[10001];
        for (int i = 1; i <= 10000; i++)
        {
            // prob that 1 up 3 down
            for (int j = 0; j < n; j++)
            {
                if (i < left[j] || i > right[j]) continue;
                e[i] += cp(i, left, right, new int[]{j}, n) / (double)(right[j] - left[j] + 1);
                // System.out.println("a " + i + " b " + j + " " + e[i]);
            }

            // prob that 2 equal, rest down
            for (int j = 0; j < n; j++)
            {
                for (int k = j+1; k < n; k++)
                {
                    if (i < left[j] || i > right[j] || i < left[k] || i > right[k])
                        continue;
                    e[i] += (cp3(i, left, right, new int[] {j, k}, n) +
                            cp(i, left, right, new int[] {j, k}, n) )/
                            ((double)(right[j] - left[j] + 1) * (double)(right[k] - left[k] + 1));
                }
            }
            //System.out.println(i + " " + e[i]);
            for (int j = 0; j < n; j++)
            {
                if (i < left[j] || i > right[j]) continue;
                for (int k = j + 1; k < n; k++)
                {
                    if (i < left[k] || i > right[k]) continue;
                    for (int l = k + 1; l < n; l++)
                    {
                        if (i < left[l] || i > right[l]) continue;
                        e[i] += (cp3(i, left, right, new int[] {j, k, l}, n) +
                                cp(i, left, right, new int[] {j, k, l}, n)) /
                                ((double)(right[j] - left[j] + 1) * (double)(right[k] - left[k] + 1)
                                 * (double)(right[l] - left[l] + 1));

                    }
                }
            }
            //System.out.println(i + " " + e[i]);
            for (int j = 0; j < n; j++)
            {
                if (i < left[j] || i > right[j]) continue;
                for (int k = j + 1; k < n; k++)
                {
                    if (i < left[k] || i > right[k]) continue;
                    for (int l = k + 1; l < n; l++)
                    {
                        if (i < left[l] || i > right[l]) continue;
                        for (int m = l + 1; m < n; m++)
                        {
                            if (i < left[m] || i > right[m]) continue;
                            e[i] += (cp3(i, left, right, new int[] {j, k, l, m}, n) +
                                    cp(i, left, right, new int[] {j, k, l, m}, n))/
                                    ((double)(right[j] - left[j] + 1) * (double)(right[k] - left[k] + 1)
                                     * (double)(right[l] - left[l] + 1) * (double)(right[m] - left[m] + 1));
                        }
                    }
                }
            }
            if (n == 5)
            {
                boolean good = true;
                for (int j = 0; j < 5; j++)
                {
                    if (i < left[j] || i > right[j])
                    {
                        good = false;
                        break;
                    }
                }
                if (good)
                {
                    double dd = 1;
                    for (int j = 0; j < 5; j++)
                    {
                        dd /= (double)(right[j] - left[j] + 1);
                    }
                    e[i] += dd;
                }
            }
            //System.out.println(i + " " + e[i]);
        }
        double ans = 0;
        for (int i = 1; i <= 10000; i++)
        {
            ans += i * e[i];
        }
        System.out.format("%.9f\n", ans);
    }

    // calc probability that 1 is strictly higher and the rest are strictly lower
    public static double cp(int v, int[] l, int[] r, int[] pos, int n)
    {
        double dd = 0;
        if (n == 2)
        {
            return 1 - cp2(l[1-pos[0]], r[1-pos[0]], v);
        }
        //System.out.println("Contains " + pos[0]);
        for (int i = 0; i < n; i++)
        {
            if (contains(pos, i)) continue;
            double d2 = 1;
            for (int j = 0; j < n; j++)
            {
                if (contains(pos, j) || j == i) continue;
                d2 *= cp2(l[j], r[j], v-1);
            }

            dd += (1 - cp2(l[i], r[i], v)) * d2;
        }
        return dd;
    }

    // prob that U(l, r) <= v
    public static double cp2(int l, int r, int v)
    {
        if (r <= v)
        {
            return 1;
        }
        if (l > v)
        {
            return 0;
        }
        return (double)(v - l + 1) / (double)(r - l + 1);
    }

    public static double cp3(int v, int[] l, int[] r, int[] pos, int n)
    {
        if (n <= pos.length) return 1;
        double dd = 1;
        for (int i = 0; i < n; i++)
        {
            if (contains(pos, i)) continue;
            dd *= cp2(l[i], r[i], v-1);
        }
        double d2 = 1;
        for (int i = 0; i < n; i++)
        {
            double d3 = 0;
            for (int j = 0; j < n; j++)
            {
                if (j == i) continue;
                if (contains(pos, i)) continue;
                d3 *= cp2(l[j], r[j], v-1);
            }

        }
        return dd;
    }

    public static boolean contains(int[] a, int b)
    {
        for (int i = 0; i < a.length; i++)
        {
            if (a[i] == b) return true;
        }
        return false;
    }
}


import java.util.Scanner;

public class B {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		long b =scan.nextLong();
		while(true){
			if(a==0 || b==0){
				break;
			}
			if(a>=2*b){
				a = a-2*b;
			}
			else if(b>=2*a){
				b = b-2*a;
			}else{
				break;
			}
		}
		System.out.println(a+" "+b);

	}

}


import java.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

import java.util.StringTokenizer;

public class Main {
	//YOU CAN DO IT MERNA....

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

		 Scanner sc= new Scanner(System.in);
	     int arr[]=new int[1000000001];
		int k=sc.nextInt();
		count(arr);
		 System.out.print(arr[k-1]);

}
	static void count(int arr[])
	{int j=0;
		for(int i=0;i<1000000001;i++)
		{  // String l=i+"";

		int u=i;
		    int sum=0;
			while(u!=0)
			{
				sum+=u%10;
				u=u/10;
			}
			if(sum==10) {
				arr[j]=i;
				j++;
			}
				sum=0;
		}
	}
		 }


import java.util.Scanner;

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

        for(int i = 0; i < word.length();i++ ){
            if(word.charAt(i) == 'H' || word.charAt(i) == 'Q' || word.charAt(i) == '9'){
                System.out.println("YES");
                break;
            }
            else {
                System.out.println("NO");
                break;
            }

        }
    }
}


//package round283;
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 E {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	// 012 120 201
	// 1 1 2 4 6 10 23 33 56
	void solve()
	{
		long n = nl();
		int K = ni();
		int t = (int)(Math.log(10)*18/Math.log(K) + 2);
		int[][][] B = new int[2*K][2*K+1][2*K+1];

		int mod = 1000000007;
		for(int i = 0;i < 2*K;i++){
			for(int j = 1;j < 2*K+1;j++){
				B[i][j][j-1] = 1;
			}
			B[i][0][0] = 2;
			B[i][0][i] += mod-1;
		}
		int[][][] C = new int[K][][];
		for(int i = 0;i < K;i++){
			int[][] LC = new int[2*K+1][2*K+1];
			for(int j = 0;j < 2*K+1;j++)LC[j][j] = 1;
			for(int j = 0;j < K-i;j++){
				LC = mul(B[K-i], LC);
			}
			for(int j = 0;j < i;j++){
				LC = mul(B[2*K-i], LC);
			}
			C[i] = LC;
		}

		int[][][] M = new int[t+1][][];
		M[1] = C[1];
		for(int z = 2;z < t;z++){
			M[z] = C[z%K];
			for(int y = 1;y < z;y++){
				for(int i = 0;i < K-1;i++){
					M[z] = mul(M[y], M[z]);
				}
			}
		}
		int[][][] rem = new int[t+1][][];
		rem[1] = C[1];
		for(int i = 0;i < K-2;i++)rem[1] = mul(C[1], rem[1]);
		for(int z = 2;z < t;z++){
			rem[z] = rem[z-1];
			for(int i = 0;i < K-1;i++){
				rem[z] = mul(M[z], rem[z]);
			}
		}

		if(n <= K){
			int u = 1;
			for(int i = 0;i < n;i++){
				u = u * 2 % mod;
			}
			out.println(u);
			return;
		}

		long[] d = new long[64];
		int p = 0;
		while(n > 0){
			d[p++] = n % K;
			n /= K;
		}

		int[] v = new int[2*K+1];
		v[K] = 1;
		for(int i = K-1;i >= 0;i--){
			v[i] = v[i+1] * 2 % mod;
		}

		int prev = -1;
		for(int u = p-1;u >= 2;u--){
			long e = d[u];
			for(int i = 0;i < e;i++){
				if(prev != -1)v = mul(C[prev], v);
				v = mul(rem[u-1], v);
				prev = u%K;
			}
		}
		{
			int u = 1;
			long e = d[u];
			if(e > 0){
				if(prev != -1)v = mul(C[prev], v);
				for(int i = 1;i < e;i++){
					v = mul(C[1], v);
					prev = u%K;
				}
				prev = 1;
			}
		}
		if(prev == -1)prev = 1;
		for(int j = 0;j < K-prev && d[0] > 0;j++, d[0]--){
			v = mul(B[K-prev], v);
		}
		for(int j = 0;j < prev && d[0] > 0;j++, d[0]--){
			v = mul(B[2*K-prev], v);
		}
		out.println(v[0]);
	}

	public static int[][] mul(int[][] A, int[][] B)
	{
		int m = A.length;
		int n = A[0].length;
		int o = B[0].length;
		int[][] C = new int[m][o];
		for(int i = 0;i < m;i++){
			long[] sum = new long[n];
			for(int k = 0;k < n;k++){
				for(int j = 0;j < n;j++){
					sum[j] += (long)A[i][k] * B[k][j];
					if(sum[j] >= BIG)sum[j] -= BIG;
				}
			}
			for(int j = 0;j < n;j++){
				C[i][j] = (int)(sum[j] % mod);
			}
		}
		return C;
	}

	///////// begin
	public static final int mod = 1000000007;
	public static final long m2 = (long)mod*mod;
	public static final long BIG = 8L*m2;

	// A^e*v
	public static int[] pow(int[][] A, int[] v, long e)
	{
		for(int i = 0;i < v.length;i++){
			if(v[i] >= mod)v[i] %= mod;
		}
		int[][] MUL = A;
		for(;e > 0;e>>>=1) {
			if((e&1)==1)v = mul(MUL, v);
			MUL = p2(MUL);
		}
		return v;
	}

	// int matrix*int vector
	public static int[] mul(int[][] A, int[] v)
	{
		int m = A.length;
		int n = v.length;
		int[] w = new int[m];
		for(int i = 0;i < m;i++){
			long sum = 0;
			for(int k = 0;k < n;k++){
				sum += (long)A[i][k] * v[k];
				if(sum >= BIG)sum -= BIG;
			}
			w[i] = (int)(sum % mod);
		}
		return w;
	}

	// int matrix^2 (be careful about minus value)
	public static int[][] p2(int[][] A)
	{
		int n = A.length;
		int[][] C = new int[n][n];
		for(int i = 0;i < n;i++){
			long[] sum = new long[n];
			for(int k = 0;k < n;k++){
				for(int j = 0;j < n;j++){
					sum[j] += (long)A[i][k] * A[k][j];
					if(sum[j] >= BIG)sum[j] -= BIG;
				}
			}
			for(int j = 0;j < n;j++){
				C[i][j] = (int)(sum[j] % mod);
			}
		}
		return C;
	}

	//////////// end

	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 E().run(); }

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

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

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

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

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

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

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

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

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

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

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

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

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


import java.util.Scanner;

public class code758C {

	public static void getAns(int n,int m,long k,int x,int y){
		long[][] arr= new long[n+1][m+1];
		if(n==1 && m==1){
			System.out.println(k+" "+k+" "+k);
			return;
		}
		long qmax=0,qmin=Long.MAX_VALUE,qser=0;
		boolean inc=true;
		if(n==1){
			while(k>0){
				for(int i=1;i<=m && k>0;i++){
					arr[1][i]++;
					k--;
				}
			}
			for(int i=1;i<=m;i++){
				if(arr[1][i]>qmax){
					qmax=arr[1][i];
				}
				if(arr[1][i]<qmin){
					qmin=arr[1][i];
				}
			}

			qser=arr[x][y];

			System.out.println(qmax+" "+qmin+" "+qser);
			return;
		}
		long temp=(2*n-2)*m;
		long com=k/temp;
		k=k%temp;

		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				arr[i][j]=com*2;
			}
		}
		for(int i=1;i<=m;i++){
			arr[1][i]=com;
			arr[n][i]=com;
		}

		while(k>0){
			if(inc==true){
				for(int i=1;i<=n && k>0;i++){
					for(int j=1;j<=m && k>0;j++){
						arr[i][j]++;
						k--;
					}
				}
				inc=false;
			}
			else{
				for(int i=n-1;i>1 && k>0;i--){
					for(int j=1;j<=m && k>0;j++){
						arr[i][j]++;
						k--;
					}
				}
				inc=true;
			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(arr[i][j]>qmax){
					qmax=arr[i][j];
				}
				if(arr[i][j]<qmin){
					qmin=arr[i][j];
				}
			}
		}

		qser=arr[x][y];

		//qser=arr[x][y];
		System.out.println(qmax+" "+qmin+" "+qser);
		return;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner get = new Scanner(System.in);
		int n=get.nextInt();
		int m =get.nextInt();
		long k=get.nextLong();
		int x =get.nextInt();
		int y= get.nextInt();
		//System.out.println(k);
		getAns(n,m,k,x,y);
	}

}


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

public class Cf59
{
	public static void main(String args[])
	{
		Scanner in = new Scanner(System.in);
		int p,d,t,f,c;
		p=in.nextInt();
		d=in.nextInt();
		t=in.nextInt();
		f=in.nextInt();
		c=in.nextInt();
		int bij=0;
		int d_c=t*p;
		int d_d=0;
		while(d_c!=c)
		{
			d_d=d*1 + d_d;
			d_c=d_c + p*1;
			if(d_d>d_c)
			{
				d_d=0;
				bij++;
				d_c=d_c+p*f;
			}
		}
		System.out.println(bij);
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class byo {
	static long gcd(long a, long b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
	static char addc(char a,char b) {
		int x=Integer.parseInt(a+"");
		int y=Integer.parseInt(b+"");
		int z=x+y;
		if(z<=9) {
			return (char)('0'+z);
		}
		z=z%10;
		return (char)('0'+z);
	}
	static String add(String a,String b) {
		String r="";
		if(a.length()>=b.length()) {
			int ai=a.length()-1;int bi=b.length()-1;
			while(bi>=0) {
				char c=addc(a.charAt(ai),b.charAt(bi));
				ai--;bi--;

				r=c+r;
			}
			while(ai>=0) {
				r=a.charAt(ai)+r;ai--;
			}
		}
		else {
			int ai=a.length()-1;int bi=b.length()-1;
			while(ai>=0) {
				char c=addc(a.charAt(ai),b.charAt(bi));
				ai--;bi--;

				r=c+r;
			}
			while(bi>=0) {
				r=b.charAt(bi)+r;bi--;
			}
		}

		String f="";
		int o=0;
		while(o<r.length() && r.charAt(o)=='0') {
			o++;
		}
		while(o<r.length()) {
			f+=r.charAt(o);o++;
		}
		if(f.length()==0)return "0";
		return f;
	}
	static long sub(String b,boolean flag) {
		StringBuilder re=new StringBuilder();
		for(int i=0;i<b.length();i++) {
			if(b.charAt(i)=='0') {
				if(re.length()==0)continue;
				re.append('0');
			}
			else {
				re.append((char)('9'+'1'-b.charAt(i)));
			}
		}
		if(re.length()==0) {
			return 0;
		}
		if(flag) {
			StringBuilder o=new StringBuilder();
			for(int i=0;i<re.length();i++) {
				if(re.charAt(i)=='0') {
					o.append('9');
				}
				else
					if(re.charAt(i)=='1' && o.length()==0) {
						continue;
					}
					else
						o.append((char)(re.charAt(i)-1));
			}
			if(o.length()==0) {
				return 0;
			}
			return Long.parseLong(o.toString());
		}
		return Long.parseLong(re.toString());
	}
	static long k;static int n;
	static char[]in;
	static HashSet<StringBuilder>[]sets;
	static StringBuilder [][][]memo;
	static int x=1;
    public static void main(String[] args) throws Exception{
        MScanner sc = new MScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int r=sc.nextInt();int c=sc.nextInt();int n=sc.nextInt();int k=sc.nextInt();
        char[][]in=new char[r][c];
        for(int i=0;i<n;i++) {
        	in[sc.nextInt()-1][sc.nextInt()-1]='*';
        }
        int ans=0;
        for(int i=0;i<r;i++) {
        	for(int j=0;j<c;j++) {
        		int sum=0;
        		for(int z=0;z<r;z++) {
                	for(int o=0;o<c;o++) {
                		if(in[z][o]=='*') {
                			sum++;
                		}
                		if(sum>=k)ans++;
                	}
                }
        	}
        }
        pw.println(ans);
        pw.flush();
    }
    static class tri implements Comparable<tri>{
    	int x;int y;
    	tri(int a,int b){
    		x=a;y=b;
    	}
		@Override
		public int compareTo(tri o) {
			if(x!=o.x) {
				return x-o.x;
			}
				return y-o.y;

		}
		public String toString() {
			return "("+x+" "+y+")";
		}
    }
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;

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

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

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

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

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

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

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

    }
}


import java.util.Scanner;

public class CFProblemA {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		int d1 = input.nextInt();
		int d2 = input.nextInt();
		int c = input.nextInt();
		boolean good = false;
		for(int a = 0; a < c/d1 + 10; a++){
			if(c - a*d1 >= 0 && (c-a*d1)%d2 == 0){
				good = true;
			}
		}
		if(good){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}

	}

}


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

public class Main{

    BufferedReader in;
    StringTokenizer str = null;
    PrintWriter out;

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

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

    public void run() throws Exception{
    	in = new BufferedReader(new InputStreamReader(System.in));
    	out = new PrintWriter(System.out);

	String date1 = next();
	String date2 = next();

	if (compare(date1, date2)) {
	    String c = date1;
	    date1 = date2;
	    date2 = c;
	}

	int month[] = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	String a[] = date1.split(":");
	int y = Integer.parseInt(a[0]);
	int m = Integer.parseInt(a[1])-1;
	int d = Integer.parseInt(a[2]);

	a = date2.split(":");
	int fy = Integer.parseInt(a[0]);
	int fm = Integer.parseInt(a[1])-1;
	int fd = Integer.parseInt(a[2]);

	int r = 0;
	while(3 < 4){

	    if (y == fy && m == fm && d == fd) break;
	    if (isLeapYear(y)) month[1] = 29;
	    else month[1] = 28;

	    d++;
	    if (d > month[m]){
		d = 1;
		m++;
		if (m > 11){
		    m = 0;
		    y++;
		}
	    }
	    r++;
	}
	out.println(r);
	out.close();
    }

    private boolean compare(String d1, String d2){
	String a[] = d1.split(":");
	String b[] = d2.split(":");
	for(int i=0;i<a.length;i++){
	    if (Integer.parseInt(a[i]) > Integer.parseInt(b[i]))
		return true;
	}
	return false;
    }

    private boolean isLeapYear(int year){
	return year%4 == 0 && (year%100!=0 || year%400==0);
    }

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


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

public class DovletCalculator {
	private static final int[] DIGIT_COUNT = new int[] { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
	//private static int sumDigigts;

	public static void main(String[] args) throws IOException {
		int a, b;
		{
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			String line = in.readLine();
			StringTokenizer st = new StringTokenizer(line);
			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());
			in.close();
		}

//		for (int d : DIGIT_COUNT) {
//			sumDigigts += d;
//		}

		System.out.println(countDigits(a, b));
	}

	private static int countDigits(int a, int b) {

		//System.out.format("a = %d, b=%d\n", a, b);
		if (a > b) {
			return 0;
		}

		int sum = 0;
		if (a == b) {
			while (a > 0) {
				sum += DIGIT_COUNT[a % 10];
				a /= 10;
			}
			return sum;
		}

		if ( b < 10 ) {
			for (int i = a; i <=b ; i++) {
				sum += DIGIT_COUNT[i];
			}
			return sum;
		}
		int baseA = 1, baseB;
		while (baseA <= a) {
			baseA *= 10;
		}
		baseA /= 10;
		baseB = baseA;
		while (baseB <= b) {
			baseB *= 10;
		}
		baseB /= 10;
		if (baseB == baseA) {
			int leadA = a / baseA;
			int leadB = b / baseB;
			if (leadA == leadB) {
				sum = DIGIT_COUNT[leadA] * (b - a + 1) + countDigits(a - leadA * baseA, b - leadA * baseB);
			} else {
				sum += countDigits(a, (leadA + 1) * baseB  - 1);
				for (int i = leadA + 1; i < leadB; i++) {
					sum += countDigits(i * baseB , (i + 1) * baseB - 1);
				}
				sum += countDigits(leadB * baseB, b);
			}
		} else {
			sum = countDigits(a, baseA * 10 - 1) + countDigits(baseA * 10, b);
		}
		return sum;
	}

}


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

/**
 * Created by vignesh on 6/30/2017.
 */
public class queueAtSchool {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n =in.nextInt();
        int t = in.nextInt();
        String q = in.next();
        String[] arr = new String[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Character.toString(q.charAt(i));
        }
        for (int i = 0; i < n - 1; i++) {
            if(arr[i].equals("B")){
                int bindex = i + 1;
                int count = 0;
                while(count<t &&i!=n-1){
                    if(bindex <= n - 1 &&arr[bindex].equals("G")){
                        String temp = arr[i];
                        arr[i] = arr[bindex];
                        arr[bindex] = temp;
                        count++;
                        i = i + 1;
                    }
                    bindex++;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.print(arr[i]);
        }
    }
}


import java.util.*;
import java.io.*;
public class a
{
	public static void main(String[] args) throws IOException
	{
		new a();
	}
	TreeSet<Long> ts;
	public a() throws IOException
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		ArrayList<Long> list = new ArrayList<Long>();
		ts = new TreeSet<Long>();
		for(long i = 1; ;i++)
		{
			if(i*i*i > 1_000_000_000_000_000l) break;
			list.add(i);
			ts.add(i*i*i);
		}
		long[] dp = new long[101];
		for(int i = 1; i <= 100; i++)
		{
			dp[i] = solve(i);
		}
		long m = in.nextLong();
		long op1 = 0;
		long op2 = 0;
		for(long i = m; i >= m-10_000_000; i--)
		{
			long v = solve(i);
			if(v > op2)
			{
				op2 = v;
				op1 = i;
			}
		}
		System.out.println(op2 + " " + op1);
		in.close(); out.close();
	}
	long solve(long target)
	{
		int ret = 0;
		while(target > 0)
		{
			Long v = ts.floor(target);
			if(v == null) return ret;
			ret++;
			target -= v;
		}
		return ret;
	}
	class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
		public void close() throws IOException
		{
			br.close();
		}
	}

}


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

public class D
{

	public long floorCube(long n)
	{
		for (long i = 1; i<= n; i++)
		{
			if (i*i*i > n)
				return(i-1);
			else if (i*i*i == n)
				return(i);
		}
		return(0);

	}

	public long Cube(long j)
	{
		return(j*j*j);
	}

	public long NoCubes(long k)
	{
		long volleft = k;
		long num = 0;
			while (volleft != 0)
			{
				long j = floorCube(volleft);

				if (j == 1)
				{
					num += volleft;
					volleft = 0;
					break;
				}

				volleft -= Cube(j);
				num += 1;
			}

		return(num);
	}

	public static void main(String args[])throws IOException
	{
		Scanner sc = new Scanner (System.in);
		long m = sc.nextLong();
		D dd = new D();
		long max = 0;
		long X = 0;

		for (long i = m/2; i<= m; i++)
		{
			if (dd.NoCubes(i) >= max)
			{
				max = dd.NoCubes(i);
				X = i;
			}
		}
		System.out.println(max+" "+X);

	}

}


import java.util.*;
public class _976A
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int len = scan.nextInt();
		String s = scan.next();
		int i, ones = 0, zeros = 0;
		for(i = 0 ; i < len ; i++)
			if(s.charAt(i) == '1')	ones++;
			else					zeros++;
		StringBuilder sb = new StringBuilder();
		sb.append("1");
		for(i = 0 ; i < zeros ; i++)
			sb.append("0");
		System.out.println(sb);
		scan.close();

	}

}


import java.io.*;

/**
 * Created by James on 1/29/2015.
 */

public class Driver {
    public static void main(String [] args) throws IOException {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int N = Integer.parseInt(scanner.readLine().trim()), count = 0;

        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= N; ++j) {
                for (int k = 1; k <= N; ++k) {
                    if (d(d(i) * d(j)) == d(k) && i * j != k) {
                        //out.println(i + " " + j + " " + k);
                        count++;
                    }
                }
            }
        }

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

    private static int d(int N) {
        if (N < 10) {
            return N;
        }

        String num = Integer.toString(N);
        int sum = 0;

        for (int i = 0; i < num.length(); ++i) {
            sum += Integer.parseInt(String.valueOf(num.charAt(i)));
        }

        return d(sum);
    }
}


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

public class Championship {

    void solve() throws IOException {
        int n = nextInt();
        int ax = nextInt();
        int bx = nextInt();

        int a = Math.max(ax, bx);
        int b = Math.min(ax, bx);

        int mid = n / 2;

        int totalRounds = 0;
        int nTmp = n;
        while ((nTmp >>= 1) > 0) totalRounds++;

        n = n / 2;
        int roundsFromFinal = 0;
        while (!(a > mid && b <= mid)) {
            roundsFromFinal++;
            if (a <= mid) {
                mid = mid / 2;
            } else {
                mid = mid + n / 2;
            }
            n = n / 2;
        }

        System.out.println(roundsFromFinal == 0 ? "Final!" : totalRounds - roundsFromFinal);
    }

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

    void run() throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
//		reader = new BufferedReader(new FileReader("input.in"));
        tokenizer = null;
        out = new PrintWriter(new OutputStreamWriter(System.out));
//		out = new PrintWriter(new FileWriter("output.out"));
        solve();
        reader.close();
        out.flush();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;

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

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

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

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


import java.util.*;
import java.io.*;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String s1[]=br.readLine().split(" ");
            String s2[]=br.readLine().split(" ");
            int n=Integer.parseInt(s1[0]);
            int m=Integer.parseInt(s1[1]);
            int l=Integer.parseInt(s1[2]);
            int r=Integer.parseInt(s1[3]);
            long g=Long.parseLong(s2[0]);
            long x=Long.parseLong(s2[1]);
            long y=Long.parseLong(s2[2]);
            long z=Long.parseLong(s2[3]);

            long a[][]=new long[n][m];
            long b[][]=new long[n][m];
            long c[][]=new long[n][m];
            for(int i=0;i<n;i++)
            {
                  for(int j=0;j<m;j++)
                  {
                        a[i][j]=g;
                        g=(g*x+y)%z;
                  }
            }

            for(int j=0;j<m;j++)
            {
                  Deque<Integer> dq=new LinkedList<Integer>();
                  for(int i=0;i<l;i++)
                  {
                        while(!dq.isEmpty() && a[i][j]<=a[dq.peekLast()][j])
                         dq.pollLast();
                        dq.addLast(i);
                  }

                  for(int i=l;i<n;i++)
                  {
                        b[i-1][j]=a[dq.peek()][j];
                        while(!dq.isEmpty() && dq.peek()<=i-l)
                         dq.poll();
                        while(!dq.isEmpty() && a[i][j]<=a[dq.peekLast()][j])
                         dq.pollLast();
                        dq.addLast(i);
                  }
                  b[n-1][j]=a[dq.peek()][j];
            }

            for(int i=l-1;i<n;i++)
            {
               Deque<Integer> dq=new LinkedList<Integer>();
               for(int j=0;j<r;j++)
               {
                     while(!dq.isEmpty() && b[i][j]<=b[i][dq.peekLast()])
                      dq.pollLast();
                     dq.addLast(j);
               }

               for(int j=r;j<m;j++)
               {
                    //System.out.println(i+" "+j);
                    c[i][j-1]=b[i][dq.peek()];
                    while(!dq.isEmpty() && dq.peek()<=j-r)
                     dq.poll();
                    while(!dq.isEmpty() && b[i][j]<=b[i][dq.peekLast()])
                      dq.pollLast();
                    dq.addLast(j);
               }
               c[i][m-1]=b[i][dq.peek()];
            }

            long S=0;
            StringBuffer sb=new StringBuffer();
            StringBuffer sb1=new StringBuffer();
            for(int i=0;i<n;i++)
            {
            for(int j=0;j<m;j++)
            {
              S+=c[i][j];
             sb.append(b[i][j]).append(" ");
             sb1.append(c[i][j]).append(" ");
            }
            sb.append("\n");
            sb1.append("\n");
            }
         //   System.out.println(sb);
         //   System.out.println();
         //   System.out.println(sb1);
         //   System.out.println();
            System.out.println(S);
      }
}


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

public class EEE {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        long g = scanner.nextInt();
        long X = scanner.nextInt();
        long Y = scanner.nextInt();
        long Z = scanner.nextInt();
        long[][] mat = new long[N][M];
        SegmentTree[] sgs = new SegmentTree[N];
        for(int i =0; i < N; i++) {
            sgs[i] = new SegmentTree(M);
            sgs[i].init(0, M - 1, 1);
        }
        int c = 0;
        while(c < N*M) {
            int r = c / M;
            int col = c%M;
            mat[r][col] = g;
            sgs[r].increment(1, col, col, g);
            g = (g*X + Y)% Z;
            c++;
        }
        long ans = 0;
        SegmentTree[] mins = new SegmentTree[M-B+1];
        for(int i = 0; i < M-B+1; i++) {
            mins[i] = new SegmentTree(N);
            mins[i].init(0, N-1, 1);
        }
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < M-B+1; j++) {
                mins[j].increment(1, i, i, sgs[i].minimum(1, j, j + B-1));
            }
        }
        for(int i = 0; i < M-B+1; i++) {
            for(int j = 0; j < N-A+1; j++) {
                ans += mins[i].minimum(1, j, j + A-1);
            }
        }
        out.println(ans);
        out.flush();
    }

    public static class SegmentTree {
        int size;
        int[] hi, lo;
        long[] min, delta;
        public SegmentTree(int size) {
            this.size = size;
            lo = new int[4*size+1];
            hi = new int[4*size+1];
            min = new long[4*size+1];
            delta = new long[4*size+1];
        }
        public void init(int l, int r, int cur) {
            lo[cur] = l;
            hi[cur] = r;
            if (l == r) return;
            int mid = (l + r) /2;
            init(l, mid, cur*2);
            init(mid+1, r, cur*2+1);
        }
        void increment(int cur,  int l, int r, long amt) {
            if (r < lo[cur] || l > hi[cur]) return;
            if (l <= lo[cur] && r >= hi[cur]) {
                delta[cur] += amt;
                return;
            }
            prop(cur);
            increment(cur*2, l, r, amt);
            increment(cur*2+1, l, r, amt);
            update(cur);

        }
        long minimum (int cur, int l, int r) {
            if (r < lo[cur] || l > hi[cur]) return Long.MAX_VALUE;
            if (l <= lo[cur] && r >= hi[cur]) return min[cur] + delta[cur];
            prop(cur);
            long min1 = minimum(2*cur, l, r);
            long min2 = minimum(2*cur+1, l, r);
            update(cur);
            return Math.min(min1, min2);
        }
        void prop (int cur) {
            delta[2*cur] += delta[cur];
            delta[2*cur+1] += delta[cur];
            delta[cur] = 0;
        }
        public void update(int cur) {
            min[cur] = Math.min(min[2*cur] + delta[2*cur], min[2*cur+1] + delta[2*cur+1]);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

        public FastScanner() {
            this(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 readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

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

    static class B449 {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int k = in.scanInt();
            int p = in.scanInt();

            long ans = 0;
            int temp = 0;
            int i = 1;
            while (temp != k) {
                int rev = 0;
                int n = i;
                int l = 0;
                while (n > 0) {
                    rev = rev * 10 + (n % 10);
                    n = n / 10;
                    l++;
                }

                if (i == rev && l % 2 == 0) {
                    temp++;
                    ans += i;
                }
                i++;
            }
            System.out.println(ans % p);
        }

    }

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

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

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

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

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

    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class C {

	static int arr[];

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

		arr = new int[6];

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

		while(arr[0] != arr[2])
		{
			rotate();
		}

		int fac = arr[0] + arr[0] + 1;
		int len = arr[1];

		long res = 0;

		for(int i = 0; i < len; ++i)
		{
			res += fac;

			fac += 2;
		}

		fac = arr[3] + arr[3] + 1;
		len = arr[4];

		for(int i = 0; i < len; ++i)
		{
			res += fac;

			fac += 2;
		}

		out.println(res);

		out.flush();
		out.close();
	}

	static void rotate()
	{
		int tmp = arr[5];

		for(int i = 5; i > 0; --i) arr[i] = arr[i - 1];
		arr[0] = tmp;
	}

	static class Scanner{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

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


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

/**
 *
 * @author thachlp
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        FastReader fr = new FastReader();
        long candies = fr.nextLong();

        if (candies < 10) {
            System.out.println(1);
            return;
        }

        long m = 0;
        if (candies % 2 != 0) {
            m = candies / 2 + 1;
        } else {
            m = candies / 2;
        }
        long l = 1;
        long r = (long) Math.floor(candies / 10);
        List<Long> nums = new ArrayList<>();
        while (l <= r) {
            long tmp = candies;
            long k = (l + r) / 2;
            long vas = 0;
            //int pet = 0;
            while (tmp >= k) {
                vas += k;
                tmp -= k;
                long q = (int) Math.floor(tmp / 10);
                tmp -= q;
                if (tmp < k) {
                    vas += tmp;
                    break;
                }

            }
            if (vas == m) {
                System.out.println(k);
                return;
            } else if (vas > m) {
                nums.add(k);
                r = k - 1;
            } else {
                l = k + 1;
            }
        }
        System.out.println(min(nums));

    }

    static long min(List<Long> nums) {
        long min = Long.MAX_VALUE;
        for (long e : nums) {
            min = Math.min(min, e);
        }
        return min;
    }

}

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) {
            }
        }
        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) {
        }
        return str;
    }
}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

        int n = in.nextInt();
        long l = in.nextLong();
        long r = in.nextLong();
        int x = in.nextInt();

        List<Integer> problems = new ArrayList();
        for (int i = 0; i < n; i++) {
            problems.add(in.nextInt());
        }

        Set<String> problemSet = new HashSet();
        String bitMask = "";
        for (int i = 0; i < n; i++) {
            bitMask += "1";
        }

        problemSet = process(problems, bitMask, l, r, x, problemSet, n);
        out.println(problemSet.size());
    }

    private static String calculateSum(List<Integer> problems, String bitMask, long minValue, long maxValue, int diff) {
        int sum = 0;
        String bitMaskTemp = "";
        int minimum = Integer.MAX_VALUE, maximum = Integer.MIN_VALUE;
        for (int i = 0; i < problems.size(); i++) {
            if(bitMask.charAt(i) == '1') {
                sum += problems.get(i);
                if(problems.get(i) < minimum) minimum = problems.get(i);
                if(problems.get(i) > maximum) maximum = problems.get(i);
            }
        }
        int difference = maximum - minimum;
        if(sum >= minValue && sum <= maxValue && difference >= diff) {
            bitMaskTemp = bitMask;
        }
        return bitMaskTemp;
    }

    private static Set<String> process(List<Integer> problems, String bitMask, long minValue, long maxValue, int difference, Set<String> problemSet, int problemsCounter) {
        String resp = calculateSum(problems, bitMask, minValue, maxValue, difference);
        if(!resp.isEmpty()) problemSet.add(bitMask);
        if(problemsCounter == 2) return problemSet;

        for (int i = 0; i < problems.size(); i++) {
            if(bitMask.charAt(i) == '1') {
                String bitMaskTemp = bitMask.substring(0, i) + '0' + bitMask.substring(i+1);
                problemSet = process(problems, bitMaskTemp, minValue, maxValue, difference, problemSet, problemsCounter-1);
            }
        }
        return problemSet;
    }
}


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

public class E {
	FastScanner in;
	PrintWriter out;

	int[] cx = new int[] { 2, 1, -1, -2, -1, 1 };
	int[] cy = new int[] { 0, 2, 2, 0, -2, -2 };

	int[] dirx = new int[] { -1, -2, -1, 1, 2, 1 };
	int[] diry = new int[] { 2, 0, -2, -2, 0, 2 };

	void solve() {
		long n = in.nextLong();
		if (n == 0) {
			out.println("0 0");
			return;
		}
		long cnt = 0;
		for (long i = 1;; i++) {
			long cur = 6 * i;
			if (cnt + cur >= n) {
				//System.err.println("circle " + i);
				for (int j = 0; j < 6; j++) {
					if (cnt + i >= n) {
						long stx = cx[j] * i, sty = cy[j] * i;
						//System.out.println(stx + " " + sty);
						long num = n - cnt;
						long rx = stx + num * dirx[j], ry = sty + num * diry[j];
						out.println(rx + " " + ry);
						//System.out.println(num);
						return;
					}
					cnt += i;
				}
				return;
			}
			cnt += cur;
		}
	}

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					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[] args) {
		new E().run();
	}
}


import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long y = sc.nextLong();
		long num1 = x;
		long num2 = y;
		while(y != 0) {
        	if(x > y)
                x = x - y;
            else
                y = y - x;
        }
		long temp = x;
		num1 = num1/temp;
		num2 = num2/temp;
		System.out.println(Math.min((a/num1),(b/num2)));
	}
}


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

/***************************
 * D.R.Y Don't Repeat Yourself
 * K.I.S Keep It Simple
 * B.W.U.N Build What You Need
 * W.N.W  Why? Not What?
 ***************************/
public class B478 {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;

    void solve() throws IOException {
        long n = nextLong(), m = nextLong();
        long min = 0;
        long max = ((n-m+1)*(n-m))/2;
        long mod = n % m;
        long div = n/m;
        long[] arr = new long[(int)m];
        for(int i = 0; i < m ;i++){
            arr[i] = div;
            if(mod > 0){
                arr[i]++;
                mod--;
            }
            min+=form1(arr[i]);
        }

        System.out.println(min + " " + max);
    }

    public static long form1(long n){
        return (n*(n-1))/2;
    }

    B478() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

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

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

    String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }

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

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

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


//package codeforces;

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

public class E {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

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

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

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

    @SuppressWarnings("unchecked")
    void solve() throws IOException {
        int x = nextInt();
        int k = nextInt();
        double p = 0.01 * nextInt();
        double ans = solve(x, k, p);
        writer.printf(Locale.US, "%.10f\n", ans);
        writer.close();
    }

    private double solve(int x, final int k, double p) {
        double q = 1.0 - p;
        class SmartNumber {
            int shift;
            int r;
            final int CAP = 1 << 8;

            SmartNumber(int x) {
                int y = x + k;
                y ^= x;
                y = Integer.highestOneBit(y);
                shift = Math.max(Integer.numberOfTrailingZeros(y), Integer.numberOfTrailingZeros(x));
                x &= (1 << shift + 1) - 1;
                r = x - (1 << shift);
            }

            SmartNumber(int shift, int r) {
                if(r > 0) {
                    shift = 0;
                }
                if(r < -k) {
                    shift = 0;
                    r &= CAP - 1;
                }
                if(r > CAP) {
                    if(r % CAP == 0) {
                        shift = Integer.numberOfTrailingZeros(r);
                        r = 0;
                    } else {
                        int x = r;
                        int y = x + k;
                        y ^= x;
                        y = Integer.highestOneBit(y);
                        shift = Math.max(Integer.numberOfTrailingZeros(y), Integer.numberOfTrailingZeros(x));
                        x &= (1 << shift + 1) - 1;
                        r = x - (1 << shift);
                    }
                }
                this.shift = shift;
                this.r = r;
            }

            SmartNumber inc() {
                return new SmartNumber(shift, r + 1);
            }

            SmartNumber shift() {
                return new SmartNumber(shift + 1, r * 2);
            }

            int zeroes() {
                if(r == 0) return shift;
                return Integer.numberOfTrailingZeros(r);
            }

            @Override
            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;

                SmartNumber that = (SmartNumber) o;

                if (r != that.r) return false;
                if (shift != that.shift) return false;

                return true;
            }

            @Override
            public int hashCode() {
                int result = shift;
                result = 31 * result + r;
                return result;
            }

            @Override
            public String toString() {
                return "SmartNumber{" +
                        "shift=" + shift +
                        ", r=" + r +
                        '}';
            }
        }
        class DebugSmartNumber extends SmartNumber {
            DebugSmartNumber parent;
            long x;
            DebugSmartNumber(int x) {
                super(x);
                this.x = x;
            }

            DebugSmartNumber(int shift, int r) {
                super(shift, r);
            }

            @Override
            SmartNumber inc() {
                DebugSmartNumber dsm = new DebugSmartNumber(shift, r + 1);
                dsm.x = x + 1;
                dsm.parent = this;
                dsm.check();
                return dsm;
            }

            @Override
            SmartNumber shift() {
                DebugSmartNumber dsm = new DebugSmartNumber(shift + 1, r * 2);
                dsm.x = x * 2;
                dsm.parent = this;
                dsm.check();
                return dsm;
            }

            void print() {
                if(parent != null) {
                    parent.print();
                }
                System.out.println(toString());
            }

            @Override
            public String toString() {
                return "DebugSmartNumber{" +
                        "x=" + x + ", " + Long.toBinaryString(x) +
                        "} " + super.toString();
            }

            void check() {
                if(zeroes() != Long.numberOfTrailingZeros(x)) {
                    print();
                    throw new RuntimeException("encoding sucks");
                }
            }

            @Override
            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                if (!super.equals(o)) return false;

                DebugSmartNumber that = (DebugSmartNumber) o;

                if (x != that.x) return false;

                return true;
            }

            @Override
            public int hashCode() {
                int result = super.hashCode();
                result = 31 * result + (int) (x ^ (x >>> 32));
                return result;
            }
        }
        List<Map<SmartNumber, Double>> dp = new ArrayList<>(k + 1);
        for(int i = 0; i <= k; i++) {
            dp.add(new HashMap<SmartNumber, Double>());
        }
        dp.get(0).put(new SmartNumber(x), 1.0);
        for(int i = 0; i < k; i++) {
//            System.out.println(i + " " + dp.get(i).size());
            for (Map.Entry<SmartNumber, Double> entry : dp.get(i).entrySet()) {
                increment(dp.get(i + 1), entry.getKey().shift(), p * entry.getValue());
                increment(dp.get(i + 1), entry.getKey().inc(), q * entry.getValue());
            }
        }
        double ans = 0;
        for (Map.Entry<SmartNumber, Double> entry : dp.get(k).entrySet()) {
            ans += entry.getKey().zeroes() * entry.getValue();
        }
        return ans;
    }

    <K> void increment(Map<K, Double> map, K key, double value) {
        value += map.containsKey(key) ? map.get(key) : 0;
        map.put(key, value);
    }

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


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

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

class TaskE {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int x = in.nextInt(), n = in.nextInt(), p = in.nextInt();
        double[][][][] prob = new double[n + 1][n + 16][256][2];
        if (x / 256 % 2 == 0) {
            prob[0][x < 256 ? 0 : Integer.numberOfTrailingZeros(x / 256)][x % 256][0] = 1.0;
        } else {
            prob[0][Integer.numberOfTrailingZeros(x / 256 + 1)][x % 256][1] = 1.0;
        }
        for (int i = 0; i < n; ++i) {
            for (int high = 0; high < n + 15; ++high) {
                for (int low = 0; low < 256; ++low) {
                    double p1 = (double)p / 100.0, p2 = 1.0 - p1;
                    if (low < 128) {
                        prob[i + 1][high == 0 ? 0 : high + 1][low * 2 % 256][0] += prob[i][high][low][0] * p1;
                        prob[i + 1][1][low * 2 % 256][0] += prob[i][high][low][1] * p1;
                    } else {
                        prob[i + 1][1][low * 2 % 256][1] += prob[i][high][low][0] * p1;
                        prob[i + 1][high + 1][low * 2 % 256][1] += prob[i][high][low][1] * p1;
                    }
                    if (low < 255) {
                        prob[i + 1][high][(low + 1) % 256][0] += prob[i][high][low][0] * p2;
                        prob[i + 1][high][(low + 1) % 256][1] += prob[i][high][low][1] * p2;
                    } else {
                        prob[i + 1][1][0][1] += prob[i][high][low][0] * p2; ////
                        prob[i + 1][high][0][0] += prob[i][high][low][0] * p2;
                    }
                }
            }
        }
        double res = 0.0;
        for (int high = 0; high < n + 16; ++high) {
            for (int low = 0; low < 256; ++low) {
                res += prob[n][high][low][0] * (low == 0 ? 8 + high : Integer.numberOfTrailingZeros(low));
                res += prob[n][high][low][1] * Integer.numberOfTrailingZeros(low);
            }
        }
        out.printf("%.13f\n", res);
    }
}


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

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

    static class TaskC {
        public void solve(int testNumber, InputReader fi, PrintWriter out) {
            long n = fi.nextLong();
            long low, mid, high;
            low = 0;
            high = n;
            long ans = 0;
            while (low < high) {
                mid = (low + high) / 2;
                if (madarchodM(n, mid)) {
                    ans = mid;
                    high = mid;
                } else {
                    low = mid + 1;
                }
            }
            out.println(ans);
        }

        boolean madarchodM(long n, long k) {

            long ans = 0;
            long prevn = n;
            while (n > 0) {
                ans += Math.min(n, k);
                n = n - k;
                n = n - (n / 10);
            }
            if (ans >= prevn / 2) return true;
            else return false;
        }

    }

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

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

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

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

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

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

        }

    }
}


/*Author LAVLESH*/
import java.util.*;
import java.io.*;
public class solution{
	static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st=new StringTokenizer("");
	static int basechange(int n)
	{
		StringBuilder st=new StringBuilder("");
		while(n>0){
			st.append(n%7);n/=7;
		}
		st.append(n);
		return Integer.parseInt(st.reverse().toString());

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

	public static void main(String[]args)throws IOException{
         long ans=0;PrintStream op = System.out;
		 int n=Integer.parseInt(next());
		 int m=Integer.parseInt(next());
		int []a=new int[n];
		int []b=new int [m];
		for(int i=0;i<n;i++)
		{
			a[i]=basechange(i);//op.println(a[i]);
		}
		for(int i=0;i<m;i++)
		{
			 b[i]=basechange(i);
		}
		StringBuilder p=new StringBuilder().append(a[n-1]).append(b[m-1]);
		int l=p.length();
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				StringBuilder s=new StringBuilder();
				s.append(a[i]);s.append(b[j]);
				while(s.length()<l) s.append("0",0,1);
				int f=0;
				String S=s.toString();int []x=new int[10];
				for(int k=0;k<S.length();k++)
				{
					int y=Integer.parseInt(""+s.charAt(k));
					x[y]++;
					if(x[y]>1)
{
	f=1;
}

				}
				if(f==0){ans++;f=0;}//System.out.println(s);}
			}
		}

		 op.println(ans);
		  op.close();
		}
	}


/*package whatever //do not write package name here */

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

public class Main {
    public static void main (String[] args) {
        //code
        Scanner in = new Scanner(System.in);
        int t =in.nextInt();
        if(t%4==1){
            System.out.println("0 A");
        }
        else if(t%4==0){
            System.out.println("1 A");
        }
        else if(t%4==3){
            System.out.println("2 A");
        }
        else{
            System.out.println("2 B");
        }
    }
}


public class A{
    public static void main(String[] args){
        int n = new java.util.Scanner(System.in).nextInt();
        int l = 0;
        boolean bool = false;
        char ch[] = {'A', 'B', 'C' ,'D'};
        for(int i = 0, k = 1; i < 4;){

            for(int j = 0; j < 3; j++){
                if((n+j)%4==k){
                    bool=true;
                    System.out.print(j +" "+ch[i]);
                    break;
                }
                if(bool){
                    break;
                }
                i++;
                if(i<2){
                    k+=2;
                }else if(i==2){
                    k -= 1;
                }else{
                    k-=2;
                }
            }
        }
    }
}


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

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

                   int n = sc.nextInt();
                   int count=0,sum=0,ans=0;
                   while(ans<=n){
                   for(int i=1;i<n;i++){
                            sum+=i;
                            ans+=sum;
                            count++;
                            if(ans>n){
                            break;
                   }
                   }
                   }
                            System.out.println(count-1);

                   }

}


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

public class Problem {

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

        int n, x, y, c;
        n = input.nextInt();
        x = input.nextInt();
        y = input.nextInt();
        c = input.nextInt();
        x--;
        y--;

        boolean[][] array = new boolean[n][n];
        array[x][y] = true;
        int counter = 1;
        ArrayList<Integer[]> al = new ArrayList<>();
        al.add(new Integer[]{x, y});
        int start = 0, end,sc = 0,fc = 0 ;
        while (counter < c) {
            fc++;
            end = al.size();
            for (int i = start; i < end; i++) {
                sc++;
                if (al.get(i)[0] - 1 >= 0 && !array[al.get(i)[0] - 1][al.get(i)[1]]) {
                    array[al.get(i)[0] - 1][al.get(i)[1]] = true;
                    al.add(new Integer[]{al.get(i)[0] - 1, al.get(i)[1]});
                    counter++;
                }
                if (al.get(i)[0] + 1 < n && !array[al.get(i)[0] + 1][al.get(i)[1]]) {
                    array[al.get(i)[0] + 1][al.get(i)[1]] = true;
                    al.add(new Integer[]{al.get(i)[0] + 1, al.get(i)[1]});
                    counter++;
                }
                if (al.get(i)[1] - 1 >= 0 && !array[al.get(i)[0]][al.get(i)[1] - 1]) {
                    array[al.get(i)[0]][al.get(i)[1] - 1] = true;
                    al.add(new Integer[]{al.get(i)[0], al.get(i)[1] - 1});
                    counter++;
                }
                if (al.get(i)[1] + 1 < n && !array[al.get(i)[0]][al.get(i)[1] + 1]) {
                    array[al.get(i)[0]][al.get(i)[1] + 1] = true;
                    al.add(new Integer[]{al.get(i)[0], al.get(i)[1] + 1});
                    counter++;
                }
            }
            start += sc ;
        }
        System.out.println(fc);
    }
}