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

public class Main {

    static BigInteger Gcd(BigInteger a, BigInteger b){
        BigInteger m = BigInteger.valueOf(1);
        while(m.equals(BigInteger.ZERO) == false){
            m = a.mod(b);
            a = b;
            b = m;
        }
        return a;
    }
    static BigInteger Lcm(BigInteger a, BigInteger b){
        BigInteger g = Gcd(a, b);
        a = a.divide(g);
        a = a.multiply(b);
        return a;
    }

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

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

        int mm;
        if(b > c)mm = c;
        else
            mm = b;

        mm--;

        BigInteger L = BigInteger.valueOf(a);
        BigInteger A = BigInteger.valueOf(b);
        BigInteger B = BigInteger.valueOf(c);

        BigInteger l = Lcm(A, B);

        BigInteger m = BigInteger.valueOf(mm);

        BigInteger ttmp = L.divide(l);

        BigInteger s = (ttmp).add(ttmp.multiply(m));

        if((L.mod(l)).equals(BigInteger.ZERO) == false){
            BigInteger tmp = L.mod(l);
            int tm = tmp.intValue();
            if(tm > mm)tm = mm;
            s = s.add(BigInteger.valueOf(tm));
        }

        BigInteger p = L;

        if(s.equals(BigInteger.ZERO) == true){
            System.out.println("0/"+a);
        }else{
            BigInteger g = Gcd(s, p);
            s = s.divide(g);
            p = p.divide(g);
            System.out.println(s.toString() + "/" + p.toString());
        }
    }
}


import java.util.*;
import java.math.*;
public class Main {
	public static int[] swap(int[] data) {
		int temp=data[0];
		data[0]=data[1];
		data[1]=temp;
		return data;
	}
	public static int[] shift(int[] data) {
		int temp=data[0];
		for(int i=0;i<data.length-1;i++) {
			data[i]=data[i+1];
		}
		data[data.length-1]=temp;
		return data;
	}
    public static void main(String[] args) {
    	Scanner s=new Scanner(System.in);
    	int n=s.nextInt();
    	int m=s.nextInt();
    	int ans=0;
    	for(int i=1;i<=n;i++) {
    		for(int j=1;j<=m;j++) {
    			if((i+j)%5==0){
    				ans++;
    			}
    		}
    	}
    	System.out.println(ans);

    }
}


import java.util.Scanner;
public class InfiniteSequence {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		boolean fl = false;
		while((a<=b && b>=0)||(a>=b && b<=0)){
			if(b==a){
				fl=true;
				break;
			}
			a+=c;
		}
		if(fl==false)
			System.out.println("NO");
		else
			System.out.println("YES");
	}

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package example;

/**
 *
 * @author Opu
 */
import java.io.*;
import java.util.*;
public class Example {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       Scanner scan=new Scanner(System.in);
       double a,b,c,d;
       double misha,vasya;
       a=scan.nextInt();
       b=scan.nextInt();
       c=scan.nextInt();
       d=scan.nextInt();
       misha=a-(a/250)*c;
       a=(3*a)/10;
       if(a>misha) misha=a;
       vasya=b-(b/250)*d;
       b=(3*b)/10;
       if(b>vasya) vasya=b;
       if(vasya==misha) System.out.println("Tie\n");
       else if(vasya>misha) System.out.println("Vasya\n");
       else if(vasya<misha) System.out.println("Misha\n");
    }


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        private static int[] cntComops;
        private static boolean[] markComps;
        private static boolean[][] matrix;
        private static int ch;
        private static char[] result;

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

            int n = in.nextInt();
            int m = in.nextInt();
            ch = 0;
            result = new char[n];
            List<List<Integer>> g = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                g.add(new ArrayList<>());
            }
            matrix = new boolean[n][n];

            for (int i = 0; i < m; i++) {
                int v = in.nextInt() - 1;
                int u = in.nextInt() - 1;
                g.get(v).add(u);
                g.get(u).add(v);
                matrix[v][u] = true;
                matrix[u][v] = true;
            }
            cntComops = new int[n];
            int compLabel = 0;
            List<List<Integer>> comps = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                if (cntComops[i] == 0) {
                    List<Integer> subGraph = new ArrayList<>();
                    Set<Integer> subset = new HashSet<>();
                    subGraph.add(i);
                    subset.add(i);
                    cntComops[i]++;
                    int it = 0;
                    while (it < subGraph.size()) {
                        int cur = subGraph.get(it++);
                        for (int j = 0; j < g.get(cur).size(); j++) {
                            int to = g.get(cur).get(j);
                            if (!subset.contains(to)) {
                                Set<Integer> toSubset = new HashSet<>(g.get(to));
                                if (toSubset.containsAll(subGraph)) {
                                    subGraph.add(to);
                                    subset.add(to);
                                    cntComops[to]++;
                                }
                            }
                        }
                    }
                    compLabel++;
                    comps.add(subGraph);
                }
            }

            for (int i = 0; i < n; i++) {
                if (cntComops[i] > 2) {
                    out.print("No");
                    return;
                }
            }
            for (int i = 0; i < comps.size(); i++) {
                for (int j = i + 1; j < comps.size(); j++) {
                    for (int x : comps.get(i)) {
                        for (int y : comps.get(j)) {
                            if (x != y && matrix[x][y] && cntComops[x] == 1 && cntComops[y] == 1) {
                                out.print("No");
                                return;
                            }
                        }
                    }
                }
            }
            markComps = new boolean[comps.size()];
            for (int i = 0; i < comps.size(); i++) {
                if (!markComps[i] && isStart(comps.get(i))) {
                    dfs(i, comps);
                }
            }
            if (ch > 4) {
                out.println("No");
                return;
            }
            out.println("Yes");
            for (int i = 0; i < n; i++) {
                out.print(result[i]);
            }

        }

        private static boolean isStart(List<Integer> comp) {
            for (int i = 0; i < comp.size(); i++) {
                if (cntComops[comp.get(i)] == 1) {
                    return true;
                }
            }
            return false;
        }

        private static void dfs(int id, List<List<Integer>> g) {
            markComps[id] = true;
            char cur = (char) (ch + 'a');
            char next = (char) (ch + 1 + 'a');
            for (int i = 0; i < g.size(); i++) {
                if (!markComps[i] && isBro(g.get(id), g.get(i))) {
                    for (int x : g.get(id)) {
                        boolean isX = true;
                        for (int y : g.get(i)) {
                            if (x == y) {
                                isX = false;
                                break;
                            }
                        }
                        if (result[x] == 0) {
                            if (isX) {
                                result[x] = cur;
                            } else {
                                result[x] = next;
                            }
                        }
                    }
                    ch += 2;
                    dfs(i, g);
                    return;
                }
            }
            for (int x : g.get(id)) {
                if (result[x] == 0) {
                    result[x] = cur;
                }
            }
            ch += 2;
        }

        private static boolean isBro(List<Integer> a, List<Integer> b) {
            for (Integer x : a) {
                for (Integer y : b) {
                    if (matrix[x][y]) {
                        return true;
                    }
                }
            }
            return false;
        }

    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner(InputStream io) {
            br = new BufferedReader(new InputStreamReader(io));
        }

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

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

    }
}


import java.util.Scanner;
public class pillow {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int n= s.nextInt();
		int m = s.nextInt();
		int k = s.nextInt();
		int p = m-n;
		int[] arr = new int[n];
        int i=1;
        int a=0;
        int b=0;
        if(n==1){
            arr[k-1]=m-1;
            p=0;
        }
		while(p>0){
            a=k-i-1;
            if(a<0)
                a=0;
            b=k+i-1;
            if(b>n)
                b=n-1;
            arr[k-1]++;
            p-=b-a+1;
			i++;
		}
		System.out.println(++arr[k-1]);
	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class TaskB
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int n = in.nextInt();
            int p = in.nextInt();
            int pos = in.nextInt() - 1;

            int low = 0;
            int high = p + 1;
            while (high - low > 1)
            {
                int mid = low + (high - low) / 2;
                if (check(mid, p, pos, n))
                {
                    low = mid;
                } else
                {
                    high = mid;
                }
            }
            out.println(low);
        }

        private boolean check(int Q, int all, int pos, int n)
        {
            int[] a = new int[n];
            Arrays.fill(a, 1);

            all -= n;
            a[pos] = Q - 1;
            all -= Q - 1;
            for (int i = pos - 1, q = Q - 2; i >= 0 && q > 0; i--)
            {
                a[i] = q;
                all -= q;
                q--;
                if (all < 0)
                {
                    return false;
                }
            }
            for (int i = pos + 1, q = Q - 2; i < n && q > 0; i++)
            {
                a[i] = q;
                all -= q;
                q--;
                if (all < 0)
                {
                    return false;
                }
            }
            return all >= 0;
        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

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

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

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

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

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

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

    }
}


import java.util.*;
public class chess_secapproach{

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

        int allblack = 0 , allwhite= 0;

        int[] arr = new int[n/2];

        for(int i = 0;i < n/2;i++){
            arr[i] = s.nextInt();
        }

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

            allblack += (Math.abs(arr[i] - (2*i + 1 )))s;
            allwhite += (Math.abs(arr[i] - (2*i + 2 )));
        }

        System.out.println(Math.min(allblack , allwhite ));

    }
}


import java.math.BigInteger;
import java.util.Scanner;

public class Round107_ProbD {
    static long F = 1000000007;

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        Disjoint2 ds = new Disjoint2(n);
        for(int i =0;i < n-k+1;i++)
            for(int j =i;j < i+k/2;j++)
                ds.union(j, j+(k/2-(j-i)));
        int c = ds.noOfConnection();
            System.out.println(((new BigInteger(m + "").pow(c))
                    .mod(new BigInteger("" + F))).toString());
    }
}

class Disjoint2 {
        int[] parent;
        int c;
        public Disjoint2(int n) {

            c =n;
            parent = new int[n];
            for (int i = 0; i < n; i++)
                parent[i] = i;
        }

        public int getParent(int i) {
            if (i == parent[i])
                return i;
            return parent[i] = getParent(parent[i]);
        }

        public boolean areSameSet(int i, int j) {
            return (getParent(i) == getParent(j));
        }

        public void union(int i, int j) {
            if(!areSameSet(i, j))
                {
                c--;
                parent[i] = getParent(j);
                }
        }

        public int noOfConnection()
        {
            return c;
        }
}


import java.util.*;
public class A {
    static class Parser {
        final private int BUFFER_SIZE = 1 << 16;

        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

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

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

        public int nextLong() 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;
        }

        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++];
        }
    }
    public static void main(String[] args) throws Exception {
        Parser aa=new Parser(System.in);
        int x=aa.nextLong();
        int y=aa.nextLong();
        int val;
        int t=0;
        while(true) {
            //System.out.println(x+" "+y);
            if(t==0) {
                val=x*100+y*10;
                if(val<220){
                    System.out.println("Hanako"); return;
                }
                int mx=Math.min(x,2);
                x-=mx;
                int rem=220-mx*100;
                int my=rem/10;
                if(my>y){
                    System.out.println("Hanako"); return;
                }
                y-=my;
                t=1;
            }
            else {
                val=x*100+y*10;
                if(val<220){
                    System.out.println("Ciel"); return;
                }
                int my;
                if(y>=12) {
                    my=12;
                }else if(y>=2) {
                    my=2;
                }
                else {
                    System.out.println("Ciel"); return;
                }
                y-=my;
                int rem=220-my*10;
                int mx=rem/100;
                x-=mx;
                t=0;
            }
        }
    }
}


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

public class KanbanNumbers {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        Map<Integer, String> mapa = new HashMap<>();
        mapa.put(1, "one");
        mapa.put(2, "two");
        mapa.put(3, "three");
        mapa.put(4, "four");
        mapa.put(5, "five");
        mapa.put(6, "six");
        mapa.put(7, "seven");
        mapa.put(8, "eight");

        if(n==70 || n==90) System.out.println("NO");

        if(n==12) System.out.println("YES");
        if(n<10 || n%10==0){
            if(n%10==0 && n!=20) n /= 10;
            if(n == 20 || mapa.get(n).contains("n")){
                System.out.println("NO");
            }else{
                System.out.println("YES");
            }
        }
        if((n>29 && n < 70) || (n>=80 && n<90)){
            if(mapa.get(n%10).contains("n")){
                System.out.println("NO");
            }else{
                System.out.println("YES");
            }
        }
        if((n>10 && n<=29 && n!=12 && n!=20) || (n>=70 && n< 80) || n>90){
            System.out.println("NO");
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Alex
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskA {
        boolean f(int i1, int j1, int i2, int j2) {
            if (i1 == i2 && j1 == j2) return false;
            return Math.abs(i1 - i2) + Math.abs(j1 - j2) <= 1;
        }
        int good(int n) {
            boolean[][] taken = new boolean[n][n];
            for (int i = 0; i < n; i++) {
                outer:
                for (int j = 0; j < n; j++) {
                    if (f(i, j, n - i - 1, j) || f(i, j, i, n - j - 1) || f(i, j, n - i - 1, n - j - 1)) {
                        continue;
                    }
                    for (int k = 0; k < 4; k++) {
                        int ni = i + MiscUtils.DX4[k];
                        int nj = j + MiscUtils.DY4[k];
                        if (MiscUtils.isValidCell(ni, nj, n, n)) {
                            if (taken[ni][nj]) {
                                continue outer;
                            }
                        }
                    }
                    taken[i][j] = true;
                }
            }
            int res = 0;
            for (boolean[] bb : taken) for (boolean b : bb) if (b) res++;
            return res;
        }
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int x = in.readInt();
            for (int side = 1; side <= 1000; side++) {
                int can = good(side);
                if (x % 4 == 0) {
                    if (can >= x) {
                        out.printLine(side);
                        return;
                    }
                }
                if (x % 4 == 1) {
                    if (can % 4 == 1) {
                        if (can >= x) {
                            out.printLine(side);
                            return;
                        }
                    }
                }
            }
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;
        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }
        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }
        public void close() {
            writer.close();
        }
        public void printLine(int i) {
            writer.println(i);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }
        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class MiscUtils {
        public static final int[] DX4 = {1, 0, -1, 0};
        public static final int[] DY4 = {0, -1, 0, 1};
        public static boolean isValidCell(int row, int column, int rowCount, int columnCount) {
            return row >= 0 && row < rowCount && column >= 0 && column < columnCount;
        }
    }
}


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("nhap");
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (Math.pow(x, y) > Math.pow(y, x)) {
			System.out.println(">");
		} else if (Math.pow(x, y) == Math.pow(y, x)) {
			System.out.println("=");
		} else {
			System.out.println("<");
		}
	}

}


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class B {

    private static final Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
       int n = scan.nextInt();
       int n2 = n;
       int k = scan.nextInt();
       int A = scan.nextInt();
       int B = scan.nextInt();
       int[] mem = new int[n+1];
       long cost = 0;

       while(n!= 1){
           if(n<k){
               cost+=A*(n-1);
               break;
           }
           if(n%k != 0){

               int rem = n%k;
               cost+=(A*rem);
               n = n-rem;
           }else{
               // keep deducting cost
               int nextN= n/k;
               long deductCost = (A*(n-nextN));
               long divideCost = B;
               cost += Math.min(deductCost,divideCost);
               n = nextN;
           }
       }
//        System.out.println(findResult(n2,k,A,B,mem));
       System.out.println(cost);

    }
//    public static int findResult(int n, int k, int A, int B, int[] mem){
//        if(n == 1){
//            mem[n] = 0;
//            return 0;
//        }
//        if(mem[n] > 0 ){
//            return mem[n];
//        }else{
//            int subResult = findResult(n-1,k,A,B,mem);
//            int divideResult = -1;
//            if(n%k == 0){
//                divideResult = findResult(n/k,k,A,B,mem);
//            }
//            if(divideResult < 0){
//                mem[n] = subResult+A;
//            }else{
//                mem[n] = Math.min(subResult+A, divideResult+B);
//            }
//            return mem[n];
//        }
//    }

}


import java.util.Scanner;

public class proba {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x = sc.nextInt();
		double y = sc.nextInt();
		int n = sc.nextInt();
		int ans_a =  0;
		int ans_b = 0;
		double min = x*x*n*n;
		for (int b = 1; b <=n; b++) {
			for (int a = 0; a <=x*b; a++) {
				if (Math.abs((double)x/y-(double)a/b) < min){
					min = Math.abs((double)x/y-(double)a/b);
					ans_a = a;
					ans_b = b;
				}
			}
		}
		int g =gcd(ans_a,ans_b);
		System.out.println(ans_a/g+"/"+ans_b/g);
	}
	private static int gcd(int a, int b) {
		return b == 0?a:gcd(b,a%b);
	}
}


import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        String entry=new String(input.next());
        String result=new String();
        while(entry.contains("1")){
            result+="1+";
            entry=entry.replace('2', '4');
        }
        while(entry.contains("2")){
            result+="2+";
            entry=entry.replace('2', '4');
        }
        while(entry.contains("3")){
            result+="3+";
            entry=entry.replace('3', '4');
        }
        result=result.substring(0, entry.length()-1);
        System.out.println(result);
        input.close();
    }
}


//package CFFEB24;

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

import static java.lang.System.exit;

public class Q1 {

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

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(System.in), 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 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 static void main(String[] args) {

        InputReader in = new InputReader();
        int P = in.nextInt();
        int Y = in.nextInt();

        if (P >= Y) {
            System.out.println("-1");
            exit(0);
        }

        Boolean ans[] = new Boolean[P + 1];
        ans[0] = ans[1] = false;

        for (int i = 2; i < P + 1; i++) {
            ans[i] = true;
        }

        for (int i = 2; i * i <= P; i++) {
            for (int j = i * i; j <= P; j += i) {
                ans[j] = false;
            }
        }

        HashMap<Integer, Integer> map1 = new HashMap<>();

        for (int q = 0; q <= P; q++) {
            if (ans[q]) {
//                System.out.println(q);
                map1.put(q, 1);
            }
        }

//        for(Map.Entry<Integer,Integer> ent : map1.entrySet()){
//            System.out.print(ent.getKey());
//        }
//
//        for(int i=0;i<6;i++) {
//            for (Integer key1 : map1.keySet()) {
//                System.out.print(key1+" " );
//            }
//            System.out.println();
//        }

        for (int i = Y; i > P; i--) {

            if (i % 2 == 0) {

                continue;
            }

            int flag = 0;

            for (Integer Key : map1.keySet()) {

                int ans11 = Key;
                if (i % ans11 == 0) {
                    flag = 1;
                    break;
                }
            }

            if (flag == 1) {
                continue;
            }

            System.out.println(i);
            exit(0);
        }

            System.out.println("-1");

        }

}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class Test {

  static PrintWriter writer =
      new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

  static int readInt() {
    int ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static long readLong() {
    long ans = 0;
    boolean neg = false;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (c == '-') {
          start = true;
          neg = true;
          continue;
        } else if (c >= '0' && c <= '9') {
          start = true;
          ans = ans * 10 + c - '0';
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return neg ? -ans : ans;
  }

  static String readString() {
    StringBuilder b = new StringBuilder();
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c)) {
          start = true;
          b.append((char) c);
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return b.toString();
  }

  static int readChars(char[] a, int off) {
    int cnt = 0;
    try {
      boolean start = false;
      for (int c = 0; (c = System.in.read()) != -1; ) {
        if (Character.isLetterOrDigit(c)) {
          start = true;
          a[off + cnt++] = (char) c;
        } else if (start) break;
      }
    } catch (IOException e) {
    }
    return cnt;
  }

  public static void main(String[] args) {
    Test te = new Test();
    te.start();
    writer.flush();
  }

  long f(long n) {
    long ret = n;
    long v = n;
    for (long i = 2; i*i <= v; i++)
      if (v % i == 0) {
        while (v % i == 0) v /= i;
        ret =ret*(i-1)/i;
      }
    if (v > 1) ret = ret*(v-1)/v;
    return ret;
  }

  long F(long n, long k) {
    if (n == 1) return 1;
    if (k == 1) return f(n);
    if (k % 2 == 0) return F(n, k-1);
    return f(F(n, k-1));
  }

  void start() {
    long n = readLong(), k = readLong();
    writer.println(F(n, k) % 1_000_000_007);
  }
}


import java.util.*;
public class april {
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long time = System.currentTimeMillis();
      StringTokenizer s = new StringTokenizer(sc.nextLine());
      TreeSet<Long> t = new TreeSet<Long>();
      while(s.hasMoreTokens()){
         t.add(Long.parseLong(s.nextToken());
      }
      while(System.currentTimeMillis() - time < 2100){

      }
      for(long i : t){
         System.out.print(i + " ");
      }
   }
}


package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner (System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        for (int res = 1; res < 31; res++) {
            long  cur = n - res * p;
            int numbit=Long.bitCount(cur);
            if(numbit<=res&&cur>0) {
                System.out.print(res);
                return;
            }
        }
        System.out.print(-1);
    }
}


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

public class PRSP170B {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(f.readLine());
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int r = Integer.parseInt(st.nextToken());
		ArrayList<Integer> nums = new ArrayList<Integer>();
		r=(a*r+b)%m; nums.add(r);
		r=(a*r+b)%m; nums.add(r);
		int t=0; int h=1;
		while(nums.get(h)!=nums.get(t)){
			r=(a*r+b)%m; nums.add(r);
			r=(a*r+b)%m; nums.add(r);
			t++;
			h+=2;
		}
		int first=nums.get(t);
		int period=1;
		while(nums.get(t+period)!=first){
			period++;
		}
		System.out.println(period);
	}
}


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

public class AA {
	public static void main(String[] args) throws IOException {
		int n = 3200000;
		int[] primes = new int[230209];
		int c = 0;
		boolean[] isComposite = new boolean[n];
		for (int i = 2; i < n; i++) {
			if (!isComposite[i]) {
				primes[c++] = i;
				for (int j = i + i; j < n; j += i) {
					isComposite[j] = true;
				}
			}
		}
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		long x = new Long(s);
		long xx = x;
		if (isPrime(x)) {
			System.out.println(1);
			System.out.println(0);
			return;
		}
		int primeFactors = 0;
		long winPosition = 1;
		for (int i = 0; i < primes.length; i++) {
			while (x % primes[i] == 0) {
				x /= primes[i];
				primeFactors++;
				winPosition *= primes[i];
				if (primeFactors == 2 && winPosition != xx) {
					System.out.println(1);
					System.out.println(winPosition);
					return;
				}
			}
		}
		System.out.println(2);
	}

	private static boolean isPrime(long x) {
		if (x == 1 || x == 2)
			return true;
		if (x % 2 == 0)
			return false;
		for (long i = 3; i * i <= x; i += 2)
			if (x % i == 0)
				return false;
		return true;
	}
}


import java.util.Scanner;

public class MultiColoredMarkers {

    public static boolean checkSmallRectangleCanBePlacedIntoBigRectangle(long smallRectangleSide, long a, long BigRectangleSide, long s){
        return ((smallRectangleSide <= BigRectangleSide) && ((a / smallRectangleSide) <= (s / BigRectangleSide)));
    }

    public static long[] getDividersPerValue(long n){
        long sqrtOfN = (int) Math.sqrt(n);
        long[] dividers = new long[(int)sqrtOfN];

        int i = 0;
        for (long divider = 1; divider <= sqrtOfN; divider++){
            if (n % divider == 0) {
                dividers[i++] = divider;
            }
        }
        return dividers;
    }

    public static long checkDiveders(long[] dividersForInnerRectangle, long[] dividersForExternalRectangle,
                                     long innerRectangleS, long ExternalRectangleS, long bestP){
        long newBestP = bestP;
        for (long dividerInner : dividersForInnerRectangle){
            if (dividerInner == 0){
                break;
            }
            for (long dividerExternal : dividersForExternalRectangle){
                if (dividerExternal == 0){
                    break;
                }
                if (checkSmallRectangleCanBePlacedIntoBigRectangle(dividerInner, innerRectangleS, dividerExternal, ExternalRectangleS)){
                    newBestP = Math.min(bestP, 2 * (dividerExternal + ExternalRectangleS/dividerExternal));
                }
            }
        }
        return newBestP;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long s = a + b;
        long[] dividersA = getDividersPerValue(a);
        long[] dividersS = getDividersPerValue(s);
        long[] dividersB = getDividersPerValue(b);
        long bestP = 2 * s;

        bestP = Math.min(bestP, checkDiveders(dividersA,dividersS,a,s,bestP));
        bestP = Math.min(bestP, checkDiveders(dividersB,dividersS,b,s,bestP));
        System.out.println(bestP);
    }
}


import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner kb = new Scanner(System.in);
		int x = kb.nextInt();
		if(x==1){
			System.out.println("1");
			return;
		}
		int array[] = new int[x+1];
		int num = 0;
		String a = ""+x;
		int count = 0;
		for(int i=2;i<=Math.sqrt(x);i++){
			//if(x%i==0){
				array[count++] = i;
				int temp = x/i;
				if(temp!=i)array[count++] = temp;
			//}
		}
		array[count++] = 1;
		array[count++] = x;
		for(int i=0;i<count;i++){
			String b = ""+array[i];
			boolean check = false;
			for(int j=0;j<b.length();j++){
				if(a.contains(""+b.charAt(j))){
					check = true;
					break;
				}
			}
			if(check==false){
				for(int j=0;j<a.length();j++){
					if(b.contains(""+a.charAt(j))){
						check = true;
						break;
					}
				}
			}
			if(x%array[i]==0&&check==true){
				//System.out.println(array[i]);
				num++;
			}
		}
		System.out.println(num);

	}

}


import java.util.Scanner;

/**
 * Created by Kirill Antonov on 19.02.2016.
 */

public class codeforces {
    static class Point {
        long x, y;

        public Point(long x, long y) {
            this.x = x;
            this.y = y;
        }
    }

    static class Line {
        long a, b, c;
        Point p, q;

        public Line(Point a, Point b) {
            this.p = a;
            this.q = b;
            this.a = b.y - a.y;
            this.b = a.x - b.x;
            this.c = a.y * b.x - a.x * b.y;
        }
    }

    public static boolean compr(Line l, Point p) {
        if (l.a * p.x + l.b * p.y + l.c == 0) return true;
        return false;
    }

    public static boolean perp(Line l1, Line l2) {
        long n1 = l1.p.x - l1.q.x, m1 = l1.p.y - l1.q.y, n2 = l2.p.x - l2.q.x, m2 = l2.p.y - l2.q.y;
        if (n1 * n2 + m1 * m2 == 0) {
            return true;
        }
        return false;
    }

    public static Point a;
    public static Point b;
    public static Point c;

    public static boolean check(Line l, int i, boolean ox) {
        if (i == 0) return checker(c, l, ox);
        if (i == 1) return checker(b, l, ox);
        if (i == 2) return checker(a, l, ox);
        return false;
    }

    public static boolean checker(Point k, Line l, boolean ox) {
        long upy = Math.max(l.q.y, l.p.y), upx = Math.max(l.p.x, l.q.x), downy = Math.min(l.q.y, l.p.y), downx = Math.min(l.q.x, l.p.x);
        if (ox) {
            if (downy <= k.y && k.y <= upy) return false;
            else return true;
        } else {
            if (downx <= k.x && k.x <= upx) return false;
            else return true
        }

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        a = new Point(in.nextInt(), in.nextInt());
        b = new Point(in.nextInt(), in.nextInt());
        c = new Point(in.nextInt(), in.nextInt());
        Line oy = new Line(new Point(0, 0), new Point(0, 1)), ox = new Line(new Point(0, 0), new Point(1, 0));
        Line ab = new Line(a, b), bc = new Line(b, c), ac = new Line(a, c);
        Line[] lines = {ab, ac, bc};
        int ans = 0;
        if ((perp(ab, ox) && perp(ac, ox)) || (perp(ab, oy) && perp(ac, oy))) ans = 1;
        else {
            for (int i = 0; i < 3; i++) {
                if (perp(lines[i], ox)) {
                    if (check(lines[i], i, true)) ans = 2;
                    break;
                }
                if (perp(lines[i], oy)) {
                    if (check(lines[i], i, false)) ans = 2;
                    break;
                }
            }
            if (ans == 0) ans = 3;
        }
        System.out.print(ans);
    }
}


import java.util.Scanner;

public class Sampl2
{

	public static void main(String[] args)
	{	Scanner s = new Scanner(System.in);
                int a = s.nextInt();
                int b = s.nextInt();
                int c = s.nextInt();
                int n = s.nextInt();
                int y = a+b-c;
                if(y < n & y=> 0 & c<=a & c<=b){
                    System.out.println(n-y);
                }else{
                    System.out.println("-1");
                }

	}
}


import java.io.*;
import java.util.*;
import java.lang.*;
 public class test{
      static class FastReader{
          BufferedReader br;
          StringTokenizer st;
          public FastReader(){
            br=new BufferedReader(new InputStreamReader(System.in));
           }
        public FastReader(String s)throws FileNotFoundException{
       br=new BufferedReader(new FileReader(new File(s)));
         }
       String next(){
         while(st==null ||!st.hasMoreElements()){
             try{
                  st=new StringTokenizer(br.readLine());
                   }
             catch(IOException e){
                  e.printStackTrace();
                     }
              }
             return st.nextToken();
          }
        int nextInt(){
           return Integer.parseInt(next());
         }
        long nextLong(){
          return Long.parseLong(next());
           }
         Double nextDouble(){
          return Double.parseDouble(next());
           }
       String nextLine(){
          String str="";
         try{
            str=br.readLine();
            }
         catch(IOException e){
            e.printStackTrace();
           }
         return str;
       }
  }
  public  static void main(String args[]){
    FastReader in=new FastReader();
      int n=in.nextInt();
     int p=in.nextInt();
      int q=in.nextInt();
       int a[]=new int[n];
       for(int i=0;i<n;i++)
         a[i]=in.nextInt();
       int cost=0;
        int min=(p>q)?q:p;
       for(int i=0;i<n/2;i++){
       if((a[i]==2 && a[n-1-i]==0)||(a[i]==0 && a[n-1-i]==2)){
        cost+=p; a[i]=0;a[n-1-i]==0    }
       else if((a[i]==2 && a[n-1-i]==1)||(a[i]==1 && a[n-1-i]==2)){
          cost+=q;a[i]=1;a[n-1-i]=1;
    }
       else if(a[i]==2 && a[n-i-1]==2){
         cost+=min*2;   a[i]=0;a[n-1-i]=0;}
        else if((a[i]==1 && a[n-1-i]==0)||(a[i]==0 && a[n-1-i]==1)){
           cost=-1;
            break;
                }
             }
          if(cost!=-1 && a[n/2]==2)
         cost+=min;
          System.out.print(cost);
    }
 }


import java.io.PrintWriter;

import java.util.*;
import java.util.Arrays ;
import java .lang.String.* ;
import java .lang.StringBuilder ;

public class Test{
    static int pos = 0 ;
    static int  arr[] ;
  static LinkedList l1 = new  LinkedList() ;
static void find(int p ,char[]x,int put[],String s){
    int c= 0 ;
    for (int i = 0; i < s.length(); i++) {
        if(x[p]==s.charAt(i)){
        c++ ; }
    }
    put[p] = c ;
}
static int mode(int m ,int[]x ){
    int temp = 0 ;
    for (int i = x.length-1; i >=0; i--) {
        if(x[i]<=m){
            temp= x[i] ;
           /// break ;
             return m-temp ;

        }
    }
     return m-temp ;
}
static int mode2(int m ,int[]x ){
    int temp = 0 ;

    for (int i = x.length-1; i >=0; i--) {
        if(x[i]<=m){
            temp= x[i] ;
           /// break ;
             return x[i] ;

        }
    }
     return 0 ;
}
static int find(int x[],int temp){
    int j = 0 ;
    for (int i = x.length-1; i >=0; i--) {
        if(x[i]==temp) return j+1 ;
        j++ ;
    }
    return -1 ;
}
static String ch(long[]x,long b){
    for (int i = 0; i < x.length; i++) {
        if(x[i]==b)return "YES" ;
    }
    return "NO" ;
}

    public static void main(String[] args)  {

        Scanner in = new Scanner(System.in) ;
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt() ;
        int m = in.nextInt() ;
        long k = in.nextLong() ;
     //   if(n%2!=0)n++ ;
        int p = 2 ;
        if(k%2!=0)p-- ;
        int x[][] =new int[m][n] ;
        long save1=0 ;
        long save2=0 ;

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

         x[j][i]= p ;
            p+=2 ;
        }
         }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
               // System.out.println(p);
                if(x[i][j]==k) {

                    save1= i+1 ;
                    save2 = j+1 ;

                   break ; }

            }
           // p+=2 ;
        }
         char y  ;
         if(k%2==0){
             y='R' ;
         }else y='L' ;

         System.out.println(save2+" "+save1+" "+ y);
 }
}


import java.util.Scanner;

public class BerOS {
	public static void main(String[]args){
		Scanner reader=new Scanner(System.in);
		String str=reader.nextLine();
		while(str.contains("//")){
			str.replaceAll("//", "/");
			}
		if (str.length() > 1 && str.charAt(str.length() - 1) == '/')
            str = str.substring(0, str.length() - 1);
        System.out.println(str);

	}

}


import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) throws Exception
	{
	    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	    String s=br.readLine();
	    String str[]=s.split(" ");
	    int n=Integer.parseInt(str[0]);
	    int m=Integer.parseInt(str[1]);
	    int k=Integer.parseInt(str[2]);
	    String s1=br.readLine();
	    String str1[]=s1.split(" ");
	    int arr[]=new int[n];
	    int sum=0;
	    for(int i=0;i<n;i++)
	    arr[i]=Integer.parseInt(str1[i]);
	    Arrays.sort(arr);
	    for(int i=n-1,j=1;j<=k;i--,j++)
	    sum=sum+arr[i];
	    if(sum<m)
	    {
	        System.out.println("-1");
	        return;
	    }
	    int tem=n-1;
	    while(m>k)
	    {
	        k=k+arr[tem]-1;
	        tem--;
	    }
	    System.out.println(n-tem-1);
	}
}


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

public class B8{
	public static void main(String[] args) throws Exception{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String path=br.readLine();
		int[][] ori=new int[][]{{0,-1},{0,1},{-1,0},{1,0}};
		String[] oris=new String[]{"L","R","U","D"};

		char chs[][]=new char[201][201];
		boolean bchs[][]=new boolean[201][201];
		int count=0;
		for(char[] c:chs){
			Arrays.fill(c,'.');
			Arrays.fill(bchs[count++],false);
		}

		int lx=100;
		int ly=100;
		for(char c:path.toCharArray()){
			switch(c){
				case 'L':
					ly--;
					break;
				case 'R':
					ly++;
					break;
				case 'U':
					lx--;
					break;
				case 'D':
					lx++;
					break;
			}
			chs[lx][ly]='e';
		}//for

		LinkedList<Node> ll=new LinkedList<Node>();
		ll.add(new Node(100,100));
		bchs[100][100]=true;
		String ans=null;
		while(ll.size()>0){
			Node node=ll.remove();
			if(node.x==lx&&node.y==ly){
				ans=node.sb.toString();
				break;
			}
			for(int i=0;i<ori.length;i++){
				int nx=node.x+ori[i][0];
				int ny=node.y+ori[i][1];
				if(nx>=0&&nx<201&&ny>=0&&ny<201&&bchs[nx][ny]==false&&chs[nx][ny]=='e'){
					Node newNode=new Node(nx,ny);
					newNode.sb.append(node.sb.toString()+oris[i]);
					ll.add(newNode);
				}
			}//for
		}//while

		if(ans.equals(path))
			System.out.println("OK");
		else
			System.out.println("BUG");
	}//main
}//class

class Node{
	int x,y;
	StringBuffer sb=new StringBuffer();
	public 	Node(int x,int y){
		this.x=x;
		this.y=y;
	}
}


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

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

    static class D431 {
        int N;
        int K;
        int D;
        int MOD = 1_000_000_007;
        Long[][] memo;

        int dp(int num, int big) {
            if (num == 0) return big;
            if (num < 0) return 0;
            if (memo[num][big] != null) return memo[num][big];
            long tot = 0;
            for (int i = 1; i <= K; i++) {
                tot += dp(num - i, i >= D ? 1 : big);
            }
            return memo[num][big] = tot % MOD;
        }

        public void solve(int testNumber, FastScanner s, PrintWriter out) {
            N = s.nextInt();
            K = s.nextInt();
            D = s.nextInt();
            memo = new Long[N + 1][2];
            long ways = 0;
            for (int i = 1; i <= K; i++)
                ways += dp(N - i, i >= D ? 1 : 0);
            out.println(ways);
        }

    }

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

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

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

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

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

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

    }
}


package com.darkbit.problems;

import net.egork.io.InputReader;
import net.egork.io.OutputWriter;

public class D2RemoveTheSubstringHardVersion {
  public void solve(int testNumber, InputReader in, OutputWriter out) {

    String s = in.readString();
    String t = in.readString();
    int n = s.length();
    int m = t.length();
    int[] left = new int[t.length() + 5];
    int[] right = new int[t.length() + 5];

    int j = 0;
    for (int i = 0; j < t.length(); ++i)
      if (s.charAt(i) == t.charAt(j)) {
        left[j++] = i;
      }
    j = t.length() - 1;
    for (int i = s.length() - 1; j >= 0; --i)
      if (s.charAt(i) == t.charAt(j)) {
        right[j--] = i;
      }

    int ans = Math.max(right[0], n - left[m - 1] - 1);

    for (int i = 0; i + 1 < m; i++) ans = Math.max(ans, right[i + 1] - left[i] - 1);
    for (int i = 0; i + 1 < m; i++) ans = Math.max(ans, left[i + 1] - left[i] - 1);
    for (int i = 0; i + 1 < m; i++) ans = Math.max(ans, right[i + 1] - right[i] - 1);

    out.printLine(ans);
  }
}


/*
[ ( ^ _ ^ ) ]
*/

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

public class test {
    int INF = (int)1e9;
    long MOD = 1000000007;

    void solve(InputReader in, PrintWriter out) throws IOException {
        int a = in.nextInt();
        int b = in.nextInt();
        int k = in.nextInt();
        int[] p = new int[b+1];
        p[0] = 1; p[1] = 1;
        for(int i=2; i<=b; i++) {
            if(p[i]>0) continue;
            if(1l*i*i>b) continue;
            for(int j=i*i; j<=b; j+=i) {
                p[j] = 1;
            }
        }
        // show("p", p);
        int i = a, j = a;
        int t = p[i]^1;
        int m = b-a+1;
        int l = 1;
        // show("ij", i, j, t);
        while(i<=b-l+1) {
            while(t<k) {
                j++;
                if(j>b) break;
                t += p[j]^1;
                // show("chk", i, j, t);
            }
            if(t<k) {
                if(i==a) out.println(-1);
                else {
                    out.println(m-(i-a-1));`
                }
                return;
            }
            // show("ij", i, j, t);
            l = Math.max(l, j-i+1);
            t -= p[i]^1;
            i++;
        }
        out.println(l);
    }

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        while(t-- >0) {
            new test().solve(in, out);
        }
        out.close();
    }

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

    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;

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

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

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

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

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


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.Scanner;
/**
 *
 * @author SONY
 */
public class sticks {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s = new Scanner(System.in);
        int n = s. nextInt();
        int m = s.nextInt();
        int count=1;
        if(n==1||m==1)
            System.out.println("Akshat");
        else
            do
            {
                n--;
                m--;
                count++;
            }while(n!=1||m!=1);
        if(count%2==0)
        {
            System.out.print("Malvika");
        }
        else System.out.print("Akshat");;
    }
}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;

public class D {

  private static Map<Long, Long> cache;

  public static void main(String[] args) {
    Print print = new Print();
    Scan scan = new Scan();
    long n = scan.scanInt();

    long MOD = 998244353;
    cache = new HashMap<>();

    long[] data = new long[(int) n + 1];
    data[1] = 1;
    data[2] = 1;

    for (int i = 3; i < data.length; i++) {
      data[i] = (data[i - 1] % MOD + data[i - 2] % MOD) % MOD;
    }

    long nFib = data[(int) n];
    long two_n = MO.pow(2, n, MOD);

    long ans = MO.divide(nFib, two_n, MOD);
    print.printLine(Long.toString(ans));
    print.close();
  }

  private static long fib(long n, long mod) {
    if (n == 1 || n == 2) {
      return 1;
    }

    if (cache.get(n) != null) {
      return cache.get(n);
    }

    long x = (fib(n - 1, mod) + fib(n - 2, mod)) % mod;
    cache.put(n, x);
    return x;
  }

  static class MO {

    //MOD Operations

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

    static long multiply(long a, long b, long MOD) {
      return (a % MOD * b % MOD) % MOD;
    }

    static long subtract(long a, long b, long MOD) {
      return ((a % MOD - b % MOD) % MOD + MOD) % MOD;
    }

    static long inverse(long a, long MOD) {
      return pow(a, MOD - 2, MOD);
    }

    static long divide(long a, long b, long MOD) {
      return multiply(a, inverse(b, MOD), MOD);
    }

    static long pow(long a, long n, long MOD) {
      if (n == 0) {
        return 1;
      }
      long x = pow(a, n / 2, MOD);
      if (n % 2 == 1) {
        return multiply(multiply(x, x, MOD), a, MOD);
      } else {
        return multiply(x, x, MOD);
      }
    }

  }

  static class Scan {

    private byte[] buf = new byte[1024];
    private int index;
    private InputStream in;
    private int total;

    public Scan() {
      in = System.in;
    }

    public int scan() {
      if (total < 0) {
        throw new InputMismatchException();
      }
      if (index >= total) {
        index = 0;
        try {
          total = in.read(buf);
        } catch (IOException ignored) {
        }
        if (total <= 0) {
          return -1;
        }
      }
      return buf[index++];
    }

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

    public double scanDouble() {
      double doub = 0;
      int n = scan();
      while (isWhiteSpace(n)) {
        n = scan();
      }
      int neg = 1;
      if (n == '-') {
        neg = -1;
        n = scan();
      }
      while (!isWhiteSpace(n) && n != '.') {
        if (n >= '0' && n <= '9') {
          doub *= 10;
          doub += n - '0';
          n = scan();
        } else {
          throw new InputMismatchException();
        }
      }
      if (n == '.') {
        n = scan();
        double temp = 1;
        while (!isWhiteSpace(n)) {
          if (n >= '0' && n <= '9') {
            temp /= 10;
            doub += (n - '0') * temp;
            n = scan();
          } else {
            throw new InputMismatchException();
          }
        }
      }
      return doub * neg;
    }

    public String scanString() {
      StringBuilder sb = new StringBuilder();
      int n = scan();
      while (isWhiteSpace(n)) {
        n = scan();
      }
      while (!isWhiteSpace(n)) {
        sb.append((char) n);
        n = scan();
      }
      return sb.toString();
    }

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

  static class Print {

    private final BufferedWriter bw;

    public Print() {
      bw = new BufferedWriter(new OutputStreamWriter(System.out));
    }

    public void print(String str) {
      try {
        bw.append(str);
      } catch (IOException ignored) {
      }
    }

    public void printLine(String str) {
      print(str);
      try {
        bw.append("\n");
      } catch (IOException ignored) {
      }
    }

    public void close() {
      try {
        bw.close();
      } catch (IOException ignored) {
      }
    }
  }

}


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

// printArr() - prints the array
// intList, doubleList, longList
// nextIntArray

/* stuff you should look for
 * int overflow, array bounds
 * special cases (n=1?)
 * do smth instead of nothing and stay organized
 * WRITE STUFF DOWN
 */

public class current {
    public static void main(String[] args) {
        FastReader fr = new FastReader();
        solve(fr.nextLine().split("e"));
    }

    public static void solve(String[] input) {
        int pow = toInt(input[1]);
        int l = input[0].length();
        char[] arr = input[0].toCharArray();
        List<Character> list = new ArrayList<>();
        for (char i : arr) {
            list.add(i);
        }
        int index = input[0].indexOf(".");
        list.remove(index);
        int newindex = index+pow;
        if (newindex < l-1) {
            list.add(index + pow, '.');
        } else {
            // skip if equal to l-1
            if (newindex > l-1) {
                for (int i = l-1; i < newindex; i++) {
                    list.add('0');
                }
            }
        }
        for (char i : list) {
            System.out.print(i);
        }
        System.out.println();
    }

    public static Set<Integer> get(List<Set<Integer>> graph, int i) {
        try {
            return graph.get(i);
        } catch (IndexOutOfBoundsException e) {
            return new HashSet<>();
        }
    }

    public static void printArr(int[] a) {
        System.out.println(Arrays.toString(a));
    }

    public static int[] bfs(List<Set<Integer>> graph, int v) {
        int l = graph.size();
        Deque<Integer> list = new ArrayDeque<>();
        list.add(v);
        boolean[] seen = new boolean[l];
        int distance = 0;
        int node = v;
        int size = 1;
        int index = 0;
        // Iterate over every single vertice and edge
        // O(V+E) -> O(V) for trees
        while (!list.isEmpty()) {
            int cur = list.poll();
            seen[cur] = true;
            node = cur;

            index++;
            if (index > size) {
                distance++;
                size = list.size();
                index = 0;
            }

            for (int i : graph.get(cur)) {
                if (!seen[i]) {
                    seen[i] = true;
                    list.add(i);
                }
            }
        }
        return new int[]{node, distance};
    }

    static class SegTree {
        int startIndex, endIndex;
        long sum;
        SegTree lchild, rchild;

        SegTree(int[] arr) {this(0, arr.length-1, arr);}

        SegTree(int startIndex, int endIndex, int[] arr) {
            this.startIndex = startIndex;
            this.endIndex = endIndex;
            if (startIndex == endIndex) sum = arr[startIndex];
            else {
                int mid = (startIndex + endIndex) / 2;
                lchild = new SegTree(startIndex, mid, arr);
                rchild = new SegTree(mid + 1, endIndex, arr);
                sum = lchild.sum + rchild.sum;
                recalc();
            }
        }

        void recalc() {
            if (startIndex == endIndex) return; sum = lchild.sum + rchild.sum;
        }

        public void valueUpdate(int index, int value) {
            if (startIndex == endIndex) {sum = value; return;}
            if (index > lchild.endIndex) rchild.valueUpdate(index, value); else lchild.valueUpdate(index, value); recalc();
        }

        public long rangeSum(int startIndex, int endIndex) {
            if (endIndex < this.startIndex || startIndex > this.endIndex) return 0;
            if (startIndex <= this.startIndex && endIndex >= this.endIndex) return sum;
            return lchild.rangeSum(startIndex, endIndex) + rchild.rangeSum(startIndex, endIndex);
        }
    }

    public static double sum(List<Long> n) {
        double a = 0;
        for (long i : n) {
            a += i;
        }
        return a;
    }

    public static int toInt(String n) {
        return Integer.parseInt(n);
    }

    public static double toDouble(String n) {
        return Double.parseDouble(n);
    }

    public static long toLong(String n) {
        return Long.parseLong(n);
    }

    static class FastReader {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

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

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

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

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

        int[] nextIntArray() {
            return intArray(nextLine().split(" "));
        }

        long[] nextLongArray() {
            return longArray(nextLine().split(" "));
        }

        double[] nextDoubleArray() {
            return doubleArray(nextLine().split(" "));
        }

        public int getInt(int index) {
            String[] arr = nextLine().split(" ");
            return Integer.parseInt(arr[index]);
        }

        public long getLong(int index) {
            String[] arr = nextLine().split(" ");
            return Long.parseLong(arr[index]);
        }

        public double getDouble(int index) {
            String[] arr = nextLine().split(" ");
            return Double.parseDouble(arr[index]);
        }

        public List<String> stringList() {
            String[] arr = nextLine().split(" ");
            return Arrays.asList(arr);
        }

        public List<Integer> intList() {
            String[] arr = nextLine().split(" ");
            List<Integer> a = new ArrayList<>();
            for (String i : arr) {
                a.add(Integer.parseInt(i));
            }
            return a;
        }

        public List<Double> doubleList() {
            String[] arr = nextLine().split(" ");
            List<Double> a = new ArrayList<>();
            for (String i : arr) {
                a.add(Double.parseDouble(i));
            }
            return a;
        }

        public List<Long> longList() {
            String[] arr = nextLine().split(" ");
            List<Long> a = new ArrayList<>();
            for (String i : arr) {
                a.add(Long.parseLong(i));
            }
            return a;
        }
    }

    public static int[] intArray(String[] arr) {
        int l = arr.length;
        int[] a = new int[l];
        for (int i = 0; i < l; i++) {
            a[i] = Integer.parseInt(arr[i]);
        }
        return a;
    }

    public static long[] longArray(String[] arr) {
        int l = arr.length;
        long[] a = new long[l];
        for (int i = 0; i < l; i++) {
            a[i] = Long.parseLong(arr[i]);
        }
        return a;
    }

    public static double[] doubleArray(String[] arr) {
        int l = arr.length;
        double[] a = new double[l];
        for (int i = 0; i < l; i++) {
            a[i] = Double.parseDouble(arr[i]);
        }
        return a;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by nadya on 28/10/17.
 */
public class Educational {
    public static void main(String[] args) throws IOException {
        Educational c = new Educational();
        c.start();
    }

    private void start() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer str = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(str.nextToken());
        String s = in.readLine();
        int b[] = new int[n];
        TreeMap<Integer, Set<Integer>> w = new TreeMap<Integer, Set<Integer>>();

        str = new StringTokenizer(in.readLine());
        for (int i = 0; i < n; ++i) {
            b[i] = Integer.parseInt(str.nextToken());
        }
        char[] res = s.toCharArray();

        ArrayList<Integer> waitingList = new ArrayList<Integer>();
        for (int i = 0; i < n / 2; ++i) {
            if (res[i] == res[getvisavis(n, i)]) {
                if (waitingList.isEmpty()) {
                    waitingList.add(i);
                } else {
                    for (Integer j : waitingList) {
                        if (res[j] != res[i]) {
                            int minB1 = b[j] < b[getvisavis(n, j)] ? j : getvisavis(n, j);
                            int minB2 = b[i] < b[getvisavis(n, i)] ? i : getvisavis(n, i);
                            swap(res, minB1, minB2);
                            b[minB1] = 0;
                            b[minB2] = 0;
                            waitingList.remove(j);
                            break;
                        }
                    }
                    waitingList.add(i);
                }
            }
        }

        for (int i = 0; i < n; ++i) {
            // if (b[i] == 0) continue;
            if (!w.containsKey(b[i])) w.put(b[i], new HashSet<Integer>());
            w.get(b[i]).add(i);
        }

        for (int i = 0; i < n / 2; ++i) {
            if (res[i] == res[getvisavis(n, i)]) {

                boolean finished = false;

                int indexToChange = b[i] < b[getvisavis(n, i)] ? i : getvisavis(n, i);

                for (Map.Entry<Integer, Set<Integer>> l : w.entrySet()) {
                    Set<Integer> candidates = l.getValue();
                    for (Integer j : candidates) {
                        if (j == i || j == indexToChange || res[indexToChange] == res[j] || res[indexToChange] == res[getvisavis(n, j)]) {
                            continue;
                        }

                        swap(res, indexToChange, j);

                        b[j] = 0;
                        b[indexToChange] = 0;

                        w.get(0).add(j);
                        w.get(0).add(indexToChange);

                        w.get(b[indexToChange]).remove(indexToChange);
                        w.get(b[j]).remove(j);

                        finished = true;
                        break;
                    }

                    if (finished) break;
                }
                if (res[i] == res[getvisavis(n, i)]) System.out.println("alarma");
            }
        }
        for (int i = 0; i < n / 2; ++i) {
            if (res[i] == res[getvisavis(n, i)]) {
                System.out.println("FFFF");
            }
        }

        int sum = 0;
        for (int i = 0; i < n; ++i) {
            //if (!changed[i]) {
            sum += b[i];
            // }
        }

        System.out.println(sum);
    }

    public static int getvisavis(int n, int i) {
        return n - i - 1;
    }

    public static void swap(char[] a, int i, int j) {
        char t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
}


package f884;

import java.util.*;

import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toMap;

public class Main {
    static int n;
    static char[] chars;
    static int[] vals;

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

        n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine().trim();
        chars = s.toCharArray();

        vals = new int[n];
        for (int i = 0; i < n; i ++) {
            vals[i] = sc.nextInt();
        }
        sc.nextLine();

        List<Char> wrongChars = new ArrayList<>();
        List<Char> chars1 = new ArrayList<>();
        for (int i = 0; i < n / 2; i++) {
            boolean wrong = false;
            if (chars[i] == chars[n - i - 1]) {
                if (vals[i] > vals[n - i - 1]) {
                    swap(i);
                }
                wrong = true;
            }

            Char chr = new Char(chars[i], vals[i], i);
            if (wrong) wrongChars.add(chr);
            chars1.add(chr);
        }
        chars1.sort(Comparator.comparing(c -> c.val));

        int diff = 0;
//        int[] vals1 = Arrays.copyOf(vals, n/2);
        if (!isAntiPalindrome(chars)) {
            if (wrongChars.size() == 1) {
                Char wrongChar = wrongChars.get(0);
                for (int i = 0; i < n/2; i++) {
                    Char chr = chars1.get(i);
                    if (chr.chr != wrongChar.chr && chars[n - chr.idx - 1] != wrongChar.chr) {
                        diff = wrongChar.val + chr.val;
                        break;
                    }
                }
            } else if (wrongChars.size() > 1) {
                Map<Character, Integer> map = wrongChars.stream().collect(toMap(n -> n.chr, n -> 1, (a, b) -> a+1, TreeMap::new));
                Map.Entry<Character, Integer> max = map.entrySet().stream().max(Comparator.comparing(Map.Entry::getValue)).get();
                List<Char> append = new ArrayList<>();
                while (max.getValue() * 2 > wrongChars.size() + append.size()) {
                    Character maxChar = max.getKey();
                    for (int i = 0; i < n/2; i++) {
                        Char chr = chars1.get(i);
                        if (chr.chr != maxChar && chars[n - chr.idx - 1] != maxChar && !wrongChars.contains(chr)) {
                            append.add(chr);
                            break;
                        }
                    }
                }
                diff = wrongChars.stream().mapToInt(chr -> chr.val).sum() + append.stream().mapToInt(chr -> chr.val).sum();
            }
        }

        int sum = stream(vals).sum();
        System.out.println(sum - diff);
    }

    private static void swap(int i) {
        char tmp = chars[i];
        chars[i] = chars[n - i - 1];
        chars[n - i - 1] = tmp;

        int tmpVal = vals[i];
        vals[i] = vals[n - i - 1];
        vals[n - i - 1] = tmpVal;
    }

    private static void swap(int i, int j) {
        char tmp = chars[i];
        chars[i] = chars[j];
        chars[j] = tmp;

        int tmpVal = vals[i];
        vals[i] = vals[n - i - 1];
        vals[n - i - 1] = tmpVal;
    }

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

    static class Char {
        char chr;
        int val;
        int idx;

        Char(char chr, int val, int idx) {
            this.chr = chr;
            this.val = val;
            this.idx = idx;
        }

        @Override
        public String toString() {
            return "Char{" +
                    "chr=" + chr +
                    ", val=" + val +
                    ", idx=" + idx +
                    '}';
        }
    }
}


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
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int l1 = in.nextInt();
        int r1 = in.nextInt();
        int l2 = in.nextInt();
        int r2 = in.nextInt();
        int len = 1;
        for (int step = 0; step < 30; ++step) {
            len = len * 2 + 1;
        }
        long res = rec(l1, r1, l2, r2, len);
        out.println(res);
    }

    private long rec(int l1, int r1, int l2, int r2, int len) {
        if (len == 0) {
            return 0;
        }
        if (l1 > r1 || l2 > r2) return 0;
        int center = (len / 2) + 1;
        if (r1 < center && r2 < center) {
            return rec(l1, r1, l2, r2, len / 2);
        }
        if (l1 > center && l2 > center) {
            return rec(len - r1 + 1, len - l1 + 1, len - r2 + 1, len - l2 + 1, len / 2);
        }
        if (r1 < center && l2 > center) {
            return rec(l1, r1, len - r2 + 1, len - l2 + 1, len / 2);
        }
        if (r2 < center && l1 > center) {
            return rec(l2, r2, l1, r1, len);
        }
        if (l1 <= center && r1 >= center) {
            if (l2 <= center && r2 >= center) {
                long max = rec(l1, center-1, l2, r2, len);
                max = Math.max(max, rec(center + 1, r1, l2, r2, len));
                int le = Math.max(l1, l2);
                int ri = Math.min(r1, r2);
                if (le <= ri) {
                    max = Math.max(max, ri - le + 1);
                }
                l1 = len - l1 + 1;
                r1 = len - r1 + 1;
                le = Math.max(l1, l2);
                ri = Math.min(r1, r2);
                if (le <= ri) {
                    max = Math.max(max, ri - le + 1);
                }
                return max;
            } else {
                long max = rec(l1, center-1, l2, r2, len);
                max = Math.max(max, rec(center + 1, r1, l2, r2, len));
                return max;
            }
        }
        if (l2 <= center && r2 >= center) {
            return rec(l2, r2, l1, r1, len);
        }
        return 0;
    }

}

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 nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

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

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class C {
    static int rec(int idx, int[] a, int[] b) {
        final int len = (1 << idx) - 1;
        final int mid = len / 2;
        if(a[0] >= a[1] || b[0] >= b[1])
            return 0;

//      System.err.println(a[0] + " " + a[1] + " " + b[0] + " " + b[1]);

        if(a[0] > b[0]) {
            final int[] c = a; a = b; b = c;
        }

        if(a[0] <= b[0] && b[1] <= a[1]) {
            return b[1] - b[0];
        }

        int res = 0;
        res = Math.max(Math.min(a[1], b[1]) - Math.max(a[0], b[0]), res);

        int[][][] rng = new int[2][2][2];
        rng[0][0][0] = a[0];
        rng[0][0][1] = Math.min(a[1], mid);

        rng[0][1][0] = Math.max(a[0] - 1, mid) - mid;
        rng[0][1][1] = a[1] - mid - 1;

        rng[1][0][0] = b[0];
        rng[1][0][1] = Math.min(b[1], mid);

        rng[1][1][0] = Math.max(b[0] - 1, mid) - mid;
        rng[1][1][1] = b[1] - mid - 1;

        for(int i = 0; i < 2; i++)
            for(int j = 0; j < 2; j++)
                res = Math.max(res, rec(idx - 1, rng[0][i], rng[1][j]));

        return res;
    }

    public static void main(String[] args) throws IOException {
        final int l1 = IOFast.nextInt();
        final int r1 = IOFast.nextInt();
        final int l2 = IOFast.nextInt();
        final int r2 = IOFast.nextInt();
        IOFast.out.println(rec(30, new int[] { l1 - 1, r1 }, new int[] { l2 - 1, r2 }));

        IOFast.out.flush();
    }

    static public class IOFast {
        private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        private static PrintWriter out = new PrintWriter(System.out);

//      private static final int BUFFER_SIZE = 50 * 200000;
        private static final StringBuilder buf = new StringBuilder();
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];

        static {
            for(int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
        }

        static boolean endInput;

        private static int nextInt() throws IOException {
            boolean plus = false;
            int ret = 0;
            while(true) {
                final int c = in.read();

                if(c == -1) {
                    endInput = true;
                    return Integer.MIN_VALUE;
                }

                if(isDigit[c]) {
                    if(c != '-') {
                        plus = true;
                        ret = c - '0';
                    }
                    break;
                }
            }

            while(true) {
                final int c = in.read();
                if(c == -1 || !isDigit[c]) {
                    break;
                }
                ret = ret * 10 + c - '0';
            }

            return plus ? ret : -ret;
        }

        private static long nextLong() throws IOException {
            boolean plus = false;
            long ret = 0;
            while(true) {
                final int c = in.read();

                if(c == -1) {
                    endInput = true;
                    return Integer.MIN_VALUE;
                }

                if(isDigit[c]) {
                    if(c != '-') {
                        plus = true;
                        ret = c - '0';
                    }
                    break;
                }
            }

            while(true) {
                final int c = in.read();
                if(c == -1 || !isDigit[c]) {
                    break;
                }
                ret = ret * 10 + c - '0';
            }

            return plus ? ret : -ret;
        }

        private static String next() throws IOException {
            buf.setLength(0);

            while(true) {
                final int c = in.read();

                if(c == -1) {
                    endInput = true;
                    return "-1";
                }

                if(!isSpace[c]) {
                    buf.append((char)c);
                    break;
                }
            }

            while(true) {
                final int c = in.read();

                if(c == -1 || isSpace[c]) {
                    break;
                }
                buf.append((char)c);
            }

            return buf.toString();
        }

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

    }

}


import java.util.Scanner;

public class B_Divisor_Subtraction_1076 {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long n = input.nextLong();
		long count =0;
		if(n%2==0) {

			System.out.println(n/2);
			return;
		}
		long[] a = new long[(int)n];
		int k=0;
		a[k]=3;
		k=k+1;
		for (int i = 5; i <= n; i=i+2) {
			int flag=0;
			for (int j = 0; j < k; j++) {
				if(i%a[j]==0) {
					flag=0;
					break;
				}
				flag=1;

			}
			if(flag==1) {
				a[k]=i;
				k=k+1;
			}

		}
		while(n!=0) {
			int i;
			for ( i = 0; i < k; i++) {
				if(n%a[i]==0) {
					break;
				}
			}

			n=n-a[i];
			count++;
		}
		System.out.println(count);

	}
}


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

  Scanner sc=new Scanner(System.in);
  PrintWriter pr=new PrintWriter(System.out,true);
  public static void main(String... args)
  {
       test c=new test();
       c.prop();
  }
  public void prop()
  {
    String s=sc.next() ;
    int n=s.length(),count=0,count2=0;
      for (int i=0;i<n ;++i) {
          char c=s.charAt(i) ;
            if(c=='a'||c=='e' || c=='i' || c=='o' || c=='u')
                 ++count ;
             else if( c=='0' ||  c=='2'|| c=='4'|| c=='6'|| c=='8')
                      ++count2 ;
      }
      if(count>=count2)
       pr.println(2*count2);
       else
        pr.println(2*count1);
  }

}


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

public class Main {

    Scanner in;

    public void run() {
        in = new Scanner(System.in);
        ArrayList<String> list = new ArrayList<String>();
        list.add("");
        list.add("C");
        list.add("C#");
        list.add("D");
        list.add("D#");
        list.add("E");
        list.add("F");
        list.add("F#");
        list.add("G");
        list.add("G#");
        list.add("A");
        list.add("B");
        list.add("H");
        String X = in.next();
        String Y = in.next();
        String Z = in.next();

        int x = list.indexOf(X);
        int y = list.indexOf(Y);
        int z = list.indexOf(Z);
        if (X.compareTo(Y) == 1) {
            int temp = x;
            x = y;
            y = temp;
            String f = X;
            X = Y;
            Y = f;
        }
        if (Y.compareTo(Z) == 1) {
            int temp = y;
            y = z;
            z = temp;
            String f = Y;
            Y = Z;
            Z = f;
        }
        if (X.compareTo(Z) == 1) {
            int temp = x;
            x = z;
            z = temp;
            String f = X;
            X = Z;
            Z = f;
        }
        int t, p;
        if (x < y) {
            t = y - x;
        } else {
            t = (12 + y) - x;
        }
        if (y < z) {
            p = z - y;
        } else {
            p = (12 + z) - y;
        }
        if (t == 4 && p == 3) {
            System.out.println("major");
        } else if (p == 4 && t == 3) {
            System.out.println("minor");
        } else {
            System.out.println("strange");
        }

    }

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


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

public class Main {

    public static PrintWriter out;

    public static void main(String args[]) {

        MyScanner in = new MyScanner();
        int n = in.nextInt();
        int l = in.nextInt();
        int r = in.nextInt();
        int x = in.nextInt();

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

        if (n == 1)
            System.out.println("0");
        else {

            int i = 0, j = 1;
            long count = 0;
            while (i < n && j < n) {
                if (numbers.get(j) - numbers.get(i) < x) {
                    j++;
                    if (j >= n) {
                        break;
                    }
                } else {
                    if (numbers.get(i) + numbers.get(j) > r) {
                        i++;
                        j = i + 1;
                    } else if (numbers.get(i) + numbers.get(j) == r) {
                        count++;
                        i++;
                        j = i + 1;
                    } else {
                        //System.out.println("i j " + i + " " + j + "before= " + count);
                        count += getSubset(i, j, n, numbers, l, r, x);
                        //System.out.println("i j " + i + " " + j + "after= " + count);

                        i++;
                        j = i + 1;
                    }
                }
                if (j >= n) {
                    i++;
                }

            }

            System.out.println(count);
        }
    }

    private static long getSubset(int i, int j, int n, List<Integer> numbers, int l, int r, int min) {

        if (j >= n)
            return 0;
        long count = 0;

        for (int x = j; x < n; x++) {
            //System.out.println("i j " + i + " " + x + "before_2= " + count + "  " + numbers.get(i) + numbers.get(x));
            if (numbers.get(i) + numbers.get(x) >= l && numbers.get(x) - numbers.get(i) >= min) {
                //System.out.println("ok");
                count++;
            }
            count += getCount(i, x, n, numbers, l, r, numbers.get(i) + numbers.get(x));
            //System.out.println("i j " + i + " " + x + "after_2= " + count);

        }

        return count;
    }

    private static long getCount(int i, int j, int n, List<Integer> numbers, int l, int r, long sum) {

        if (j < i)
            return 0;
        long count = 0;
        for (int z = 0; z < j - i - 1; z++) {
            long localSum = 0;
            // System.out.println("sum " + sum);
            count += getCount(i + 1, j, n, numbers, l, r, localSum + sum);
            localSum += numbers.get(i + z + 1);
            // System.out.println("localsum " + localSum);
            // System.out.println("count " + count);

            if (localSum + sum <= r) {
                count += 1 + getCount(i + 1, j, n, numbers, l, r, localSum + sum);
            }
            // System.out.println("count " + count);

        }

        return count;

    }

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

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

    }

}


import  java.util.*;
import java.lang.*;
public class Cat {
    public static void main(String[] args) {
    try{
        Scanner sc =new Scanner(System.in);
        long a,b,c,p,q,r;
        p= sc.nextLong();
        q=sc.nextLong();
        r=sc.nextLong();
        // String a[]={"mo","tu","we","th","fr","sa","su"};
        long max=0;
        int i=0;
        long ans=0;

        for(int j=0;j<7;j++)
        {
            // System.out.println("j ="+j);
            i=j;
            max=0;
            a=p;
            b=q;
            c=r;
            while(true)
            {
                if(a==-1 || b==-1 || c==-1)
                    break;
                if(a==0 &&(i==0 || i==3 || i==6 ))
                    break;
                if(b==0 && (i==1 || i==5))
                    break;
                if(c==0 && (i==2 || i==4 ))
                    break;
                //   System.out.println("i="+i);
                // System.out.println(a);
                //System.out.println(b);
                //System.out.println(c);
                if(i==0 || i==3 || i==6)
                {
                    a--;
                    max++;
                }
                else  if(i==1 || i==5)
                {
                    b--;
                    max++;
                }
                else if(i==2 || i==4 )
                {
                    c--;
                    max++;
                }
                i++;
                if(i==7)
                    i=0;
            }
            //  System.out.println("for j="+j+" max is "+max);
            if(max>ans)
                ans=max;
        }
        System.out.println(ans);

    }catch(Exception e){}

    }
}


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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();
            HashSet<Point> points = new HashSet<>();
            for (long x = -n; x <= n; x++) {
                double y = Math.sqrt(n * n - x * x);
                points.add(new Point((int) x, (int) Math.floor(y)));
                points.add(new Point((int) x, -((int) Math.floor(y))));
            }
            for (long y = -n; y <= n; y++) {
                double x = Math.sqrt(n * n - y * y);
                points.add(new Point((int) Math.floor(x), (int) y));
                points.add(new Point(-((int) Math.floor(x)), (int) y));
            }
            out.println(points.size());
        }

    }

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

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

        private void fillTokenizer() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }

        public String next() {
            fillTokenizer();
            return tokenizer.nextToken();
        }

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

    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication39;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Scanner;

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

     int n=0;
     int c_local=0;
     int c_visita=0;
     int total=0;
     ArrayList<Integer> l_local=new ArrayList();
     ArrayList<Integer> l_visita=new ArrayList();
     Scanner sc = new Scanner(System.in);
     n=sc.nextInt();
     for(int i =0 ;  i<n;i++){
     l_local.add(sc.nextInt());
     l_visita.add(sc.nextInt());

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

            if(l_local.get(k).equals(l_visita.get(j)) && k!=j){

                total=total+1;

            }

           }

     }
     System.out.println(" el numero de la cantidad de veces que un local se pondra la camiseta de visita es "+total);

    }

}


import java.util.Scanner;

public class K {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String s1=sc.nextLine();
        char[] ch2=s1.toCharArray();
        char[] ch = s.toCharArray();
        int count=0;
        char[] ch1 = new char[s.length()];
        for (int i = 0; i < ch.length; i++) {
            ch1[i] = ch[s.length()-1 - i];
        }
        for (int i = 0; i < ch.length; i++) {
            if (ch1[i]==ch2[i]){
                count++;
            }
        }
        if (count==ch.length){
            System.out.println("YES");
        } else{
            System.out.println("NO");
        }
    }
}