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

public class Main {

	static int MOD = 1000 * 1000 * 1000 + 7;

	public static void main(String[] args) {

		InputStream  inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		solve(in, out);
		out.close();
		System.exit(0);
	}

	private static void solve(InputReader in, PrintWriter out) {

		int[][] tab = new int[3][2];
		for (int i = 0; i < 3; i++) {
			tab[i][0] = in.nextInt();
			tab[i][1] = in.nextInt();
		}

		if (tab[0][0] == tab[1][0] && tab[1][0] == tab[2][0]) {
			out.print(1);
			return;
		}
		if (tab[0][1] == tab[1][1] && tab[1][1] == tab[2][1]) {
			out.print(1);
			return;
		}

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (i == j) {
					continue;
				}
				for (int k = 0; k < 3; k++) {
					if (k == i || k == j) {
						continue;
					}
					if (tab[k][0] < Math.min(tab[i][0], tab[j][0]) || tab[k][0] > Math.max(tab[i][0], tab[j][0])) {
						continue;
					}
					if (tab[k][1] < Math.min(tab[i][1], tab[j][1]) || tab[k][1] > Math.max(tab[i][1], tab[j][1])) {
						continue;
					}
					if (tab[k][0] == tab[i][0] || tab[k][0] == tab[j][0] || tab[k][1] == tab[i][1]
							|| tab[k][1] == tab[j][1]) {
						out.print(2);
						return;
					}
				}
			}
		}

		out.print(3);

	}

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

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

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

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

			return str;
		}
	}
}


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

public class Main{

    public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer(br.readLine());
int n=Integer.parseInt(st.nextToken());
st=new StringTokenizer(br.readLine());
int Nchest=0;
int Nbiceps=0;
int Nback=0;
int w=2;
        for (int i =1; i <=n; i++) {
            if(i % 3==0)
                Nback+=Integer.parseInt(st.nextToken());
            else if(i==w){
                w=w+3;
                Nbiceps+=Integer.parseInt(st.nextToken());
            }
            else
                Nchest+=Integer.parseInt(st.nextToken());

        }
if(Nchest > Nbiceps && Nchest > Nback)
            System.out.println("chest");
else if( Nbiceps> Nchest && Nbiceps > Nback)
            System.out.println("biceps");
else
    System.out.println("back");
    }

}


import java.util.Scanner;

public class SimpleMoecules {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int c = input.nextInt();
		if((c+b-a)%2==0){
			int z  = (c+b-a)/2;
			if(z<0){
				System.out.println("Impossible");
				return;
			}
			int y = c-z;
			if(y<0){
				System.out.println("Impossible");
				return;
			}
			int x = a-y;
			if(x<0){
				System.out.println("Impossible");
				return;
			}
			else
				System.out.println(x+" "+z+" "+y);
		}
		else
			System.out.println("Impossible");
	}

}


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

public class Task886A {

    public static void main(String... args) throws NumberFormatException,
            IOException {
        Solution.main(System.in, System.out);
    }

    static class Scanner {

        private final BufferedReader br;
        private String[] cache;
        private int cacheIndex;

        Scanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
            cache = new String[0];
            cacheIndex = 0;
        }

        int nextInt() throws IOException {
            if (cacheIndex >= cache.length) {
                cache = br.readLine().split(" ");
                cacheIndex = 0;
            }
            return Integer.parseInt(cache[cacheIndex++]);
        }

        long nextLong() throws IOException {
            if (cacheIndex >= cache.length) {
                cache = br.readLine().split(" ");
                cacheIndex = 0;
            }
            return Long.parseLong(cache[cacheIndex++]);
        }

        String next() throws IOException {
            if (cacheIndex >= cache.length) {
                cache = br.readLine().split(" ");
                cacheIndex = 0;
            }
            return cache[cacheIndex++];
        }

        void close() throws IOException {
            br.close();
        }

    }

    static class Solution {

        public static void main(InputStream is, OutputStream os)
                throws NumberFormatException, IOException {
            PrintWriter pw = new PrintWriter(os);
            Scanner sc = new Scanner(is);

            List<Integer> a = new ArrayList<>(6);

            int sum = 0;

            for(int i = 0 ; i < 6 ; i++){
                int tmp = sc.nextInt();
                sum += tmp;
                a.add(tmp);
            }

            boolean found = false;

            for(int i = 0 ; i < 6 ; i++){
                for(int j = i +1 ; j < 6 ; j++){
                    for(int k = j + 1 ; k < 6 ; k++){
                        if(2 * (a.get(i) + a.get(j) + a.get(k)) == sum){
                            found = true;
                        }
                    }
                }
            }

            pw.println(found ? "YES" : "NO");

            pw.flush();
            sc.close();

        }
    }

}


/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int arr[] = new int[n];
        for(int i = 0 ; i < n ;++i) {
            arr[i] = scanner.nextInt();
        }

        int finalCount = Integer.MAX_VALUE;
        for(int maxPos = 0; maxPos < n ;++maxPos) {
            int totalCount = 0;
            for (int i = 0; i < n; ++i) {
                int singleVal = 2 * Math.abs(maxPos - i) + 2 * i + 2 * maxPos;
                totalCount += (arr[i] * singleVal);
            }
            if(finalCount > totalCount) {
                finalCount = totalCount;
            }
        }

        System.out.println(finalCount);
    }
}


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

public class C implements Runnable{
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	int[] fact;
	int n50, n100;
	int n, k, MOD = (int)1e9+7, oo = (int)2e9;

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		fact = new int[100];
		fact[0] = fact[1] = 1;
		for(int i = 2; i < fact.length; i++)
			fact[i] = mult(fact[i-1], i);

		n = fs.nextInt();
		k = fs.nextInt();
		int n50 = 0, n100 = 0;
		for(int i = 0; i < n; i++) {
			int x = fs.nextInt();
			if(x == 50) n50++;
			else n100++;
		}
		this.n50 = n50;
		this.n100 = n100;

		int[][][] dist = new int[2][n50+1][n100+1];
		int[][][] ways = new int[2][n50+1][n100+1];
		for(int[][] d : dist)
			for(int[] dd : d)
				Arrays.fill(dd, oo);
		dist[0][n50][n100] = 0;
		ways[0][n50][n100] = 1;
		ArrayDeque<Node> bfs = new ArrayDeque<>();
		bfs.add(new Node(n50, n100, 0, 0));
		while(!bfs.isEmpty()) {
			Node now = bfs.pollFirst();
//			System.out.println(now);
			int nn50 = n50 - now.n50;
			int nn100 = n100 - now.n100;
			for(int i = 0; i <= now.n50; i++) {
				for(int j = 0; j <= now.n100; j++) {
					if(i + j == 0) continue;
					if(i*50 + j*100 > k) continue;
					int ndist = 1 + dist[now.side][now.n50][now.n100];
					int x = dist[now.side^1][nn50+i][nn100+j];
					int tf = mult(ways[now.side][now.n50][now.n100], mult(nCk(now.n50, i), nCk(now.n100, j)));

					if(x > ndist) {
						dist[now.side^1][nn50+i][nn100+j] = ndist;
						ways[now.side^1][nn50+i][nn100+j] = tf;
						bfs.add(new Node(nn50+i, nn100+j, now.side^1, ndist));
					}
					else if(x == ndist) {
						ways[now.side^1][nn50+i][nn100+j] = add(ways[now.side^1][nn50+i][nn100+j], tf);
					}
				}
			}
		}

		int res = dist[1][n50][n100];
		int way = ways[1][n50][n100];
		if(res == oo) { res = -1; way = 0; }
		out.printf("%d\n%d\n", res, way);

		out.close();
	}

	int add(long a, long b) {
		a %= MOD;
		b %= MOD;
		a += b;
		a %= MOD;
		return (int)a;
	}

	int nCk(int n, int k) {
		int num = fact[n];
		int den = mult(fact[k], fact[n-k]);
		int inv = inv(den);
		return mult(num, inv);
	}

	int inv(long x) {
		long res = power(x, MOD - 2, MOD);
		while(res < 0) res += MOD;
		return (int)res;
	}

	int mult(long a, long b) {
		a %= MOD;
		b %= MOD;
		a *= b;
		a %= MOD;
		return (int)a;
	}

	long power (long x, long y, long m) {
		long res = 1;
		x %= m;
		while(y > 0) {
			if(y % 2 == 1) {
				res = (res * x) % m;
			}
			y >>= 1L;
						x = (x * x) % m;
		}
		return res;
	}

	class Node implements Comparable<Node> {
		int n50, n100, side, dist;
		Node(int a, int b, int c, int d) {
			n50 = a; n100 = b;
			side = c; dist = d;
		}
		public String toString() {
			return String.format("(%d, %d) %d %d", n50, n100, side, dist);
		}
		public int compareTo(Node n) {
			return Integer.compare(dist, n.dist);
		}
	}

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

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

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

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

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

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

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

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

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

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

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

	}

}


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

public class Chess {
    public static void main(String[] args) throws Exception {
        BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
        String rook = b.readLine(), knight = b.readLine();
        int board[][] = new int[8][8], Xaxis = rook.charAt(0) - 'a', Yaxis = rook.charAt(1) - '1';
        for (int i = 0; i < 8; i++) {
            board[Xaxis][i] = 1;
            board[i][Yaxis] = 1;
        }
        int moveX[] = {2, 2, -2, -2, 1, 1, -1, -1}, moveY[] = {1, -1, 1, -1, 2, -2, 2, -2};
        for (int i = 0; i < 8; i++) {
            int x = Xaxis + moveX[i], y = Yaxis + moveY[i];
            if (x >= 0 && x < 8 && y >= 0 && y < 8) {
                board[x][y] = 1;
            }
        }

        Xaxis = knight.charAt(0) - 'a';
        Yaxis = knight.charAt(1) - '1';
        board[Xaxis][Yaxis] = 1;
        for (int i = 0; i < 8; i++) {
            int x = Xaxis + moveX[i], y = Yaxis + moveY[i];
            if (x >= 0 && x < 8 && y >= 0 && y < 8) {
                board[x][y] = 1;
            }
        }

        int count = 0;
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                if (board[i][j] == 0) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}


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

/**
 * Created by IntelliJ IDEA.
 * User: tiro
 * Date: 19/08/11
 * Time: 18:00
 * To change this template use File | Settings | File Templates.
 */

public class Durak extends Thread {
    private String doS(String input) {
        if (!Character.isDigit(input.charAt(0))) {
            input = input.replace('T', '4');
            input = input.replace('J', '5');
            input = input.replace('Q', '6');
            input = input.replace('K', '7');
            input = input.replace('A', '8');
        } else {
            Integer digit = Character.digit(input.charAt(0), 10);
            Character ch = digit.toString().charAt(0);
            digit -= 6;
            input = input.replace(ch, new Character(digit.toString().charAt(0)));
        }
        return input;
    }

    public void Run() {
        try {
            String superType = nextToken();
            String first = nextToken();
            String second = nextToken();
            first = doS(first);
            second = doS(second);
            if (first.charAt(1) == second.charAt(1) && Character.digit(first.charAt(0), 10) > Character.digit(second.charAt(0), 10)) {
                out.print("YES");
                return;
            } else if (first.charAt(1) == superType.charAt(0)) {
                if (Character.digit(first.charAt(0), 10) >= Character.digit(second.charAt(0), 10)||second.charAt(1) != superType.charAt(0)) {
                    out.print("YES");
                    return;
                }
            }
            out.print("NO");
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            out.flush();
            out.close();
        }
    }

    public static void main(String[] args) {
        new Durak().Run();
    }

    public Durak() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        setPriority(Thread.MAX_PRIORITY);
    }

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer stringTokenizer;

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

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

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

    private String nextToken() throws IOException {
        if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
            stringTokenizer = new StringTokenizer(in.readLine(), "\t\n\r ");
        }
        return stringTokenizer.nextToken();
    }
}


import java.util.Scanner;

public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(); int b = sc.nextInt();
        M = Math.min(a, b);     N = Math.max(a, b);
        if(M==1){
            System.out.println(N);
            return;
        }
        if(M==2){
            int k = N/4, ans;
            if(N==4*k) ans = 4*k;
            else if(N==4*k+1) ans = 4*k+2;
            else if(N==4*k+2) ans = 4*k+4;
            else ans = 4*k+4;
            System.out.println(ans);
            return;
        }
        System.out.println((M*N+1)/2);
    }

    static int M, N;

}


import java.awt.Polygon;
import java.awt.geom.Line2D;
import java.util.Scanner;
public class Squares {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
int x1[]=new int[4];
int x2[]=new int[4];
int y1[]=new int[4];
int y2[]=new int[4];boolean t=false;
for(int i=0;i<4;i++)
{
	x1[i]=in.nextInt();
	y1[i]=in.nextInt();
}
for(int i=0;i<4;i++)
{
	x2[i]=in.nextInt();
	y2[i]=in.nextInt();
}
Polygon P=new Polygon(x1,y1,4);
Polygon Q=new Polygon(x2,y2,4);
Line2D a[]=new Line2D[4];
Line2D b[]=new Line2D[4];

for(int i=0;i<4;i++)
{
	a[i]=new Line2D.Double(x1[i],y1[i],x1[(i+1)%4],y1[(i+1)%4]);
	b[i]=new Line2D.Double(x2[i],y2[i],x2[(i+1)%4],y2[(i+1)%4]);
}

for(int i=0;i<4;i++)
{
	for(int j=0;j<4;j++)
	{
		if(a[i].intersectsLine(b[j]))
			{t=true;break;}
	}
	if(t)
		break;
}
if(t==false)
for(int i=0;i<4;i++)
{
	if(P.contains(x2[i],y2[i]))
	{t=true;break;}
	if(Q.contains(x1[i],y1[i]))
	{t=true;break;}
}
if(t)
	System.out.println("YES");
else
	System.out.println("NO");
in.close();
	}

}


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

public class Div215A {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int d=sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int m = sc.nextInt();

		if(m>n){
			int fine = (m-n)*d;
			int profit =0;
			for(int i=0;i<n;i++){
				profit+=a[i];
			}
			System.out.println(profit-fine);
		}else{
			int profit =0;
			for(int i=0;i<m;i++){
				profit+=a[i];
			}
			System.out.println(profit);
		}

	}

}


import java.util.*;
import java.io.*;
public class apart
{
  public static void main(String args[]) throws IOException
  {
    try{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      String ar[]=br.readLine().split(" ");
      int a=0,b=0;
      a=Integer.parseInt(ar[0]);
      b=Integer.parseInt(ar[1]);
      String arr[]=br.readLine().split(" ");
      int max=0;
      for(int i=0;i<a-1;i++)
      {
        max=Math.max(Integer.parseInt(arr[i])-Integer.parseInt(arr[i+1])-b,max);
      }
      System.out.println(max);
    }
    catch(Exception e){}
  }}


import java.util.Scanner;

public class Main {

    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int t=0;
        if (a<2 && b<2){
            System.out.println(0);
        } else {
            while (a > 0 && b > 0) {
                if (a > b) {
                    while (a > 2) {
                        a = a - 2;
                        b = b + 1;
                        t++;

                    }
                } else {
                    while (b > 2) {
                        b = b - 2;
                        a = a + 1;
                        t++;

                    }

                }

                if (a <= 2 && b <= 2) {
                    t++;
                    break;
                }

            }

            System.out.println(t);
        }
    }

}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader Bf = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		String input = Bf.readLine();
		StringTokenizer str = new StringTokenizer(input, " ");
		int n = Integer.parseInt(str.nextToken());
		int m = Integer.parseInt(str.nextToken());
		int[] x = new int[m];
		input = Bf.readLine();
		str = new StringTokenizer(input, " ");
		for (int i = 0; i < m; i++)
			x[i] = Integer.parseInt(str.nextToken());

		Arrays.sort(x);
		int min = 100000000;
		for (int i = 0; i < m - n +1  ; i++) {
			min = Math.min(min, x[i + n -1 ] - x[i]);

		}

		out.println(min);
		out.flush();
	}
}


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

public class ttt {

	static boolean checkWin(char[][] chess, char s) {
		for (int i = 0; i < 3; i++)
			if (s == chess[i][0] && s == chess[i][1] && s == chess[i][2])
				return true;
		for (int j = 0; j < 3; j++)
			if (s == chess[0][j] && s == chess[1][j] && s == chess[2][j])
				return true;
		if (s == chess[0][0] && s == chess[1][1] && s == chess[2][2])
			return true;
		if (s == chess[0][2] && s == chess[1][1] && s == chess[2][0])
			return true;
		return false;
	}

	static String solve(char[][] chess, int x, int o) {
		if (x < o || x > o + 1)
			return "illegal";
		boolean xw = checkWin(chess, 'X');
		boolean ow = checkWin(chess, '0');
		if (xw && ow || xw && x == o || ow && x > o)
			return "illegal";
		if (xw)
			return "the first player won";
		if (ow)
			return "the second player won";
		if (x + o == 9)
			return "draw";
		if (x == o)
			return "first";
		if (x > o)
			return "second";
		return "illegal";
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		char[][] chess = new char[3][3];
		int x = 0;
		int o = 0;
		for (int i = 0; i < 3; i++) {
			String line = in.nextLine();
			chess[i] = line.toCharArray();
			for (int j = 0; j < 3; j++)
				if (chess[i][j] == 'X')
					x++;
				else if (chess[i][j] == '0')
					o++;
		}
		out.println(solve(chess, x, o));
		out.close();
		in.close();
	}
}


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

public class number {
    private BufferedReader br;
    private StringTokenizer st;

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

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

    public   int intParse() throws IOException {
        return Integer.parseInt(read()) ;
    }
    public   String stringParse() throws IOException {
        return String.valueOf(read());
    }
    public static void main(String[] args) throws IOException {
        number n=new number();
        String digit=n.stringParse();
        StringBuilder s=new StringBuilder();
        for(int a=0; a<digit.length();a++){
            int w='9';
            int ch='5';
            if(digit.charAt(a)<ch || (a==0 && digit.charAt(0)==w))
            {
                s.append(digit.charAt(a));
            }else
                s.append(w-digit.charAt(a));

        }
        System.out.println(s);

    }
}


import java.util.*;
public class Codechef
{
	public static void main (String[] args)
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=0,small=1,count=0,flag=0,ans=0,check=0,per=0,mark=0;
		n=Integer.parseInt(sc.nextLine());
		int dup=n;
		int arr[]=new int[n+1];
		for(int j=0;j<arr.length;j++)
		{
		    arr[j]=0;
		}
		while((n%2==0)&&n>0)
		{
		    n=n/2;
		    arr[2]+=1;
		}
		for(int i=3;i<=(int)Math.sqrt((double)dup);i+=2)
		{
		    while((n%i==0)&&n>0)
		    {
		        n=n/i;
		        arr[i]+=1;
		    }
		}
		//System.out.println(" Value n"+n);
		if(n!=1)
		{
		    arr[n]+=1;
		}
		for(int m=1;m<arr.length;m++)
		{
		    if(arr[m]!=0)
		    {
		        small*=m;
		    }
		}
		for(int x=1;x<arr.length;x++)
		{
		    if(arr[x]!=0)
		    {
		        mark=arr[x];
		        break;
		    }
		}
		for(int x=1;x<arr.length;x++)
		{
		    if(arr[x]!=0)
		    {
		        if(arr[x]!=mark)
		        {
		            flag+=1;
		        }
		    }
		}
//	System.out.println(" Value small"+check);
		int max=-1;
		for(int k=1;k<arr.length;k++)
		{
		   if(arr[k]!=0)
		   {
		    if(arr[k]>=max)
		    {
		        max=arr[k];
		    }
		   }
		}
	if(max>1)
	{

	//	System.out.println(" Value max"+flag);
		if(flag==0)
		{
		     while(max%2==0)
            {
                max=max/2;
                count+=1;
            }
            if(max==1)
            {
                ans=count;
            }
            else
            {
                 while(max!=0)
                {
                    max=max/2;
                    count+=1;
                }
                ans=count+1;
            }
		}
		else
		{
            while(max%2==0)
            {
                max=max/2;
                count+=1;
            }
            if(max==1)
            {
                ans=count+1;
            }
            else
            {
                while(max!=0)
                {
                    max=max/2;
                    count+=1;
                }
                ans=count+1;
            }
            //System.out.println("Ans "+ans);
		}

		System.out.println(small+" "+ans);
	}
	else
	{

	      System.out.println(dup+" "+0);

	}

	}
}


import java.util.Scanner;

/**
 * ������ 2016/11/20 21:45
 */
public class ContestA {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int length=Integer.parseInt(in.nextLine());
        String line = in.nextLine();

        String origin = line;

        origin = replaceSameStrs(origin, "ogo", "go","***");
        System.out.println(origin);
    }

    private static String replaceSameStrs(String origin, String s2, String s3,String replace) {
        int count=1;
        for (int i = 0; i < origin.length(); i++) {
            int index = origin.indexOf(s2);
            if (index == -1) {
                break;
            }
            String findStr = appendCountN(s2,s3,count);
            int index2 = origin.indexOf(findStr, index);
            //���ogo����û��go�ˣ���ô�ѵ�һ��ogo�滻��***
            if (index != index2) {
                int start = index;
                int end = index + ((s2.length()-1) + 2*(count-1));
                origin = replaceByLocation(origin,replace,start,end);
                count=1;
            }else {
                count++;
            }
        }
        return origin;
    }

    /**
     * ��origin�ַ�����[start,end]�����ַ��滻��replace�ַ�
     * @param origin
     * @param replace
     * @param start
     * @param end
     * @return
     */
    public static String replaceByLocation(String origin, String replace, int start, int end) {
        char[] originChars = origin.toCharArray();
        char[] replaceChars= replace.toCharArray();
        for (int i = start;i<=end;i++) {
            if (i - start > replaceChars.length-1) {
                originChars[i]=' ';
            }   else {
            originChars[i] = replaceChars[i-start];
            }
        }
        StringBuffer sb = new StringBuffer();
        for (char c : originChars) {
            if (c != ' ') {
                sb.append(c);
            }
        }
        return new String(sb);
    }

    public static String appendCountN(String origin, String append,int count) {
        StringBuffer sb = new StringBuffer(origin);
        for (int i = 0; i < count; i++) {
            sb.append(append);
        }
        return new String(sb);
    }
}


import java.util.Scanner;

public class A {

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

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

				if(i>=n){
					break;
				}
				System.out.print(g.charAt(i));
				i+=counter;
				counter++;
			}
		}
}


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 Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		String s = ns();
		int n = Integer.parseInt(s, 16);
		out.println(n%2);
	}

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

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

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

	private byte[] inbuf = new byte[1024];
	public 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 static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


import java.util.Scanner;
public class test3 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        if(check(n) == 7 || check(n) == 4)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
    public static int check(long n){
        int digits = 0;
        String m = Long.toString(n);
        for(int i = 0; i < m.length(); i++){
            if(n % 10 == 4 || n % 10 == 7){
                digits++;
            }
            n = n / 10;
        }
        return digits;
    }

}


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

/**
 * @auther chao
 * @date 15/12/30
 */
public class A {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int[][] a = new int[2][3];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) a[i][j] = in.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < 3; i++) {
            if (a[0][i] - a[1][i] >= 0) ans += (a[0][i] - a[1][i]) / 2;
            else ans += a[0][i] - a[1][i];
        }
        if (ans >= 0) System.out.println("YES");
        else System.out.println("NO");

    }
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.text.*;
public class cf1 {
    static long mod = (long)1e9 + 7;
    static long mod1 = 998244353;
    static FastScanner f;
    static PrintWriter pw = new PrintWriter(System.out);
    static Scanner S = new Scanner(System.in);
    static long x0; static long y0;
    static int inf = (int)(1e9);
    static long iinf = (long)(1e18);
    static void solve()throws IOException {
        long a = f.nl(); long b = f.nl(); long x = f.nl(); long y = f.nl();
        long g = gcd(x , y);
        x /= g; y /= g;
        a = Math.min(a / x , b / y);
        pn(x * a + " " + y * a);
    }
    public static void main(String[] args)throws IOException {
        init();
        int t = 1;
        while(t --> 0) {solve();}
        pw.flush();
        pw.close();
    }

/******************************END OF MAIN PROGRAM*******************************************/
    public static void init()throws IOException{if(System.getProperty("ONLINE_JUDGE")==null){f=new FastScanner("");}else{f=new FastScanner(System.in);}}
    public static class FastScanner {
        BufferedReader br;StringTokenizer st;
        FastScanner(InputStream stream){try{br=new BufferedReader(new InputStreamReader(stream));}catch(Exception e){e.printStackTrace();}}
        FastScanner(String str){try{br=new BufferedReader(new FileReader("!a.txt"));}catch(Exception e){e.printStackTrace();}}
        String next(){while(st==null||!st.hasMoreTokens()){try{st=new StringTokenizer(br.readLine());}catch(IOException e){e.printStackTrace();}}return st.nextToken();}
        String nextLine()throws IOException{return br.readLine();}int ni(){return Integer.parseInt(next());}long nl(){return Long.parseLong(next());}double nextDouble(){return Double.parseDouble(next());}
    }
    public static void pn(Object o){pw.println(o);}
    public static void p(Object o){pw.print(o);}
    public static void pni(Object o){pw.println(o);pw.flush();}
    static int gcd(int a,int b){if(b==0)return a;else{return gcd(b,a%b);}}
    static long gcd(long a,long b){if(b==0l)return a;else{return gcd(b,a%b);}}
    static long lcm(long a,long b){return (a*b/gcd(a,b));}
    static long exgcd(long a,long b){if(b==0){x0=1;y0=0;return a;}long temp=exgcd(b,a%b);long t=x0;x0=y0;y0=t-a/b*y0;return temp;}
    static long pow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=res*a;b>>=1;a=a*a;}return res;}
    static long mpow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=((res%mod)*(a%mod))%mod;b>>=1;a=((a%mod)*(a%mod))%mod;}return res;}
    static long mul(long a , long b){return ((a%mod)*(b%mod)%mod);}
    static long adp(long a , long b){return ((a%mod)+(b%mod)%mod);}
    static boolean isPrime(long n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static boolean isPrime(int n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static HashSet<Long> factors(long n){HashSet<Long> hs=new HashSet<Long>();for(long i=1;i<=(long)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static HashSet<Integer> factors(int n){HashSet<Integer> hs=new HashSet<Integer>();for(int i=1;i<=(int)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static HashSet<Long> pf(long n){HashSet<Long> ff=factors(n);HashSet<Long> ans=new HashSet<Long>();for(Long i:ff)if(isPrime(i))ans.add(i);return ans;}
    static HashSet<Integer> pf(int n){HashSet<Integer> ff=factors(n);HashSet<Integer> ans=new HashSet<Integer>();for(Integer i:ff)if(isPrime(i))ans.add(i);return ans;}
    static int[] inpint(int n){int arr[]=new int[n];for(int i=0;i<n;i++){arr[i]=f.ni();}return arr;}
    static long[] inplong(int n){long arr[] = new long[n];for(int i=0;i<n;i++){arr[i]=f.nl();}return arr;}
    static boolean ise(int x){return ((x&1)==0);}static boolean ise(long x){return ((x&1)==0);}
    static int gnv(char c){return Character.getNumericValue(c);}//No. of integers less than equal to i in ub
    static int log(long x){return x==1?0:(1+log(x/2));} static int log(int x){return x==1?0:(1+log(x/2));}
    static int upperbound(int a[],int i){int lo=0,hi=a.length-1,mid=0;int count=0;while(lo<=hi){mid=(lo+hi)/2;if(a[mid]<=i){count=mid+1;lo=mid+1;}else hi=mid-1;}return count;}
    static void sort(int[] a){ArrayList<Integer> l=new ArrayList<>();for(int i:a)l.add(i);Collections.sort(l);for(int i=0;i<a.length;++i)a[i]=l.get(i);}
    static void sort(long[] a){ArrayList<Long> l=new ArrayList<>();for(long i:a)l.add(i);Collections.sort(l);for(int i=0;i<a.length;++i)a[i]=l.get(i);}
    static void sort(ArrayList<Integer> a){Collections.sort(a);}//!Precompute fact in ncr()!
}


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

public class Main {

    public static void main(String[] args) {
        Scanner S=new Scanner(System.in);
        int m=S.nextInt();
        int s=S.nextInt();
        int v;
        int t;
        int i;
        int mas1[]=new int[m];
        int mas2[]=new int[m];
        mas1[0]=1;
        v=s-1;
        if (v>=0) {
            t=v/9;
            v%=9;
            for (i=m-1;i>0&&t>0;i--,t--) mas1[i]=9;
            mas1[i]+=v;
            if (mas1[0]>9||t>0) System.out.print("-1 ");
            else {
                for (i=0;i<m;i++) System.out.print(mas1[i]);
                System.out.print(" ");
            }
        } else if (m==1&&s==0) {
            System.out.print("0 0");
            return;
        }
        else System.out.print("-1 ");
        for (i=0;i<s/9&&i<m;i++) mas2[i]=9;
        if (i<m) mas2[i]=s%9;
        else if (s%9>0||s/9>m) {
            System.out.println("-1");
            return;
        }
        if (mas2[0]==0) {
            System.out.println("-1");
            return;
        }
        for (i=0;i<m;i++) System.out.print(mas2[i]);
    }
}


import java.util.Scanner;

public class main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		int s=sc.nextInt();
		int x=sc.nextInt();
		x=x-t;
		//System.out.println(x%s+" "+x);
		if(x<s && x!=0)
			System.out.println("NO");
		else if(x%s==0 || x%s==1)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


import java.util.*;

public class A {
public static void main(String args[]) {
	Scanner in = new Scanner(System.in);
	int n=in.nextInt(),x=in.nextInt(),y=in.nextInt();
	double ans = y*n/100.0 - x;
	if (ans<0) ans =0;
	if (ans==(long)ans) System.out.println((int)ans); else System.out.println((long)ans+1);

 }
}


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;
	    else if (Integer.parseInt(a[i]) < Integer.parseInt(b[i]))
		return false;
	}
	return false;
    }

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

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


import java.util.Scanner;

public class task2 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		int k = in.nextInt();
		for (int i=0;i<k;i++){
			sb.append("?");
		}
		s = sb.toString();
		int n = s.length()+1, max = -1,t;
		for (int i=0;i<n;i++){
			for (int j=i+1;j<n;j++){
				t = isTandemRepeat(s.substring(i,j));
				if (t > max) max = t;
			}
		}
		t = isTandemRepeat(s.substring(n-1,n-1));
		if (t > max) max = t;
		System.out.println(max);
	}
	public static int isTandemRepeat(String s){
		if (s.length() % 2 == 1) return -1;
		int length = 0, n = s.length()/2;
		for (int i=0;i<n;i++){
			if (s.charAt(i) == '?' || s.charAt(i+n) == '?') continue;
			if (s.charAt(i) != s.charAt(i+n)){
				length = -1;
				break;
			}
		}
		if (length == 0){
			length = s.length();
		}
		return length;
	}
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	static ArrayList<Long>luck=new ArrayList<>();
	static long big=1000000007;
	public static void pushLuck(long num) {
		if(num>big)
			return;
		if(num!=0)
			luck.add(num);

		pushLuck(num*10+4);
		pushLuck(num*10+7);

	}

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

		long n =in.nextInt();
		pushLuck(0);
		Collections.sort(luck);

		System.out.println(luck.indexOf(n)+1);

}}


import static java.lang.Math.abs;
import java.util.Scanner;
public class ProblemSolving {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int sum=0;
        int start=97;
        for (int i =0;i<s.length();i++)
        {

        if(abs((int)s.charAt(i)-start)<=13)
        {
        sum= sum + abs((int)s.charAt(i)-start);
        start=s.charAt(i);
        }
        else if(abs((int)s.charAt(i)-start)>13)
        {
        sum = sum + abs(abs((int)s.charAt(i)-start)-26);
        start=s.charAt(i);
        }

        }

        System.out.println(sum);
        }
}


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

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

    static class d899 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int max = 2 * n - 1;
            int digitCount = 0;
            int nineCount = 0;
            while (max > 0) {
                if (max % 10 == 9) nineCount++;
                digitCount++;
                max /= 10;
            }
            if (digitCount == nineCount) {
                out.println(1);
                return;
            }
            max = 2 * n - 1;
            long posMax = 0;
            long firstDigit = 1;
            for (int i = 1; i < digitCount; i++) {
                posMax *= 10;
                posMax += 9;
                firstDigit *= 10;
            }
            long ans = 0;
            for (int i = 0; i < 10; i++) {
                long first = posMax - n;
                if (first >= n) break;
                if (first < 1) first = 1;
                long last = posMax - first;
                ans += (last - first + 1) / 2;
                posMax += firstDigit;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

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

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

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}


import java.util.*;

public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int start = a+1;
        int end = n;
        while(n-start>b){
            start++;
        }
        System.out.println(n - start+1);
    }
}


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

public class jump {
	public static void main(String args[]) throws Exception {
		Scanner in;
		try {
			in = new Scanner(new File("inputcool.txt"));
		}
		catch (Exception e) {
			in = new Scanner(System.in);
		}
		String str = in.nextLine();
		boolean hi = false;
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == 'H' || str.charAt(i) == 'Q' || str.charAt(i) == '9') {
				hi = true;
			}
		}
		if (!hi) System.out.println("NO");
		else System.out.println("YES");
	}
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for(int i = 0; i< 3; i++){
		    a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println((a[1]-a[0]) + (a[2]-a[1]));
	}
}


import java.util.Scanner;
public class Main {
public static void main(String args[])
{
	Scanner in=new Scanner(System.in);
  int n;
  double t1;
  int sum=0;
  n=in.nextInt();
  for(int i=1;i<=n;i++)
  {
	  for(int y=i+1;y<=n;y++)
	  {
		t1=(i*i)+(y*y);
		 t1= Math.sqrt(t1);
		  if(t1==(int)t1)
		  {
		if(t1<=(n)&&t1>=(i)&&t1>=(y))
	    sum++;
		 }

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


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

public class onceagain {
  private static InputReader in;
  private static PrintWriter out;

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out, true);
    int n = in.nextInt(), k = in.nextInt();
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) arr[i] = in.nextInt();

    int m = 301;
    int[][] mat = new int[m+1][m+1];
    for (int i = 0; i < n; i++) {
      int[][] next = new int[m+1][m+1];
      for (int j = 0; j <= m; j++) System.arraycopy(mat[j], 0, next[j], 0, m+1);
      for (int last = 0; last <= arr[i]; last++) {
        for (int first = 0; first <= last; first++) {
          next[first][arr[i]] = Math.max(next[first][arr[i]], mat[first][last] + 1);
        }
      }
      mat = next;
    }

    mat = mat_exp(mat, k);
    int ret = 0;
    for (int i = 0; i <= m; i++) for (int j = 0; j <= m; j++)
      ret = Math.max(ret, mat[i][j]);

    out.println(ret);
    out.close();
    System.exit(0);

  }

  private static int[][] mat_exp(int[][] A, int e) {
    if (e == 1)
      return A;
    else if (e % 2 == 0) {
      int[][] A1 = mat_exp(A, e / 2);
      return matrix_mult(A1, A1);
    } else
      return matrix_mult(A, mat_exp(A, e - 1));
  }

  private static int[][] matrix_mult(int[][] A, int[][] B) {
    int[][] C = new int[A.length][A.length];
    for (int i = 0; i < A.length; i++)
      for (int j = i; j < A.length; j++)
        for (int k = j; k < A.length; k++) {
          if (A[i][j] == 0 || B[j][k] == 0) continue;
          C[i][k] = Math.max(C[i][k], A[i][j] + B[j][k]);
        }
    return C;
  }
  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());
    }
  }

}


import java.util.*;
public class Main
{
	public static boolean isnumberlucky(long x)
	{
		if(x<0)
			x*=-1;
		for( ; x>0 && x%10!=8; x/=10);
		if(x==0)
			return false;
		return true;
	}
	public static void main(String []args)
	{
		long a;
		short ans=1;
		Scanner in=new Scanner(System.in);
		a=in.nextLong();
		++a;
		while(!(isnumberlucky(a)))
		{
			ans++;
			a++;
		}
		System.out.println(ans);
	}
}


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

public class con169_D {

	private static final boolean DEBUG = false;

	public static void main( final String[] args ) throws Exception {
		final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
		final String line = br.readLine();
		final StringTokenizer tok = new StringTokenizer( line );

		final long L = Long.parseLong( tok.nextToken() );
		final long R = Long.parseLong( tok.nextToken() );

		System.out.println( solve( L, R ) );
	}

	public static long solve( final long L, final long R ) {
		if ( L == R ) return L ^ R;
		if ( DEBUG ) System.out.printf( "L=%d (%s), R=%d (%s)\n", L, Long.toBinaryString( L ), R,
				Long.toBinaryString( R ) );

		final int ld = length( L );
		final int ldm1 = ld - 1;
		final int rd = length( R );

		if ( ld < rd ) {
			long max = 1;
			while ( length( max ) < rd ) {
				max <<= 1;
			}
			long min = 1;
			while ( length( min ) < rd - 1 ) {
				min <<= 1;
				++min;
			}
			if ( DEBUG ) System.out.printf( "min=%d (%s), max=%d (%s)\n", min, Long.toBinaryString( min ), max,
						Long.toBinaryString( max ) );
			return min ^ max;
		} else {
			final char[] minStr = Long.toBinaryString( L ).toCharArray();
			final char[] maxStr = Long.toBinaryString( R ).toCharArray();
			final char[] res = new char[minStr.length];
			Arrays.fill( res, '0' );
			{
				int i = 0;
				while ( i < res.length ) {
					if ( minStr[ i ] == maxStr[ i ] ) {
						res[ i ] = '0';
					} else {
						break;
					}
					++i;
				}
				if ( DEBUG ) System.out.println( "diff at pos: " + i );
				if ( minStr[ i ] == '0' ) {
					res[ i++ ] = '1';
					for ( int j = i; j < res.length; ++j ) {
						res[ j ] = '1';
					}
				} else {
					throw new IllegalArgumentException();
				}
			}
			return Long.parseLong( new String( res ), 2 );
		}
	}

	private static int length( long l ) {
		int res = 0;
		while ( l > 0 ) {
			++res;
			l >>= 1;
		}
		return res;
	}

}


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

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

    static class ACarrotCakes {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            int t = sc.nextInt();
            int k = sc.nextInt();
            int d = sc.nextInt();

            long[] before = new long[1000001];
            long[] after = new long[1000001];
            long t1 = 0;
            long t2 = 0;
            long c = 0;
            for (int i = 1; i < before.length; i++) {
                if (i % t == 0) {
                    before[i] = k + c;
                    c = before[i];
                }
                if (before[i] >= n) {
                    t1 = i;
                    break;
                }
            }
            c = 0;
            for (int i = 1; i < before.length; i++) {
                if (i % t == 0) {
                    after[i] += k + c;
                    c = after[i];
                }
                if (i > d && (i - d) % t == 0) {
                    after[i] += k + c;
                    c = after[i];
                }
                if (after[i] >= n) {
                    t2 = i;
                    break;
                }
            }
            //pw.println(Arrays.toString(before));
            //pw.println(Arrays.toString(after));
            //pw.println(t1 + " "+t2);
            pw.println(t1 <= t2 ? "NO" : "YES");
        }

    }
}


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

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

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int []ar = in.primitiveIntArray(0,6);
        BigInteger start = BigInteger.valueOf((long) 1e9);
        int g = 2;
        String []s = new String[]{"Hermione","Ron"};
        if (ar[2] == 0 && ar[3] != 0){
            out.print(s[1]);return;
        }
        if (ar[0] == 0 && ar[1] != 0 && ar[3] != 0){
            out.print(s[1]);return;
        }
        if (ar[1] == 0 || ar[3] == 0 || ar[5] == 0){
            out.print(s[0]);return;
        }
        if (ar[4] == 0){
            out.print(s[1]);return;
        }
        BigInteger tk = BigInteger.ONE;
        for (int i = 0; i < 10000; i++) {
            for (int j = 0; j < 5; j+= 2) {
                BigInteger val = start.divideAndRemainder(BigInteger.valueOf((ar[j] == 0?1:ar[j])))[0];
                start = val.multiply(BigInteger.valueOf(ar[j + 1]));
            }
            if (i == 0)
                tk = start;
            if (start.compareTo(tk) <= 0 && i > 3){
                out.print(s[0]+"\n");return;
            }
        }
        out.print(s[1]);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

    public int[] primitiveIntArray(int startIndex,int size){
        if (startIndex == 1)size++;
        int []array = new int[size];
        for (int i = startIndex; i < size; i++) {
            array[i] = Integer.parseInt(next());
        }
        return array;
    }

}


import java.util.Scanner;
public class Slonik {

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

            float min = input / 5f;
            System.out.println((int)Math.ceil(min));
        }
    }


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

public class CF568C {

	public static void main(String[] args) 	throws Exception  {
		boolean[] primos = new boolean[2000000];
		int[] primosC = new int[2000000];
		int[] palC = new int[2000000];
		primos[0]=primos[1]=true;
		palC[1]=1;
		for(int i=2;i<primos.length;++i){
			if(!primos[i]&&i<10000)
				for(int j=i*i;j<primos.length;j+=i){
					primos[j]=true;
				}
			primosC[i]=primosC[i-1]+(primos[i]?0:1);
			palC[i]=palC[i-1]+(isPal(i)?1:0);
		}

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(String ln;(ln=in.readLine())!=null;){
			StringTokenizer st = new StringTokenizer(ln);
			int p = Integer.parseInt(st.nextToken());
			int q = Integer.parseInt(st.nextToken());
			int sol=-1;
			for(int i=0;i<primosC.length;i++)
				if(q*primosC[i]<=p*palC[i])
					sol=i;
			if(sol==-1)
				System.out.println("Palindromic tree is better than splay tree");
			else
				System.out.println(sol);
		}
	}

	private static boolean isPal(int n) {
		char[] a=(n+"").toCharArray();
		for(int i=0;i<a.length/2;i++)
			if(a[i]!=a[a.length-1-i])
				return false;
		return true;
	}

}


//codeforces_1068B_live

import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.lang.Math.*;
import java.math.*;

public class Main{

	static PrintWriter go = new PrintWriter(System.out);

	public static void main(String args[]) throws IOException,FileNotFoundException {
		BufferedReader gi = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(gi.readLine());
		int ans = 0;
		for ( long k = 1; k*k <= n; k++){
			if ( n%k == 0 ){
				if ( n/k == k ){
					ans++;
				}else{
					ans += 2;
				}
			}
		}
		go.println(ans);

		go.close();
	}

	static int[] parseArray(BufferedReader gi) throws IOException{
		String[] line = gi.readLine().trim().split(" ");
		int[] rez = new int[line.length];
		for ( int k = 0; k < line.length; k++){
			rez[k] = Integer.parseInt(line[k]);
		}
		return rez;
	}

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.io.*;
public class codeforces
{
   static class Student{
       int x,y;
        Student(int x,int y){
            this.x=x;
            this.y=y;
            //this.z=z;
        }
    }
    static int prime[];
    static void sieveOfEratosthenes(int n)
    {
        // Create a boolean array "prime[0..n]" and initialize
        // all entries it as true. A value in prime[i] will
        // finally be false if i is Not a prime, else true.
        int pos=0;
        prime= new int[n+1];
        for(int p = 2; p*p <=n; p++)
        {
            // If prime[p] is not changed, then it is a prime
            if(prime[p] == 0)
            {
                // Update all multiples of p
                prime[p]=p;
                for(int i = p*p; i <= n; i += p)
                    prime[i] = p;
            }
        }
    }
static    class Sortbyroll implements Comparator<Student>
{
    // Used for sorting in ascending order of
    // roll number
    public int compare(Student c, Student b)
    {
        if(c.x<b.x)
            return -1;
        if(c.x>b.x)
            return 1;
        return c.y-b.y;
    }
}
static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    static class Edge{
        int a,b;
        Edge(int a,int b){
            this.a=a;
            this.b=b;
        }
    }
    static class Trie{
        HashMap<Character,Trie>map;
         int c;
        Trie(){
            map=new HashMap<>();
            //z=null;
            //o=null;
            c=0;
        }
    }
    //static long ans;
    static int parent[];
    static int rank[];
    static int b[][];
    static int bo[];
    static int ho[];
    static int seg[];
    //static int pos;
   // static long mod=1000000007;
    //static int dp[][];
    static HashMap<Integer,Integer>map;
    static PriorityQueue<Student>q=new PriorityQueue<>();
    //static Stack<Integer>st;
   // static ArrayList<Character>ans;
    static ArrayList<ArrayList<Integer>>adj;
    static long ans;
    static Trie root;
    static long fac[];
    static long mod=(long)(1000000007);
    //static int ans;
    static void solve()throws IOException{
        FastReader sc=new FastReader();
        int s,s2,x1,x2,t1,t2,p,d,a1,a2;
        s=sc.nextInt();
        x1=sc.nextInt();
        x2=sc.nextInt();
        t1=sc.nextInt();
        t2=sc.nextInt();
        p=sc.nextInt();
        d=sc.nextInt();
        a1=(int)(Math.abs(x1-x2))*t2;
        if(d==1){
            if(x2>x1){
                if(p<=x1)
                    a2=(x2-p)*t1;
                else{
                    a2=(s-p)*t1+s*t1+x2*t1;
                }
            }
            else{
                a2=(s-p)*t1+(s-x2)*t1;
            }
        }
        else{
            if(x2>x1){
                a2=p*t1+x2*t1;
            }
            else{
                if(p>=x1)
                    a2=(p-x2)*t1;
                else
                    a2=p*t1+s*t1+(s-x2)*t1;
            }
        }
        System.out.println(Math.min(a1,a2));
    }
    static void build(StringBuilder sb,int n,char a){
        if(n==0)
        {
            sb.append(a);
            return;
        }
        int x=(int)Math.sqrt(2*n);
        if(x*(x+1)>2*n)
            x-=1;
        for(int i=0;i<=x;i++)
            sb.append(a);
        n-=(x*(x+1))/2;
        build(sb,n,(char)((int)a+1));
    }
    static void dfs(Trie root,int k){
        if(root==null)
            return;
        for(char i='A';i<='Z';i++){
            if(root.map.containsKey(i)){
                ans+=root.map.get(i).c/k;
                dfs(root.map.get(i),k);
            }
        }
    }
    static long nCr(long n, long r,
                                    long p)
    {
        return (fac[(int)n]* modInverse(fac[(int)r], p)
                % p * modInverse(fac[(int)(n-r)], p)
                                    % p) % p;
    }
    //static int prime[];
    //static int dp[];
    public static void main(String[] args){
        //long sum=0;
        try {
                codeforces.solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
    }
       static long modInverse(long n, long p)
    {
        return power(n, p-(long)2,p);
    }
 static long power(long x, long y, long p)
{
    long res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y %(long)2!=0)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res%p;
 }
    /*public static long power(long x,long a) {
		if(a==0) return 1;
		if(a%2==1)return (x*1L*power(x,a-1))%mod;
		return (power((int)((x*1L*x)%mod),a/2))%mod;
	}*/
   static int find(int x)
    {
        // Finds the representative of the set
        // that x is an element of
        while(parent[x]!=x)
        {
            // if x is not the parent of itself
            // Then x is not the representative of
            // his set,
            x=parent[x];

            // so we recursively call Find on its parent
            // and move i's node directly under the
            // representative of this set
        }

        return x;
    }
    static void union(int x, int y)
    {
        // Find representatives of two sets
        int xRoot = find(x), yRoot = find(y);

        // Elements are in the same set, no need
        // to unite anything.
        if (xRoot == yRoot)
            return;

         // If x's rank is less than y's rank
        if (rank[xRoot] < rank[yRoot])

            // Then move x under y  so that depth
            // of tree remains less
            parent[xRoot] = yRoot;

        // Else if y's rank is less than x's rank
        else if (rank[yRoot] < rank[xRoot])

            // Then move y under x so that depth of
            // tree remains less
            parent[yRoot] = xRoot;

        else // if ranks are the same
        {
            // Then move y under x (doesn't matter
            // which one goes where)
            parent[yRoot] = xRoot;

            // And increment the the result tree's
            // rank by 1
            rank[xRoot] = rank[xRoot] + 1;
        }
    }
    static long gcd(long a, long b)
    {
        if (a == 0){
             //ans+=b;
            return b;
        }
        return gcd(b % a, a);
    }
}


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.math.*;
import java.util.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import static java.util.stream.Collectors.*;
import static java.util.Map.Entry.*;

public class Main {

	static int ans = 0;
	static boolean [] memo;
	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int d = in.nextInt();
		char [] a = in.next().toCharArray();
		memo = new boolean [n-1];
		if (!go(a,0,n-1,d)) {
			out.println("-1");
		} else {
			out.println(ans);
		}

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

	}

	private static boolean go(char[] a, int i, int n,int d ) {
		if (i == n||  i+d >= n) {
			ans +=1;
			return true;
		} else if (a[i] == '0' || i > n || memo[i])  {
			return false;
		} else {
				for (int j = i+d; j > i; j--) {
					if (a[j] == '1') {
						if (go(a,j,n,d)) {
							ans+=1;
							return true;
						}  else {
							memo[j] = true;
						}
					}
				}
				return false;
			}
	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

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

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		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 double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

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

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

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

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Andy Phan
 */
public class c {

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

        long n = in.nextLong();
        long k = in.nextLong();
        long M = in.nextLong();
        long D = in.nextLong();
        D = Math.min(D, n/k);
        long max = 0;
        for(long d = 1; d <= D; d++) {
            long minX = n/(k*d);
            long maxX = n/(k*(d-1)+1);
            if(minX > M) continue;
            max = Math.max(max, d*Math.min(M, maxX));
        }
        System.out.println(max);
        out.close();
    }

    static class FS {

        BufferedReader in;
        StringTokenizer token;

        public FS(InputStream str) {
            in = new BufferedReader(new InputStreamReader(str));
        }

        public String next() {
            if (token == null || !token.hasMoreElements()) {
                try {
                    token = new StringTokenizer(in.readLine());
                } catch (IOException ex) {
                }
                return next();
            }
            return token.nextToken();
        }

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

/*
6
-1
1
1
1
10
6
4
8
-1
1
1
*/


/**
 * Created by Chirag on 12-12-2017.
 * DA-IICT (B.tech 3rd year)
 */

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

public class ChotllyRequest
{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

      /*
      int n      = sc.nextInt();        // read input as integer
      long k     = sc.nextLong();       // read input as long
      double d   = sc.nextDouble();     // read input as double
      String str = sc.next();           // read input as String
      String s   = sc.nextLine();       // read whole line as String

      int result = 3*n;
      out.println(result);                    // print via PrintWriter
      */
        //The Code Starts here
        int k=sc.nextInt();
        int p=sc.nextInt();
        int noOfNumbers=0;
        long sum=0;
        int i=1;
        while (noOfNumbers<k)
        {
            int num=i;
            StringBuilder revNum=new StringBuilder(Integer.toString(num));
            revNum.reverse();
            StringBuilder orgNum=new StringBuilder(Integer.toString(num));
//            debug(orgNum,revNum);
            sum=(sum+(Long.parseLong(orgNum.append(revNum).toString()))%p)%p;
            noOfNumbers++;
            i++;
        }
        out.print(sum);

        //The Code ends here
        out.close();
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        char nextCharacter() {
            return next().charAt(0);
        }

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

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

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

        public int[][] nextInt2DArray(int m, int n) {
            int[][] arr = new int[m][n];
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++)
                    arr[i][j] = nextInt();
            }
            return arr;
        }

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

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

    }

    public static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }

    public static class Pair implements Comparable<Pair> {
        long u;
        long v;

        public Pair(long u, long v) {
            this.u = u;
            this.v = v;
        }

        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }

        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }

        public int compareTo(Pair other) {
            return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u) : Long.compare(v, other.v);
        }

        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
    //--------------------------------------------------------

    // Different other methods

    public static long pow(long n, long p, long mod) {
        if (p == 0)
            return 1;
        if (p == 1)
            return n % mod;
        if (p % 2 == 0) {
            long temp = pow(n, p / 2, mod);
            return (temp * temp) % mod;
        } else {
            long temp = pow(n, p / 2, mod);
            temp = (temp * temp) % mod;
            return (temp * n) % mod;

        }
    }

    public static long pow(long n, long p) {
        if (p == 0)
            return 1;
        if (p == 1)
            return n;
        if (p % 2 == 0) {
            long temp = pow(n, p / 2);
            return (temp * temp);
        } else {
            long temp = pow(n, p / 2);
            temp = (temp * temp);
            return (temp * n);

        }
    }

    public static long gcd(long x, long y) {
        if (x == 0)
            return y;
        else
            return gcd(y % x, x);
    }

    static long modInverse(long a, long m) {
        long m0 = m, t, q;
        long x0 = 0, x1 = 1;

        if (m == 1)
            return 0;

        while (a > 1) {
            // q is quotient
            q = a / m;

            t = m;

            // m is remainder now, process
            // same as Euclid's algo
            m = a % m;
            a = t;

            t = x0;

            x0 = x1 - q * x0;

            x1 = t;
        }

        // Make x1 positive
        if (x1 < 0)
            x1 += m0;

        return x1;
    }

    public static boolean isPrime(int n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }

    public static class DisjointSet {
        HashMap<Integer, Node> map = new HashMap<Integer, Node>();

        class Node {
            int data;
            int rank;
            Node parent;

            Node(int data) {
                this.data = data;
                this.rank = 0;
                this.parent = this;
            }
        }

        void makeSet(int data) {
            map.put(data, new Node(data));
        }

        Node findSet(int data) {
            return findSet(map.get(data));
        }

        boolean isConnected(int d1, int d2) {
            return findSet(d1) == findSet(d2);
        }

        Node findSet(Node node) {
            Node parent = node.parent;
            if (parent == node)
                return parent;
            node.parent = findSet(node.parent);
            return node.parent;
        }

        void union(int data1, int data2) {
            Node d1 = map.get(data1);
            Node d2 = map.get(data2);

            Node p1 = findSet(d1);
            Node p2 = findSet(d2);

            if (p1.data == p2.data)
                return;

            if (p1.rank >= p2.rank) {
                p1.rank = (p1.rank == p2.rank) ? p1.rank + 1 : p1.rank;
                p2.parent = p1;
            } else {
                p1.parent = p2;
            }
        }

    }

}


import java.util.Scanner;

public class songsandjoke {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
       int n,d,k;
       Scanner in=new Scanner(System.in);
       n=in.nextInt();
       d=in.nextInt();
       int sum=0;
       for(int i=0;i<n;i++){
    	   k=in.nextInt();
    	   sum+=k;
       }
    sum+=(n-1)*10;
    int joke=d-sum;
    if(joke<0) System.out.println("-1");
    else System.out.println((joke/5)+(n-1)*2);
}
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Solution {

	static InputReader in = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);
	static int exp = (int) (1e9);

	public static void main(String[] args) {

		int n = in.nextInt();
		String s = Integer.toString(n);
		ArrayList<Integer> sq = getSquares(n);

		for (int i = 0; i < sq.size(); i++) {
			String regex = getRegexed(Integer.toString(sq.get(i)));
			if (s.matches(regex)) {
				System.out.println(s.length() - Integer.toString(sq.get(i)).length());
				System.exit(0);
			}
		}
		System.out.println(-1);
	}

	static String getRegexed(String str) {
		String tmp = "";
		for (int i = 0; i < str.length(); i++) {
			tmp += ".*" + str.charAt(i) + ".*";
		}
		return tmp;
	}

	static ArrayList<Integer> getSquares(int n) {
		ArrayList<Integer> list = new ArrayList<>();
		int x = 1;
		while (x * x <= n) {
			list.add(x * x);
			x++;
		}
		Collections.reverse(list);
		return list;
	}

}

class Pair {

	int x;
	int y;

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

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

class OutputWriter {
	public PrintWriter writer;

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

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

	public void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void println(Object... objects) {
		print(objects);
		writer.println();
	}

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

class InputReader {
	private BufferedReader reader;
	private 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 String readLine() {
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	public char nextChar() {
		return next().charAt(0);
	}

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

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

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

	public float nextFloat() {
		return Float.parseFloat(next());
	}

}


/**
 * Created by IntelliJ IDEA.
 * User: aircube
 * Date: 10.04.11
 * Time: 16:36
 * To change this template use File | Settings | File Templates.
 */

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

public class taskA {

    void solve() throws IOException {
        Scanner in = new Scanner(System.in);
        int a[] = new int[3];
        for (int i = 0; i < 3; ++i)
            a[i] = in.nextInt();
        int k = in.nextInt();
        int b[] = new int[3];
        while (k > 0) {
            int c = -1;
            for (int i = 0; i < 3; ++i) {
                if (a[i] - b[i] - 1 > 0 && (c == -1 || b[i] < b[c]) )
                    c = i;
            }
            if (c == -1) break;
            b[c] ++;
            -- k;
        }
        System.out.print((long)(b[0] + 1) * (b[1] + 1) * (b[2] + 1));
    }

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


/**
 * DA-IICT
 * Author : Savaliya Sagar
 */
import java.io.*;
import java.math.*;
import java.util.*;

public class D908
{
	int k, mod = (int) (1e9 + 7);
	long pa, pb, pa_pb;
	long dp[][];

	void solve()
	{
		k = ni();
		dp = new long[k + 5][k + 5];
		for (int i = 0; i < k + 5; i++)
		{
			Arrays.fill(dp[i], -1);
		}
		int a = ni();
		int b = ni();
		pa = mul(a, pow(a + b, mod - 2, mod));
		pb = mul(b, pow(a + b, mod - 2, mod));
		pa_pb = mul(a, pow(b, mod - 2, mod));
		out.println(rec(1, 0));
	}

	long rec(int a, int ab)
	{
		if (ab >= k)
			return ab;
		if (a >= k)
		{
			return (a + 0L + ab + pa_pb) % mod;
		}
		if (dp[a][ab] != -1)
			return dp[a][ab];
		dp[a][ab] = rec(a + 1, ab) * pa + 0L + rec(a, ab + a) * pb;
		dp[a][ab] %= mod;
		return (dp[a][ab]);
	}

	long add(long a, long b)
	{
		long sum = a + b;
		if (sum >= mod)
			sum -= mod;
		return sum;
	}

	long sub(long a, long b)
	{
		long sub = a - b;
		if (sub < 0)
			sub += mod;
		return sub;
	}

	long mul(long a, long b)
	{
		return (a * b) % mod;
	}

	long pow(long x, long n, long mod)
	{
		long res = 1;
		x %= mod;
		while (n > 0)
		{
			if (n % 2 == 1)
			{
				res = (res * x) % mod;
			}
			x = (x * x) % mod;
			n /= 2;
		}
		return res;
	}

	void run() throws Exception
	{
		out = new PrintWriter(System.out);
		reader = new BufferedReader(new InputStreamReader(System.in), 32768);
		tokenizer = null;
		solve();
		out.flush();
	}

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

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;

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

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


/**
 *
 * @author sarthak
 */

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

public class ExpeEduRnd_H {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

        private int x, y;

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

        public int hashCode() {
            return (x * 31) ^ y;
        }

        public boolean equals(Object o) {
            if (o instanceof P) {
                P other = (P) o;
                return (x == other.x && y == other.y);
            }
            return false;
        }
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);

    long n=s.nextLong();
    long an=n*(n-1)*(n-2)*(n-3)*(n-4);//placing benches along north to south
    BigInteger ans=BigInteger.valueOf(an);//a bench from north to south alos has options
    ans=ans.multiply(ans); //all beches are identical
    ans=ans.divide(BigInteger.valueOf(120));

    System.out.println(ans);

    }

}


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author geek_guY
 */
public class que5 {

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

        inputz6 in = new inputz6(System.in);

        int a = in.nextInt();
        int b = in.nextInt();

        if(a==b)
        {
            System.out.println("0");
            return;
        }

        int a1[] = new int[6];
        int a2[] = new int[6];

        while(a%2==0)
        {
            a1[2]++;
            a/=2;
        }
        while(a%3==0)
        {
            a1[3]++;
            a/=3;
        }
        while(a%5==0)
        {
            a1[5]++;
            a/=5;
        }

        while(b%2==0)
        {
            a2[2]++;
            b/=2;
        }
        while(b%3==0)
        {
            a2[3]++;
            b/=3;
        }

        while(b%5==0)
        {
            a2[5]++;
            b/=5;
        }

        if(a!=b)
        {
            System.out.println(-1);
            return;
        }
        else
        {
            int d1 = Math.abs(a1[2]-a2[2]);
            int d2 = Math.abs(a1[3]-a2[3]);
            int d3 = Math.abs(a1[5]-a2[5]);
            System.out.println(d1+d2+d3);

        }

    }
}

class inputz6 {

    final private int BUFFER_SIZE = 1 << 17;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public inputz6(InputStream in) {
        din = new DataInputStream(in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String nextString() throws Exception {
        StringBuffer sb = new StringBuffer("");
        byte c = read();
        while (c <= ' ') {
            c = read();
        }
        do {
            sb.append((char) c);
            c = read();
        } while (c > ' ');
        return sb.toString();
    }

    public char nextChar() throws Exception {
        byte c = read();
        while (c <= ' ') {
            c = read();
        }
        return (char) c;
    }

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

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

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

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


import java.util.*;
import java.io.*;
public class Main {
	static BufferedReader br;
	static FileInputStream fis;
	static InputStreamReader isr;
	static FileWriter fw;

	public static void main(String[] args) throws IOException{
		//fis = new FileInputStream("input.txt");
		//isr = new InputStreamReader(fis);
		isr = new InputStreamReader(System.in);
		br = new BufferedReader(isr);
		//File file = new File("output.txt");
		//fw = new FileWriter(file);
		solve();
		//fis.close();
		isr.close();
		br.close();
		//fw.close();
		return;
	}

	// the followings are methods to take care of inputs.
	static int nextInt(){
		return Integer.parseInt(nextLine());
	}
	static long nextLong(){
		return Long.parseLong(nextLine());
	}
	static int[] nextIntArray(){
		String[] inp = nextLine().split("\\s+");
		int[] ary = new int[inp.length];
		for (int i = 0; i < ary.length; i++){
			ary[i] = Integer.parseInt(inp[i]);
		}
		return ary;
	}
	static int[] nextIntArrayFrom1(){
		String[] inp = nextLine().split("\\s+");
		int[] ary = new int[inp.length + 1];
		for (int i = 0; i < inp.length; i++){
			ary[i+1] = Integer.parseInt(inp[i]);
		}
		return ary;
	}
	static long[] nextLongArray(){
		String[] inp = nextLine().split("\\s+");
		long[] ary = new long[inp.length];
		for (int i = 0; i < inp.length; i++){
			ary[i] = Long.parseLong(inp[i]);
		}
		return ary;
	}
	static long[] nextLongArrayFrom1(){
		String[] inp = nextLine().split("\\s+");
		long[] ary = new long[inp.length + 1];
		for (int i = 0; i < inp.length; i++){
			ary[i+1] = Long.parseLong(inp[i]);
		}
		return ary;
	}
	static String nextLine(){
		try {
			return br.readLine().trim();
		} catch (Exception e){}
		return null;
	}
	static void write(String str){
		try{
			fw.write(str);
		}catch (Exception e){
			System.out.println(e);
		}
		return;
	}
	static void solve(){
		int[] tmp = nextIntArray();
		int n = tmp[0];
		int p = tmp[1];
		int k = tmp[2];
		String ret="";
		if(p != 1 && 1 < p-k){
				ret += "<< ";
		}
		for(int i=p-k;i<=p+k && i<=n;i++){
			if(i<=0){
				i = 1;
			}
			if(p == i){
				ret += "(" + p + ") ";
			}else{
				ret += i + " ";
			}
		}
		if(p + k < n){
			ret += ">>";
		}
		System.out.println(ret);
		return;
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

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

    StringTokenizer str = null;
    BufferedReader in;
    PrintWriter out;

    void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        out.flush();
        out.close();
    }

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

    String nextToken() throws IOException {
        if (str == null || !str.hasMoreElements()) {
            str = new StringTokenizer(nextString());
        }
        return str.nextToken();
    }

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

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

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

    class Point implements Comparable<Point> {
        int x;
        int y;

        @Override
        public int compareTo(Point p) {
            if (p.x > x)
                return -1;
            if (p.x < x)
                return 1;
            if (p.y > y)
                return -1;
            if (p.y < y)
                return 1;
            return 0;
        }
    }

    private double Rastoyanie(Point p[], int i, int l) {
        int xx = p[i].x - p[l].x;
        int yy = p[i].y - p[l].y;
        xx = xx * xx;
        yy = yy * yy;
        return Math.sqrt(xx + yy);
    }

    private boolean Na_odnoy_pramoy(Point p[], int i, int j, int l) {
        return (p[i].y - p[j].y) * p[l].x + (p[j].x - p[i].x) * p[l].y
                + (p[i].x * p[j].y - p[j].x * p[i].y) == 0;
    }

    boolean isPrime(long p) {
        int t = (int) (Math.sqrt(p) + 1);
        for (int i = 2; i < t; i++) {
            if (p % i == 0)
                return false;
        }
        return true;
    }

    void solve() throws IOException {
        long n = nextLong();
        long r = 0;
        long i;
        while (n > 1) {
            int t = (int) (Math.sqrt(n) + 1);

            for (i = 2; i < t; i++) {
                if (n % i == 0) {
                    break;
                }
            }
            if (i == t) {
                i = n;
            }
            while (n % i != 0) {
                i++;
            }
            r += n;
            n = n / i;
        }
        r += 1;
        out.println(r);
    }
}


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

public class A {

    public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);
        int year = input.nextInt();
        int firstDay=3;
        int Day=3;
        int yearDay=0;
        int Days=0;
        for (int current = 1000; current < year+200; current++) {
            int days=365;
            if(current%4==0 && current%100!=0 || current%400==0){
                days++;
            }
            if(current==year){
                yearDay=Day;
                Days=days;
            }
            if(current>year && Day==yearDay && days==Days){
                out.println(current);
                break;
            }
            for(int j=365; j<=days; j++){
                Day=(Day+1)%7;
            }
        }
    }
}


import java.util.Scanner;

public class C {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String burger = sc.nextLine();
		long B = 0;
		long S = 0;
		long C = 0;
		long count = 0;
		for(int i = 0; i < burger.length(); i++){
                        char c = burger.charAt(i);
			if(c == 'B'){
				B++;
			}
			else if(c == 'S'){
				S++;
			}
			else if(c == 'C'){
				C++;
			}
		}
		long nB = sc.nextLong();
		long nS = sc.nextLong();
		long nC = sc.nextLong();

		long pB = sc.nextLong();
		long pS = sc.nextLong();
		long pC = sc.nextLong();

		long r = sc.nextLong();
		do {
			long min = Long.MAX_VALUE;
			if(B != 0){
				min = Math.min(nB/B, min);
			}
			else{
				nB = 0;
			}
			if(S != 0){
				min = Math.min(nS/S, min);
			}
			else{
				nS = 0;
			}
			if(C != 0){
				min = Math.min(nC/C, min);
			}
			else{
				nC = 0;
			}
			count+=min;
			nC -= C*min;
			nS -= S*min;
			nB -= B*min;
			if(nC == nS && nS == nB && nB == 0){
				break;
			}
			if(B!= 0 && nB < B){
				r -= (B-nB)*pB;
				nB = B;
			}
			if(S!= 0 && nS < S){
				r-= (S-nS)*pS;
				nS = S;
			}
			if(C!= 0 && nC < C){
				r-= (C-nC)*pC;
				nC = C;
			}
		} while (!(r<0));
		long costOfBurger = B*pB + S*pS + C*pC;
		if(r > 0){
			count += r/costOfBurger;
		}
		System.out.println(count);

	}
}