import java.io.InputStream;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        long x,y,a,b;
            InputStream inputStream = System.in;
//            OutputStream outputStream = System.out;
            Scanner in = new Scanner(inputStream);
//            PrintWriter out = new PrintWriter(outputStream);

            x=in.nextInt();
            y=in.nextInt();
            a=in.nextInt();
            b=in.nextInt();
            long count=0;
            long x_,y_,xx;
            long xmin,xmax;
            x_=Math.max(x, y);
            xx=1;
            y_=Math.min(x, y);
            for (int i = 2; i <= y_; i++) {
                if ((x_%i==0)&&(y_%0==0))xx=i;
        }
            if (xx==1)xx=x*y;
            count=(b-a+1)/xx;
            if (a%x_==0)count++;
//            if (x_%y_==0){count=b/x_-a/x_;
//                if (a%x_==0)count++;}
//            else{
//                xmin=a/x_;
//                if(a%x_>0)xmin++;
//                xmax=b/x_;
//                for(long i=xmin;(x_*i)<=b;i++){
//                    if (((i*x_)%y_==0))count++;
//                }}

            System.out.println(count);

    }

}


package hjgh;

/**
 * Created with IntelliJ IDEA.
 * User: ALEXXX
 * Date: 12.09.13
 * Time: 22:11
 * To change this template use File | Settings | File Templates.
 */

import java.util.Scanner;

public class Code198A {

    public static int NOK(int x, int n) {
        int j;
        if (x < n) j = n;
        else j = x;
        boolean t = true;
        while (t) {
            if ((j % x == 0) && (j % n == 0)) break;
            else j += 1;
        }
        return (j);
    }

    public static void main(String[] args) {
        int a, b, t;
        Scanner sc = new Scanner(System.in);

        a = Integer.parseInt(args[0]);
        b = Integer.parseInt(args[1]);
        int l = Integer.parseInt(args[2]);
        int r = Integer.parseInt(args[3]);
//        a = sc.nextInt();
//        b = sc.nextInt();
        if (a < b) {
            t = b;
            b = a;
            a = t;
        }
        t = NOK(a, b);

        int i=l;
        boolean flag=true;
        while ((flag)&&(i<=r)) {
            if (i%t==0) {
            flag=false;
            break;
            }
                i++;
        }
        int p=0;
        if (flag==false){
            p++;
        }
        p=p+((r-i)/t);
        System.out.println(p);

    }
}


package codeforce;

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

public class theWall {

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

		Scanner in=new Scanner(System.in);
		int x=in.nextInt();
		int y=in.nextInt();
		int a=in.nextInt();
		int b=in.nextInt();
		int aa=a;
		ArrayList<Integer>list=new ArrayList<Integer>();
		list.add(a);
		int count=0;
		while(a<=b){
			 a+=x;
		//	 System.out.print(a+" ");
			list.add(a);
		}
		System.out.println();
		while(aa<=b){
			if(list.contains(aa)){
			//	 System.out.print("YES"+" ");
			 count++;
		//	 System.out.println(count+"  "+list.indexOf(aa));
			 }
			aa+=y;
		//	 System.out.print(aa+" ");

		}
		System.out.print(count);
	}

}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

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

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new FileReader("input.txt"));
		out = new PrintWriter("output.txt");
		solve();
		in.close();
		out.close();
	}

	int x, y, a, b;
	int gcd (int a, int b) {
		if (b == 0)
			return a;
		else
			return gcd (b, a % b);
	}
	int mysolve(){
		int ans = 0;
		int aabb = gcd(y,x);
//		System.err.println(aabb);
		int l = x / aabb;
		int k = y / aabb;
//		System.err.println(l + " " + k);
		int n = (int)((long)a / (long)(k * x));
		if( (n * k * x) < a )
			n++;
		int m = (int)((long)b / (long)(k * x));
		ans = m - n + 1;
		return ans;
	}

	private void solve() throws IOException {
		x = nextInt();
		y = nextInt();
		a = nextInt();
		b = nextInt();
		int ans = mysolve();
		out.println(ans);
	}

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}
	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}


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

public class C {
	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;
	String SK;

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

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

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

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

	void solve() throws IOException {
		long c[][] = new long[31][31];
		for (int i = 0; i <= 30; i++)
			c[i][0] = 1;
		for (int i = 1; i <= 30; i++)
			for (int j = 1; j <= 30; j++) {
				c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
			}
		long res = 0;
		int n = nextInt();
		int m = nextInt();
		int t = nextInt();
		for (int i = 4; i < t; i++)
			res = res + c[n][i] * c[m][t - i];
		out.println(res);

	};

	void run() throws IOException {

		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

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

}


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

public class C {

	public C () throws IOException {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int t = sc.nextInt();
		solve(n,m,t);
	}

	public void solve (int n, int m, int t) {
		BigInteger [][] C = new BigInteger [31][31];
		for (int i = 0; i <= 30; ++i)
			C[i][0] = C[i][i] = BigInteger.ONE;

		for (int i = 1; i <= 30; ++i)
			for (int j = 1; j < i; ++j)
				C[i][j] = C[i-1][j-1].add(C[i-1][j]);

		BigInteger S = BigInteger.ZERO;
		for (int b = 4; b < t; ++ b)
			S = S.add(C[n][b].multiply(C[m][t-b]));

		print(S);
	}

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

	static Scanner sc;

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

	static void run () throws IOException {
		sc = new Scanner(System.in);
		new C();
	}

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


import java.util.Scanner;

public class C {

	/**
	 * @param args
	 */
	static void combiation(int n,int m)
	{
		com = new long[n+1][m+1];
		for(int i=0;i<m;i++)
			com[i][0] = 1;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				com[i][j] = com[i-1][j] + com[i-1][j-1];
	}
	static long[][] com;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		combiation(50,50);
		Scanner scan = new Scanner(System.in);
		int n  = scan.nextInt();
		int m  = scan.nextInt();
		int t  = scan.nextInt();
		long c = 0;
		for(int i = 4 ; i  <= n ; i ++)
		{
			int mm = t-i;
			if(mm > 0){
				c += com[n][i]*com[m][mm];
			}
		}
		System.out.println(c);
	}
}


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

public class Main
{
    public static BigInteger fact(BigInteger n)
    {
        if(n.equals(BigInteger.ZERO))
            return BigInteger.ONE;
        else
            return n.multiply(fact(n.subtract(BigInteger.ONE)));
    }
    public static BigInteger C(BigInteger n,BigInteger r)
    {
        return (fact(n).divide((fact(r).multiply(fact(n.subtract(r))))));
    }
    public static void main(String args[]) throws IOException
    {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        StringTokenizer st=new StringTokenizer(in.readLine());
        BigInteger n=new BigInteger(st.nextToken());
        BigInteger m=new BigInteger(st.nextToken());
        BigInteger t=new BigInteger(st.nextToken());
        BigInteger comb=BigInteger.ZERO;
        for(BigInteger b=new BigInteger("4");t.subtract(b).compareTo(BigInteger.ONE)>=0 && b.compareTo(n)<=0;b=b.add(BigInteger.ONE))
        {
            BigInteger g=t.subtract(b);
            comb=comb.add(C(n,b).multiply(C(m,g)));
        }
        out.println(comb);
        out.flush();
    }
}


import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class cf1 {
    static long mod = (long)1e9 + 7;
    static long mod1 = 998244353;
    static FastScanner f;
    static PrintWriter pw = new PrintWriter(System.out);
    static Scanner S = new Scanner(System.in);
    static long x0; static long y0;
    static int inf = (int)(1e9) + 5;
    static long iinf = (long)(1e18) + 5l;
    static double eps = (double)1e-4;
    public static void solve()throws IOException {
        int n = f.ni();
        boolean sieve[] = new boolean[(int)1e6];
        Arrays.fill(sieve , true);
        sieve[0] = false;
        sieve[1] = false;
        for (int i = 2; i < sieve.length; ++i) {
            if (sieve[i]) {
                for (int j = i + i; j < sieve.length; j += i) {
                    sieve[j] = false;
                }
            }
        }

        int sum = (n * (n + 1)) / 2;

        int ans[] = new int[n + 1];
        Arrays.fill(ans , 1);

        if (sieve[sum]) {
            // All in same grp
            for (int i = 1; i <= n; ++i) p(ans[i] + " ");
        }

        else {
            // Goldbach Conjecture

            if (ise(sum)) {
                for (int i = 2; i <= n; ++i) {
                    if (sieve[i] && sieve[sum - i]) {
                        ans[i] = 2;
                        break;
                    }
                }
            }

            else {

                if (sieve[sum - 2]) ans[2] = 2;
                else {
                    ans[3] = 3;
                    for (int i = 2; i <= n; ++i) {
                        if (sieve[i] && sieve[sum - i - 3]) {
                            ans[i] = 2;
                            break;
                        }
                    }
                }
            }

            for (int i = 1; i <= n; ++i) {
                p(ans[i] + " ");
            }
            pn("");
        }
    }
    public static void main(String[] args)throws NumberFormatException , IOException {
        init();
        boolean tc = false;
        int t = tc ? f.ni() : 1;
        while(t --> 0) solve();
        pw.flush();
        pw.close();
    }

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


import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class cf1 {
    static long mod = (long)1e9 + 7;
    static long mod1 = 998244353;
    static FastScanner f;
    static PrintWriter pw = new PrintWriter(System.out);
    static Scanner S = new Scanner(System.in);
    static long x0; static long y0;
    static int inf = (int)(1e9) + 5;
    static long iinf = (long)(1e18) + 5l;
    static double eps = (double)1e-4;
    public static void solve()throws IOException {
        int n = f.ni();
        boolean sieve[] = new boolean[6005];
        Arrays.fill(sieve , true);
        sieve[0] = false;
        sieve[1] = false;
        for (int i = 2; i <= 6004; ++i) {
            if (sieve[i]) {
                for (int j = i * i; j <= 6004; j += i) {
                    sieve[j] = false;
                }
            }
        }

        int sum = (n * (n + 1)) / 2;

        int ans[] = new int[n + 1];
        Arrays.fill(ans , 1);

        if (sieve[sum]) {
            // All in same grp
            for (int i = 1; i <= n; ++i) p(ans[i] + " ");
        }

        else {
            // Goldbach Conjecture

            if (ise(sum)) {
                for (int i = 2; i <= n; ++i) {
                    if (sieve[i] && sieve[sum - i]) {
                        ans[i] = 2;
                        break;
                    }
                }
            }

            else {

                if (sieve[sum - 2]) ans[2] = 2;
                else {
                    ans[3] = 3;
                    for (int i = 2; i <= n; ++i) {
                        if (sieve[i] && sieve[sum - i - 3]) {
                            ans[i] = 2;
                            break;
                        }
                    }
                }
            }

            for (int i = 1; i <= n; ++i) {
                p(ans[i] + " ");
            }
            pn("");
        }
    }
    public static void main(String[] args)throws NumberFormatException , IOException {
        init();
        boolean tc = false;
        int t = tc ? f.ni() : 1;
        while(t --> 0) solve();
        pw.flush();
        pw.close();
    }

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


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

public class PrimeProblem {

	private void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int sum = n*(n+1)/2;
		int[] primes = getPrimes(1000000);
		int[] colors = new int[n];
		if (n > 2 && sum%2==1 &&primes[sum-2]==1) {
			colors[2] = 2; sum -= 3;
		}
		if (n > 2) {
			for (int i = 2; i < sum; i++) {
				if (primes[i]==0 && primes[sum-i]==0) {
					int left = i;
					for (int j = n; j>= 1; j--) {
						if (colors[j-1]==0 && j <= left) {
							colors[j-1] = 1;
							left-=j;
						}
					}
					break;
				}
			}
		}
		for (int c: colors) {
			out.print((c+1) + " ");
		}
		out.println();
	}

	private static int[] getPrimes(int sum) {
		int[] p = new int[sum+1];
		p[0] = p[1] = 1;
		for (int i = 2; i < p.length; i++) {
			if (p[i] == 1) continue;
			for (int j = i+i; j < p.length; j+=i) {
				p[j] = 1;
			}
		}
		return p;
	}

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

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

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

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

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

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

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

}


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

public class Goldbach {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int S = (N*(N+1))/2;
	/**	int[] pr = new int[3000*6001+1];
		for(long i=2; i<pr.length; i++){
			if(pr[(int)i]!=0) continue;
			for(long j=i; j*i<pr.length; j++){
				pr[(int) (i*j)] = 1;
			}
		}
		isPrime[1] = isPrime[0] = false;
		for(int i=2; i<pr.length; i++) isPrime[i] = pr[i]==0; */
		if(S%2==0){
			for(int a=2; a<=S; a++){
		//		if(isPrime[a] && isPrime[S-a]){
				if(BigInteger.valueOf(a).isProbablePrime(20) && BigInteger.valueOf(S-a).isProbablePrime(20)){
					int[] ar = get(a, N);
					int[] used = new int[N+1];
					for(int i=0; i<ar.length; i++) used[ar[i]] = 1;
					for(int i=1; i<=N; i++) if(used[i]==0) used[i] = 2;
					for(int i=1; i<=N; i++){
						System.out.print(used[i]+" ");
					}
					System.out.println();
					return;
				}
			}
		}
		else{
			int[] used = new int[N+1];
			if(S==3){
				if(N==2) System.out.println("1 2");
				if(N==3) System.out.println("1 1 2");
				return;
			}
			used[3] = 1;
			for(int a=2; a<=S-3; a++){
			//	if(isPrime[a] && isPrime[S-3-a]){
				if(BigInteger.valueOf(a).isProbablePrime(20) && BigInteger.valueOf(S-3-a).isProbablePrime(20)){
					if(a==3){
						int[] ans = new int[N+1];
						ans[1] = ans[2] = 1;
						ans[3] = 2;
						for(int x=4; x<=N; x++) ans[x] = 3;
						for(int i=0; i<ans.length; i++) System.out.print(ans[i]+" ");
						System.out.println();
						return;
					}
					int[] arr = getWithout3(a, N);
					for(int i=0; i<arr.length; i++) used[arr[i]] = 2;
					for(int i=1; i<=N; i++) if(used[i]==0) used[i] = 3;
					for(int i=1; i<=N; i++) System.out.print(used[i]+" ");
					System.out.println();
					return;
				}
			}
		}
	}

	static int[] get(int a, int N){
		int sum = 0, c = 1;
		while(sum<a){
			sum += c;
			c++;
		}
		int dif = sum-a;
		if(dif==0){
			int[] ar = new int[c-1];
			for(int i=0; i<ar.length; i++) ar[i] = i+1;
			return ar;
		}
		int[] ar = new int[c-2];
		for(int i=1, j=0; i<c; i++){
			if(i==dif) continue;
			ar[j] = i;
			j++;
		}
		return ar;
	}

	static int[] getWithout3(int a, int N){
		int sum = 3, c = 4;
		while(sum<a){
			sum += c;
			c++;
		}
		int dif = sum-c;
		if(dif==0){
			int[] ans = new int[c-2];
			ans[0] = 1;
			ans[1] = 2;
			for(int i=2; i<c-2; i++) ans[i] = i+2;
			return ans;
		}
		if(dif==3){
			int[] ans = new int[c-4];
			for(int i=0; i<c-4; i++) ans[i] = i+4;
			return ans;
		}
		int[] ans = new int[c-2];
		for(int i=1, j=0; i<c; i++){
			if(i==dif || i==3) continue;
			ans[j++] = i;
		}
		return ans;
	}

	static boolean[] isPrime = new boolean[20000000];

}


import java.util.*;
public class Two_Round_Dances {
    public static Scanner scan = new Scanner(System.in);
    public static long factorial(int n){
        long fact = 1;
        for (int i=1;i<=n;i++){
            fact*=i;
        }
        return fact;
    }

    public static void main(String[] args) {
        int n=scan.nextInt();
        long answer = (long) (factorial(n)/Math.pow(n/2,2)/2);
        System.out.println(answer);
    }
}


//package div3._1433;

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

public class TwoRoundDances {

    private final FastReader fr = new FastReader();
    private long[] facts = new long[21];

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

    private void solve() {
        System.out.println(solve(fr.nextInt()));
    }

    private long solve(int n) {
        facts[0] = 1;
        for (int i = 1; i < n+1; i++) facts[i] = facts[i - 1] * i;
        long p = facts[n] / (facts[n/2] * facts[n/2]);
        return p * facts[n/2 - 1] * facts[n/2 - 1] / 2;
    }

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

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            }
        }

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

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

}


import java.util.*;
public class Codeforces{

    public long factorial(long n)
    {
        if(n==1 || n==0)
            return 1;
        else
            return n*factorial(n-1);
    }

    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        Codeforces ob=new Codeforces();
        long a=ob.factorial(n);
        long b=ob.factorial(n/2);
        long c=ob.factorial(n/2-1);
        long ans=(a/(b*b))*c*c/2;
        System.out.println(ans);
        sc.close();
    }
}


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

public class Main{
	static long fac(long l) {
		int j = 1;
		for (int i = 2; i <= l; i++) {
			j *= i;
		}
		return j;
	}
   public static void main(String[] args) throws IOException{

		long res = 1;
		long n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			res *= i;
		}
		for (int j = 0; j < 2; j++) {
			for (int i = 1; i <= n/2; i++) {
				res /= i;
			}
		}
		res/=2;

		out.println(res * pow(fac(n/2-1),2));

	out.close();
   }
   static long ceil(long a, long b) {
		return (a+b-1)/b;
	}

   static long powMod(long base, long exp, long mod) {
	   if (base == 0 || base == 1) return base;
	   if (exp == 0) return 1;
	   if (exp == 1) return base % mod;
	   long R = powMod(base, exp/2, mod) % mod;
	   R *= R;
	   R %= mod;
	   if ((exp & 1) == 1) {
		   return base * R % mod;
	   }
	   else return R % mod;
   }

   static long pow(long base, long exp) {
	   if (base == 0 || base == 1) return base;
	   if (exp == 0) return 1;
	   if (exp == 1) return base;
	   long R = pow(base, exp/2);
	   if ((exp & 1) == 1) {
		   return R * R * base;
	   }
	   else return R * R;
   }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


import java.util.Scanner;

public class Main {

	public static void main ( String args[] ) {

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

		if( i > 2 ) {
			if( (i-2)%2 == 0 ) {
				System.out.print("YES");
			}
		}
		else System.out.print("NO");
	}

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.util.Vector;

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

    StreamTokenizer in;
    PrintWriter out;
    boolean oj;
    BufferedReader br;

    void init() throws IOException {
        oj = System.getProperty("ONLINE_JUDGE") != null;
        Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
        Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
        br = new BufferedReader(reader);
        in = new StreamTokenizer(br);
        out = new PrintWriter(writer);
    }

    void run() throws IOException {
        long beginTime = System.currentTimeMillis();
        init();
        solve();
        long endTime = System.currentTimeMillis();
        if (!oj) {
            System.out.println("Memory used = " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
            System.out.println("Running time = " + (endTime - beginTime));
        }
        out.flush();
    }

    int nextInt() throws IOException {
        in.nextToken();
        return (int) in.nval;
    }

    long nextLong() throws IOException {
        in.nextToken();
        return (long) in.nval;
    }

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

    double nextDouble() throws IOException {
        in.nextToken();
        return in.nval;
    }

    void solve() throws IOException {
        int n = nextInt();
        int[][] w = new int[n + 1][2];
        int[] sc = new int[n + 1];
        Vector[] ways = new Vector[n + 1];
        for (int i = 0; i <= n; i++) {
            w[i][0] = nextInt();
            w[i][1] = nextInt();
        }
        boolean b;
        ways[0] = new Vector();
        for (int i = 1; i <= n; i++) {
            ways[i] = new Vector();
            ways[i].add(i);
            sc[i] = i;
        }
        do {
            b = true;
            for (int i = 2; i <= n; i++) {
                if (w[i][0] + w[i][1] < w[i - 1][0] + w[i - 1][1]) {
                    int c = w[i][0];
                    w[i][0] = w[i - 1][0];
                    w[i - 1][0] = c;
                    c = w[i][1];
                    w[i][1] = w[i - 1][1];
                    w[i - 1][1] = c;
                    c = sc[i];
                    sc[i] = sc[i - 1];
                    sc[i - 1] = c;
                    b = false;
                }
            }
        } while (!b);
        for (int i = n; i >= 1; i--) {
            for (int j = i + 1; j <= n; j++) {
                if (ways[j].size() + 1 > ways[i].size() && w[i][0] < w[j][0] && w[i][1] < w[j][1]) {
                    ways[i] = (Vector) ways[j].clone();
                    ways[i].add(i);
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            if (ways[i].size() > ways[0].size() && w[0][0] < w[i][0] && w[0][1] < w[i][1]) {
                ways[0] = (Vector) ways[i].clone();
            }
        }
        out.println(ways[0].size());
        for (int i = ways[0].size() - 1; i >= 0; i--) {
            out.print(sc[(Integer) ways[0].get(i)] + " ");
        }
    }
}


import java.io.*;
public class Watermelon {

       public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();

        int num = Integer.parseInt(s);

        if(num %2 == 0){
            System.out.println("YES");
        }
    }

}


import java.util.Scanner;

public class Main {

	public static void main ( String args[] ) {

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

		if( i > 2 ) {
			if( (i-2)%2 == 0 ) {
				System.out.println("YES");
			}
		}
		else System.out.println("NO");
	}

}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Main().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	char[][] grid;
	boolean[][] used;
	int n, m;
	int[] dx = { -1, 0, 1, 0 };
	int[] dy = { 0, 1, 0, -1 };
	int ans = 0;

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

		n = nextInt();
		m = nextInt();
		grid = new char[n][m];
		used = new boolean[n][m];
		for (int i = 0; i < n; i++)
			grid[i] = nextLine().toCharArray();
		dfs(0);
		out.println(ans);

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

	private void dfs(int c) {
		if (c == n * m) {
			int num = 0;
			for (int j = 0; j < n; j++)
				for (int k = 0; k < m; k++)
					if (grid[j][k] == 'P' && used[j][k])
						num++;
			ans = max(ans, num);
			return;
		}
		for (int i = c; i < n * m; i++) {
			if (grid[i / m][i % m] == 'W') {
				int i1 = i / m;
				int j1 = i % m;
				for (int j = 0; j < 4; j++) {
					i1 += dx[j];
					j1 += dy[j];
					if (i1 >= 0 && i1 < n && j1 >= 0 && j1 < m && !used[i1][j1] && grid[i1][j1] == 'P') {
						used[i1][j1] = true;
						dfs((i1 - dx[j]) * m + j1 - dy[j] + 1);
						used[i1][j1] = false;
					}
					i1 -= dx[j];
					j1 -= dy[j];
				}
			}
			if (i == n * m - 1) {
				int num = 0;
				for (int j = 0; j < n; j++)
					for (int k = 0; k < m; k++)
						if (grid[j][k] == 'P' && used[j][k])
							num++;
				ans = max(ans, num);
				return;
			}
		}
	}

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}
	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}


import java.util.Scanner;

public class B116 {

    public static int wolfs, maxPigs, n, m, a[][];
    public static boolean used[][];

    public static void rec(int x, int y, int w, int p) {
        if (w == wolfs) {
            if (p > maxPigs) {
                maxPigs = p;
            }
        } else if (w < wolfs) {
            for (int ii = x; ii < n; ii++) {
                for (int jj = (ii == x ? y : 0); jj < m; jj++) {
                    if (a[ii][jj] == 2) {
                        if (ii > 0 && !used[ii - 1][jj] && a[ii-1][jj] == 1) {
                            used[ii - 1][jj] = true;
                            rec(ii, jj + 1, w + 1, p + 1);
                            used[ii - 1][jj] = false;
                        }
                        if (jj > 0 && !used[ii][jj - 1] && a[ii][jj-1] == 1) {
                            used[ii][jj - 1] = true;
                            rec(ii, jj + 1, w + 1, p + 1);
                            used[ii][jj - 1] = false;
                        }
                        if (ii < (n - 1) && !used[ii + 1][jj] && a[ii+1][jj] == 1) {
                            used[ii + 1][jj] = true;
                            rec(ii, jj + 1, w + 1, p + 1);
                            used[ii + 1][jj] = false;
                        }
                        if (jj < (m - 1) && !used[ii][jj + 1] && a[ii][jj+1] == 1) {
                            used[ii][jj + 1] = true;
                            rec(ii, jj + 1, w + 1, p + 1);
                            used[ii][jj + 1] = false;
                        }
                        rec(ii,jj+1,w+1,p);
                    }
                }
            }
        }
    }

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        a = new int[n][m];
        used = new boolean[n][m];
        in.nextLine();
        wolfs = 0;
        maxPigs = 0;
        for (int i = 0; i < n; i++) {
            String s = in.nextLine();
            for (int j = 0; j < m; j++) {
                if (s.charAt(j) == 'W') {
                    a[i][j] = 2;
                    wolfs++;
                } else if (s.charAt(j) == 'P') {
                    a[i][j] = 1;
                } else {
                    a[i][j] = 0;
                }
            }
        }
        rec(0, 0, 0, 0);
        System.out.println(maxPigs);
    }
}


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

public class PigsAndWolves {

	static int n, m, best;
	static char[][] grid;
	static int[] dr = {-1, 0, 1, 0};
	static int[] dc = {0, 1, 0, -1};

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		n = Integer.parseInt(st.nextToken());
		m = Integer.parseInt(st.nextToken());
		grid = new char[n][m];
		for (int i = 0; i < n; i++) {
			String s = in.readLine();
			for (int j = 0; j < m; j++) {
				grid[i][j] = s.charAt(j);
			}
		}
		best = -1;
		rec(0, 0, 0);
		System.out.println(best);
	}

	static void rec(int r, int c, int eaten) {
		if (c == m) {
			c = 0;
			r++;
		}
		if (r == n) {
			best = Math.max(best, eaten);
			return;
		}
		if (grid[r][c] == 'P') {
			for (int i = 0; i < 4; i++) {
				int rr = r + dr[i];
				int cc = c + dc[i];
				if (onGrid(rr, cc)) {
					if (grid[rr][cc] == 'W') {
						grid[rr][cc] = '.';
						rec(r, c + 1, eaten + 1);
						grid[rr][cc] = 'W';
					}
				}
			}
		}
		rec(r, c + 1, eaten);
	}

	static boolean onGrid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < m;
	}
}


//package ladderB;

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

public class littlePigsAndWolves {
	static ArrayList<pair> wolves;
	static pair [] trav;
	static class pair{
		int i, j;
		public pair(int i, int j) {
			this.i = i;
			this.j = j;
		}
	}
	static int traverse(char [][] map, int idx) {
		if(idx ==wolves.size())
			return 0;
		pair wolf = wolves.get(idx);
		int counter = 0;
		for (int i = 0; i < trav.length; i++) {
			int curI = wolf.i;
			int curJ = wolf.j;
			int possI = curI+trav[i].i;
			int possJ = curJ + trav[i].j;
//			System.out.println(possI+" "+possJ);
			if(possI>=0&&possI<map.length) {
				if(possJ>=0&&possJ<map[0].length)
					if(map[possI][possJ]=='P') {
//					System.out.println("here");
					map[possI][possJ]= '.';
					counter = Math.max(1 + traverse(map,idx+1),counter);
					map[possI][possJ] = 'P';
				}
			}
		}
		counter = Math.max(traverse(map, idx+1), counter);
		return counter;
	}
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int m = sc.nextInt();
	char [][]map = new char[n][m];
	wolves = new ArrayList<pair>();
	trav = new pair[4];
	trav[0] = (new pair(1,0));
	trav[1] = (new pair(0,1));
	trav[2] = (new pair(-1,0));
	trav[3] = (new pair(0,-1));
	for (int i = 0; i < map.length; i++) {
		String cur = sc.next();
		for (int j = 0; j < map[i].length; j++) {
			map[i][j] = cur.charAt(j);
			if(map[i][j]=='W')
				wolves.add(new pair(i,j));
		}
	}
//	System.out.println(wolves.size());
	if(wolves.size()==0)
		System.out.println(0);
	else
	System.out.println(traverse(map, 0));
}
}


package codeforces;

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

public class TaskA {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int countp = in.nextInt();
        String s = in.next();
        in.close();
        char[] al = s.toCharArray();
        int[] count = new int[26];
        for(char c: al){
            int j = c -'a' ;
            count[j]++;
        }
        int count2 = 0;
        for(int i : count) {
            if (i >=2) {
                count2++;
            }
        }
        if(count2>0){
            out.write("Yes");
        }else {
            out.write("No");
        }
        out.close();

    }
}


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

public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        HashSet<String> dublicates = new HashSet<>();
        for(int i = 0; i < n; i++) {
            String color = in.next();
            if(dublicates.contains(color)) {
                System.out.println("Yes");
            }
            dublicates.add(color);
        }
        System.out.println("No");
    }
}


/*
 * 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 cfa;
import java.util.Scanner;

/**
 *
 * @author jay
 */
public class Cfa {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        String s;
        int t;
        int flag=0;
        Scanner in = new Scanner(System.in);
        t=in.nextInt();
        s=in.next();
//        s=in.nextLine();
//        System.out.println(t);
//        System.out.println(s);
        int[] h=new int[26];

        for(int i=0;i<26;i++)
            h[i]=0;

//        for(int i=0;i<26;i++)
//            System.out.print(h[i]+" ");
//        System.out.println("");

        for(int i=0;i<s.length();i++)
        {
//            System.out.println("in");
            if(h[s.charAt(i)-'a']>0)
                flag=1;
            else
                h[s.charAt(i) - 'a']++;
        }

//        for(int i=0;i<26;i++)
//            System.out.print(h[i]+" ");
//        System.out.println("");

        if(flag==1)
        {
            System.out.println("Yes");;
        }
        else
        {
            System.out.println("No");
        }
    }

}


package codefocecontest1;

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

public class doggo {

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

		    s.nextLine();
		    String pup = s.nextLine();

		    boolean ans = false;
		    ArrayList<String> pups = new ArrayList <String>();
		    for(int i = 0; i < pupNum; i++) {
		    	pups.add(pup.substring(i,i+1));
		    }
		    if(pups.size() == 1) {
		    	System.out.println("YES");
		    	System.exit(0);
		    }
		    for(int i = 0; i< pupNum; i++) {
		        if (ans) break;
		        for(int j = i+1; j<pupNum; j++){

	                if(pups.get(i).equals(pups.get(j))) {
		    		System.out.println("YES");
		    		ans = true;
		    		break;
		         }
		        	    	}
		    }
		    if (ans == false) System.out.println("NO");

	}

}


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

public class Kicker {
	public static void choose1(int[][] skills, int[] order) {
		if (skills[0][0] > skills[2][0] && skills[0][0] > skills[3][0] &&
			skills[1][1] > skills[2][1] && skills[1][1] > skills[3][1]) {
				order[0] = 0;
				order[1] = 1;
		} else {
			order[0] = 1;
			order[1] = 0;
		}
	}

	public static void choose2(int[][] skills, int[] order) {
		int d1 = order[0], a1 = order[1];
		if (skills[2][0] > skills[d1][0] && skills[3][1] > skills[a1][1]) {
				order[2] = 2;
				order[3] = 3;
		} else {
			order[2] = 3;
			order[3] = 2;
		}
	}

	public static int play(int[][] skills, int[] order) {
		int d1 = order[0], a1 = order[1], d2 = order[2], a2 = order[3], result;
		if (skills[d1][0] > skills[d2][0]) {
			if (skills[a1][1] > skills[a2][1]) {
				result = 1;
			} else {
				result = 0;
			}
		} else if (skills[d1][0] == skills[d2][0]) {
			result = 0;
		} else {
			if (skills[a1][1] < skills[a2][1]) {
				result = 2;
			} else {
				result = 0;
			}
		}
		return result;
	}

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

		int[][] skills = new int[4][2];
		int[] order = new int[4]; // defence 1, attack 1, defence 2, attack 2

		String[] tempList;
		String line;
		for (int i = 0; i < 4; ++i) {
			line = br.readLine();
			tempList = line.split("\\s");
			for (int j = 0; j < 2; ++j) {
				skills[i][j] = Integer.parseInt(tempList[j]);
			}
		}

		choose1(skills, order);	// team 1 choose
		choose2(skills, order);	// team 2 choose

		int result = play(skills, order);
		if (result == 0) {
			System.out.println("Draw");
		} else {
			System.out.println("Team " + result);
		}
	}
}


import java.util.*;

public class C {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t1p1A = in.nextInt();
		int t1p1D = in.nextInt();
		int t1p2A = in.nextInt();
		int t1p2D = in.nextInt();
		int t2p1A = in.nextInt();
		int t2p1D = in.nextInt();
		int t2p2A = in.nextInt();
		int t2p2D = in.nextInt();

		boolean advantage2; // Advantage of team 2

		// Case 1. Team 1 (A D) is (t1p1A t1p2D)
		if ((t2p1A < t1p1A && t2p2D < t1p2D) && (t2p2A < t1p1A && t2p1D < t1p2D)) {
			System.out.println("Team 1");
			return;
		}
		if ((t2p1A > t1p1A && t2p2D > t1p2D) || (t2p2A > t1p1A && t2p1D > t1p2D)) advantage2 = true;
		else advantage2 = false;

		// Case 2. Team 1 (A D) is (t1p2A t1p1D)
		if ((t2p1A < t1p2A && t2p2D < t1p1D) && (t2p2A < t1p2A && t2p1D < t1p1D)) {
			System.out.println("Team 1");
			return;
		}
		else if (((t2p1A > t1p2A && t2p2D > t1p1D) || (t2p2A > t1p2A && t2p1D > t1p1D)) && advantage2) {
			System.out.println("Team 2");
			return;
		}
		System.out.println("Draw");
	}

}


import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.min;
import static java.lang.Math.max;

public class Main {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {

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

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

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

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

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

    public static void main(String[] args) {
        new Main().run();
        // Sworn to fight and die
    }

    public static void mergeSort(int[] a) {
        mergeSort(a, 0, a.length - 1);
    }

    private static void mergeSort(int[] a, int levtIndex, int rightIndex) {
        final int MAGIC_VALUE = 2;
        if (levtIndex < rightIndex) {
            if (rightIndex - levtIndex <= MAGIC_VALUE) {
                insertionSort(a, levtIndex, rightIndex);
            } else {
                int middleIndex = (levtIndex + rightIndex) / 2;
                mergeSort(a, levtIndex, middleIndex);
                mergeSort(a, middleIndex + 1, rightIndex);
                merge(a, levtIndex, middleIndex, rightIndex);
            }
        }
    }

    private static void merge(int[] a, int levtIndex, int middleIndex,
                              int rightIndex) {
        int length1 = middleIndex - levtIndex + 1;
        int length2 = rightIndex - middleIndex;
        int[] levtArray = new int[length1];
        int[] rightArray = new int[length2];
        System.arraycopy(a, levtIndex, levtArray, 0, length1);
        System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
        for (int k = levtIndex, i = 0, j = 0; k <= rightIndex; k++) {
            if (i == length1) {
                a[k] = rightArray[j++];
            } else if (j == length2) {
                a[k] = levtArray[i++];
            } else {
                a[k] = levtArray[i] <= rightArray[j] ? levtArray[i++]
                        : rightArray[j++];
            }
        }
    }

    private static void insertionSort(int[] a, int levtIndex, int rightIndex) {
        for (int i = levtIndex + 1; i <= rightIndex; i++) {
            int current = a[i];
            int j = i - 1;
            while (j >= levtIndex && a[j] > current) {
                a[j + 1] = a[j];
                j--;
            }
            a[j + 1] = current;
        }
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    class LOL implements Comparable<LOL> {

        int x;
        int y;

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

        }

        @Override
        public int compareTo(LOL o) {
            if (x == o.x) {
                return y - o.y;
            }

            return (x - o.x);
            // return o.x * o.y - x * y; // <----
        }

    }

    Map <Integer, ArrayList<Integer>> g = new HashMap<Integer, ArrayList<Integer>>();

    public void solve() throws IOException {
        int n = 4;
        int a[] = new int[n + 1];
        int b[] = new int[n + 1];

        for (int i = 1; i <= n; i++) {
            a[i] = readInt();
            b[i] = readInt();
        }

        int win1 = 0;
        int draw1 = 0;
        int loose1 = 0;

        if (a[1] > a[3] && b[2] > b[4]) {
            win1++;
        } else if (a[1] < a[3] && b[2] < b[4]) {
            loose1++;
        } else {
            draw1++;
        }

        if (a[1] > a[4] && b[2] > b[3]) {
            win1++;
        } else if (a[1] < a[4] && b[2] < b[3]) {
            loose1++;
        } else {
            draw1++;
        }

        if (win1 == 2) {
            out.print("Team 1");
            return;
        }

        int win2 = 0;
        int draw2 = 0;
        int loose2 = 0;

        if (a[2] > a[3] && b[1] > b[4]) {
            win2++;
        } else if (a[2] < a[3] && b[1] < b[4]) {
            loose2++;
        } else {
            draw2++;
        }

        if (a[2] > a[4] && b[1] > b[3]) {
            win2++;
        } else if (a[2] < a[4] && b[1] < b[3]) {
            loose2++;
        } else {
            draw2++;
        }

        if (win2 == 2) {
            out.print("Team 1");
            return;
        }

        if (loose1 > 1 && loose2 > 1) {
            out.print("Team 2");
            return;
        }

        out.print("Draw");

    }

}


package players;

import java.util.Scanner;

public class Players {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[][] s = new String[4][2];
        int[][] j = new int[4][2];
        for(int i = 0; i < 4; ++ i) {
            String t = sc.nextLine();
            String s1 = t.split(" ")[0];
            String s2 = t.split(" ")[1];
            //System.out.println(s1 + "  " + s2);
            j[i][0] = Integer.parseInt(s1);
            j[i][1] = Integer.parseInt(s2);
        }
        int t1_t1 = j[0][1];
        int t1_t2 = j[1][1];
        int t1_d1 = j[0][0];
        int t1_d2 = j[1][0];

        int t2_t1 = j[2][1];
        int t2_t2 = j[3][1];
        int t2_d1 = j[2][0];
        int t2_d2 = j[3][0];

        //int t1_max_t = Integer.max(t1_t1, t1_t2);
        //int t1_max_d = Integer.max(t1_d1, t1_d2);

        //int t2_max_t = Integer.max(t2_t1, t2_t2);
        //int t2_max_d = Integer.max(t2_d1, t2_d2);
        //if(t1_max_t > t2_max_d && t1_max_d > t2_max_t) System.out.println("Team 1");
        //else if(t2_max_t > t1_max_d && t2_max_d > t1_max_t) System.out.println("Team 2");
        //else System.out.println("Draw");

        int t1_t = j[0][1];
        int t1_d = j[1][0];

        int t1_t_1 = j[0][1];
        int t1_d_1 = j[1][0];

        int state = -1;
            if((t1_t > j[2][0] && t1_d > j[3][1]) && (t1_t > j[3][0] && t1_d > j[2][1])) {
                System.out.println("Team 1");
                return;
            }
            if((t1_t_1 > j[2][0] && t1_d_1 > j[3][1]) && (t1_t_1 > j[3][0] && t1_d_1 > j[2][1])) {
                System.out.println("Team 1");
                return;
            }
            int t2_t = j[2][1];
            int t2_d = j[3][0];

            int t2_t_1 = j[3][1];
            int t2_d_1 = j[2][0];

            if((t2_t > t1_d && t2_d > t1_t) || (t2_t_1 > t1_d && t2_d_1 > t1_t)) {
                System.out.println("Team 2");
                return;
            }
            if((t2_t_1 > t1_d && t2_d_1 > t1_t) || (t2_t_1 > t1_t_1 && t2_d_1 > t1_t_1)) {
                System.out.println("Team 2");
                return;
            }

                System.out.println("Draw");

    }
}


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

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

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

		//int freq[]=new int[max+1];
	int count=0;
	while(t>0)
	{
		int x=q.peek();
		if(t-x<=0)
		continue;

		t=t-x;
		count++;
		if(count==n)
		count=1;
		q.remove();
		q.add(x);
	}

		System.out.println(count);

	}
}


import java.util.Scanner;

public class A139 {

    public void main_menu() {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();

        int week[] = new int[8];

        for (int i = 0; i < 7; i++) {
            week[i] = scan.nextInt();
        }

        int total = 0;
        while (true) {

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

                total += week[i];
                if (total >= n) {
                    System.out.println(i + 1);
                    return;

                }

            }

        }

    }

    public static void main(String[] args) {
        new A139().main_menu();
    }
}


import java.util.Scanner;

public class Solution {

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

    public static void main(String[] args) {
        int n = scan.nextInt();
        System.out.println(doProcess(n));
    }

    private static int doProcess(int n){
        int [] p = new int[n];
        int sum=0, i=0;
        while(sum<n){
            if(i < n) p[i] = scan.nextInt();
            else i = 0;
            sum+=p[i];
            i++;
        }
        return i;
    }
}


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

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

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

		//int freq[]=new int[max+1];
	int count=0;
	while(t>0)
	{
		if(count==7)
		count=1;
		count++;
		t=t-arr[count-1];
	}

		System.out.println(count);

	}
}


import java.util.Scanner;

public class EasterEggs {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] color = {"R","O","Y","G","B","I","V"};
        for(int i = 0; i < n; i++){
            if(i > 6){
                int mod = (i)%6;
                System.out.print(color[mod + 2]);
            }
            else{
                System.out.print(color[i]);
            }
        }
    }
}


package Contest1;

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

public class problem2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = in.nextInt();
		int Color[] = new int[N];
		for(int i=0;i<N;i++){
			//System.out.print((i-1)%N+" "+(i-1)+" "+N);
			int color = 1;
			while (Color[i]==0){
				if (Color[(i+N-1)%N]==color||Color[(i+N-2)%N]==color||Color[(i+N-3)%N]==color||
					Color[(i+1)%N]==color||Color[(i+2)%N]==color||Color[(i+3)%N]==color)
					color+=1;
				else Color[i] = color;
			}
		}

		for (int i=0;i<N;i++)
			if (Color[i]==1) out.print("R");
			else if (Color[i]==2) out.print("O");
			else if (Color[i]==3) out.print("Y");
			else if (Color[i]==4) out.print("G");
			else if (Color[i]==5) out.print("B");
			else if (Color[i]==6) out.print("I");
			else out.print("V");
		out.close();
	}

}


import java.util.Scanner;
public class Acm {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in) ;
       int size = input.nextInt();
        char[] arr =new char[7];
        arr[0]='R';arr[1]='O';arr[2]='Y';arr[3]='G';arr[4]='B';arr[5]='I';arr[6]='V';

        char []output = new char [size];
        output[size-1]='a';
        for(int i=0;i<7;i++)
            output[i]=arr[i] ;
        int x =0 ;
        for(int i=7;i<i+1;i++)
        {
            if(x>6)
                 x=0;
            char y = arr[x];
            if(y!=output[i-1]&&y!=output[i-2]&&y!=output[i-3]&&y!=output[i-4])
            {
                if((y!=output[(i+1)%size]&&y!=output[(i+2)%size]&&y!=output[(i+3)%size]&&y!=output[(i+4)%size]))
                {output[i]=y;  }
                else
                    i--;
             }
            else
                i--;
            x++ ;
            if(output[size-1]!='a')
                break ;
            }

        for(int i=0;i<size;i++)
         System.out.print(output[i]);

 //int x = input.nextInt();
// System.out.print(10%10);
    }
}


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

public class C {

	static boolean in(char c, String x) {
		for (int i = 0; i < x.length(); i++)
			if (x.charAt(i) == c)
				return true;
		return false;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		StringBuilder ans = new StringBuilder();
		char[] c = "ROYGBIV".toCharArray();

		while (N > 3) {

			for (int i = 0; i < c.length && N > 3; i++) {
				if (ans.length() == 0 || ans.length() < 3 || !in(c[i], ans.substring(ans.length() - 3, ans.length()))) {
					ans.append(c[i]);
					N--;
				}
			}

		}
		int p = 5;
		while (N > 0) {
			for (int i = 0; i < c.length && N > 0; i++) {
				if (ans.length() == 0 || ans.length() < 3 || !in(c[i], ans.substring(ans.length() - 3, ans.length()))
						&& !in(c[i], ans.substring(0, Math.min(p, ans.length())))) {
					ans.append(c[i]);
					N--;
					p--;
				}
			}
		}

		System.out.println(ans);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

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

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

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

		public int[] nextIntArray1(int n) throws IOException {
			int[] a = new int[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextInt();
			return a;
		}

		public int[] nextIntArraySorted(int n) throws IOException {
			int[] a = nextIntArray(n);
			Random r = new Random();
			for (int i = 0; i < n; i++) {
				int j = i + r.nextInt(n - i);
				int t = a[i];
				a[i] = a[j];
				a[j] = t;
			}
			Arrays.sort(a);
			return a;
		}

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

		public long[] nextLongArray1(int n) throws IOException {
			long[] a = new long[n + 1];
			for (int i = 1; i <= n; i++)
				a[i] = nextLong();
			return a;
		}

		public long[] nextLongArraySorted(int n) throws IOException {
			long[] a = nextLongArray(n);
			Random r = new Random();
			for (int i = 0; i < n; i++) {
				int j = i + r.nextInt(n - i);
				long t = a[i];
				a[i] = a[j];
				a[j] = t;
			}
			Arrays.sort(a);
			return a;
		}
	}
}


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

public class B {
	FastScanner in;
	PrintWriter out;

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

	public void solve() throws IOException {
		long n = in.nextLong();
		long m = in.nextLong();
		long x = in.nextLong();
		long y = in.nextLong();
		long a = in.nextLong();
		long b = in.nextLong();

		long g = gcd(a, b);
		a /= g; b /= g;

		long k = Math.min(n / a, m / b);

		long width = k * a;
		long height = k * b;

		long rx = Math.max(Math.min(x - width / 2 - width % 2, n - width), 0);
		long ry = Math.max(Math.min(y - height / 2 - height % 2, m - height), 0);

		out.println(rx + " " + ry + " " + (rx + width) + " " + (ry + height));
	}

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

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream is) {
			try {
				br = new BufferedReader(new InputStreamReader(is));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

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

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

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

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

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


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

public class Main {

	static int gcd(int a, int b) {
		if (a > b) return gcd(b, a);
		if (a == 0) return b;
		return gcd(b % a, a);
	}

	public static void main(String[] args) throws Exception {
		long time = System.nanoTime();

		int n = next();
		int m = next();
		int xx = next();
		int yy = next();
		int a = next();
		int b = next();

		int c = gcd(a, b);
		a /= c;
		b /= c;

		int mult = Math.min(n/a, m/b);
		a *= mult;
		b *= mult;

		int x1 = 0;
		int x2 = a;
		int y1 = 0;
		int y2 = b;

		int shiftx = Math.max(0, Math.min(n - a, xx - (a + 1)/2));
		int shifty = Math.max(0, Math.min(m - b, yy - (b + 1)/2));

		x1 += shiftx;
		x2 += shiftx;
		y1 += shifty;
		y2 += shifty;

		out.println(x1 + " " + y1 + " " + x2 + " " + y2);

		//System.out.println((System.nanoTime() - time)* 1e-9);
		out.close();
	}
	static PrintWriter out = new PrintWriter(System.out);

	static BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer in = new StringTokenizer("");

	static String nextToken() throws Exception {
		if (!in.hasMoreTokens()) in = new StringTokenizer(bufferedreader.readLine());
		return in.nextToken();
	}

	static int next()  throws Exception {return Integer.parseInt(nextToken());};
	static int[] next(int n) throws Exception {
		int[] x = new int[n];
		for (int i = 0; i < n; i++) x[i] = next();
		return x;
	}
	static int[][] next(int n, int m) throws Exception {
		int[][] x = new int[n][];
		for (int i = 0; i < n; i++) x[i] = next(m);
		return x;
	}

	static long nextl() throws Exception {return Long.parseLong(nextToken());};
	static long[] nextl(int n) throws Exception {
		long[] x = new long[n];
		for (int i = 0; i < n; i++) x[i] = nextl();
		return x;
	}
	static long[][] nextl(int n, int m) throws Exception {
		long[][] x = new long[n][];
		for (int i = 0; i < n; i++) x[i] = nextl(m);
		return x;
	}

	static double nextd() throws Exception {return Double.parseDouble(nextToken());};
	static double[] nextd(int n) throws Exception {
		double[] x = new double[n];
		for (int i = 0; i < n; i++) x[i] = nextd();
		return x;
	}
	static double[][] nextd(int n, int m) throws Exception {
		double[][] x = new double[n][];
		for (int i = 0; i < n; i++) x[i] = nextd(m);
		return x;
	}

	static String nextline() throws Exception {
		in = new StringTokenizer("");
		return bufferedreader.readLine();
	}

}


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

public class B {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

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

	int solve(int bigLen, int ins, int smallLen) {
		int low = Math.max(ins - smallLen, 0);
		int high = Math.min(ins, bigLen - smallLen);

		int doubleOpt = 2 * ins - smallLen;
		if (doubleOpt < 2 * low)
			return low;
		if (doubleOpt > 2 * high)
			return high;
		return doubleOpt / 2;
	}

	void solve(int n, int m, int x, int y, int a, int b) {
		int gcd = gcd(a, b);
		a /= gcd;
		b /= gcd;

		int sz = Math.min(n / a, m / b);
		a *= sz;
		b *= sz;

		int x1 = solve(n, x, a);
		int y1 = solve(m, y, b);
		out.println(x1 + " " + y1 + " " + (x1 + a) + " " + (y1 + b));
	}

	B() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int n = nextInt();
		int m = nextInt();
		int x = nextInt();
		int y = nextInt();
		int a = nextInt();
		int b = nextInt();
		solve(n, m, x, y, a, b);
		out.close();
	}

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

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

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

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

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

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


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

public class Rectangle2{
	public static void main(String[] args) throws Exception{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] g = in.readLine().split("\\s+");
		long n = Long.parseLong(g[0]);
		long m = Long.parseLong(g[1]);
		long x = Long.parseLong(g[2]);
		long y = Long.parseLong(g[3]);
		long a = Long.parseLong(g[4]);
		long b = Long.parseLong(g[5]);
		long gcf = gcd(Math.max(a,b),Math.min(a,b));
		a/=gcf;
		b/=gcf;
		long l = (n/a)*a;
		long w = (l*b)/a;
		if(w>m){
			w = (m/b)*b;
			l = (w*a)/b;
		}
		long xhalf = (long)Math.ceil((l+0.0)/2);
		long yhalf = (long)Math.ceil((w+0.0)/2);
		long x1 = x-xhalf;
		long y1 = y-yhalf;
		long x2 = x+(l-xhalf);
		long y2 = y+(w-yhalf);
		// System.out.println(x1+" "+y1+" "+x2+" "+y2);
		// System.out.println(l+" "+w);
		if(x2>n){
			long d = x2-n;
			x2-=d;
			x1-=d;
		}
		else if(x1<0){
			long d = -x1;
			x2+=d;
			x1+=d;
		}
		if(y2>m){
			long d = y2-m;
			y2-=d;
			y1-=d;
		}
		else if(y1<0){
			long d = -y1;
			y2+=d;
			y1+=d;
		}
		System.out.println(x1+" "+y1+" "+x2+" "+y2);
	}

	static long gcd(long a, long b){
		long c = a%b;
		if(c==0) return b;
		return gcd(b,c);
	}
}


//package CodeForces;

/*In the name of Allah the Most Merciful.
 * Author
 * Md. Toufiqul Islam
 * Dept. Of CSE
 * Ahsanullah University Of Science And Technology
*/
import java.io.*;
import java.util.*;
import java.math.*;
public class ER36B {

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

        int n = sc.nextInt();
        int pos = sc.nextInt();
        int pos1 = pos;
        int l = sc.nextInt();
        int r = sc.nextInt();

        int a = 1;
        int b = n;
        int totalSec =0;
        int totalSec1 =0;
        if(a==l && b==r){
            out.println("0");
        }

        else{

           if(a!=l && b!=r){

               while (pos1!=l){
                   pos1--;
                   totalSec++;
               }

               totalSec++;

               while (pos1!=r){
                   pos1++;
                   totalSec++;
               }
               totalSec++;

               pos1 = pos;

            //   System.out.println("Pos1 "+pos1);

               while (pos1!=r){
                   pos1++;
                   totalSec1++;
               //    System.out.println(totalSec1);

               }

               totalSec1++;

               while (pos1!=l){
                   pos1--;
                   totalSec1++;

               }
            //   System.out.println();
               totalSec1++;

             //  System.out.println(totalSec+" "+totalSec1);
               out.println(Math.min(totalSec,totalSec1));
           }
           else if(a!=l && b==r){
               while (pos1!=l){
                   pos1--;
                   totalSec++;
               }

               totalSec++;

               System.out.println(totalSec);
           }

           else if(a==l && b!=r){
            //   System.out.println(pos1+" "+r);

               while (pos1!=r){
                   pos1++;
                   totalSec1++;
                   //    System.out.println(totalSec1);

               }

               totalSec1++;

               //   System.out.println();

               System.out.println(totalSec1);

           }
           else{
               System.out.println("0");
           }
        }
        out.close();
    }

    public static class InputReader {
        private boolean finished = false;

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private 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 peek() {
            if (numChars == -1) {
                return -1;
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar];
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

        public SpaceCharFilter getFilter() {
            return filter;
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
        public int[] nextIntArray(int n){
            int[] array=new int[n];
            for(int i=0;i<n;++i)array[i]=nextInt();
            return array;
        }
        public int[] nextSortedIntArray(int n){
            int array[]=nextIntArray(n);
            Arrays.sort(array);
            return array;
        }
        public int[] nextSumIntArray(int n){
            int[] array=new int[n];
            array[0]=nextInt();
            for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
            return array;
        }
        public long[] nextLongArray(int n){
            long[] array=new long[n];
            for(int i=0;i<n;++i)array[i]=nextLong();
            return array;
        }
        public long[] nextSumLongArray(int n){
            long[] array=new long[n];
            array[0]=nextInt();
            for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
            return array;
        }
        public long[] nextSortedLongArray(int n){
            long array[]=nextLongArray(n);
            Arrays.sort(array);
            return array;
        }
    }
    public 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 print(char[] array) {
            writer.print(array);
        }

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

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

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

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

        public void println(int[] array) {
            print(array);
            writer.println();
        }

        public void println(double[] array) {
            print(array);
            writer.println();
        }

        public void println(long[] array) {
            print(array);
            writer.println();
        }

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

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

        public void print(char i) {
            writer.print(i);
        }

        public void println(char i) {
            writer.println(i);
        }

        public void println(char[] array) {
            writer.println(array);
        }

        public void printf(String format, Object... objects) {
            writer.printf(format, objects);
        }

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

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

        public void print(long i) {
            writer.print(i);
        }

        public void println(long i) {
            writer.println(i);
        }

        public void print(int i) {
            writer.print(i);
        }

        public void println(int i) {
            writer.println(i);
        }

        public void separateLines(int[] array) {
            for (int i : array) {
                println(i);
            }
        }
    }

}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n,pos,l,r,i;
        n=scan.nextInt();
        pos=scan.nextInt();
        l=scan.nextInt();
        r=scan.nextInt();
        if(n==r && l==1){
            System.out.println(0);
        }
        else if(pos==r && l==1){
            System.out.println(1);
        }
        else{
            i=0;
            if(l==1 && pos!=r){
                if(pos>r){
                    System.out.println((pos-r)+1);
                }else{
                System.out.println(n-pos);
                }
            }else{
                if(n==r){
                   while(pos!=l){
                pos--;
                i++;
            }
                    System.out.println(i+1);
                }else{
            while(pos!=l){
                pos--;
                i++;
            }
            while(pos!=n){
                pos++;
                i++;
            }
            System.out.println(i);
        }
            }
        }

    }
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

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

	public static void main(String[] args) {

		int n = in.nextInt();
		int c = in.nextInt();
		int l = in.nextInt();
		int r = in.nextInt();

		int [] a = new int[n];

		for (int i = 0; i < a.length; i++) {
			if(i>=l-1 && i<=r-1) a[i]=-1;
		}

		int num = 0;

		c=c-1;
		r=r-1;
		l=l-1;

		while(!isFinish(a)) {

			if(Math.abs(c-l)<Math.abs(c-r)) {
				num+=Math.abs(c-l);
				c = l;
				closeLeft(a, l);
				if(c!=0) num++;
			}
			else {
				num+=Math.abs(c-r);
				c=r;
				closeRight(a, r);
				if(a.length-1-c!=0) num++;
			}

			if(isFinish(a)) break;

			if(c==l) {
				num+=(r-l);
				c=r;
			}
			else {
				num+=(r-l);
				c=l;
			}
		}

		System.out.println(num);

	}
	static void closeLeft(int [] a , int l) {
		for (int i = 0; i < l; i++) {
			a[i]=1;
		}
	}
	static void closeRight (int [] a, int r) {
		for (int i = r; i < a.length; i++) {
			a[i]=1;
		}
	}
	static boolean isFinish(int [] a) {

		int num = 0;

		for (int i = 0; i < a.length; i++) {
			if(a[i]==-1 || a[i]==1) num++;
		}

		return num==a.length;
	}

	static int findAPeak(int [] a) {

		int n = a.length;

		int lo = 0;
		int hi = n-1;

		while(lo<=hi) {

			int mid = lo+(hi-lo)/2;
			if(a[mid]<a[mid-1]) hi = mid-1;
			else if(a[mid]<a[mid+1]) lo=mid+1;
			else return mid;

		}

		return -1;
	}
	 static HashMap<String, ArrayList<String>> solve(HashMap<String, String []> map) {

		boolean flag = false;

		HashMap<String, ArrayList<String>> ans = new HashMap<>();

		for (Map.Entry<String, String []> m : map.entrySet()) {
			String [] ss = m.getValue();
			for (int i = 0; i < ss.length; i++) {
				for (int j = i+1; j < ss.length; j++) {
					if(ss[j].endsWith(ss[i]))  {
						flag = true;
						break;
					}
				}
				if(!flag) {
				//	ans.put(m.getKey(), value)
				}
			}
		}

		return null;
	}

	static void fillAnArray(long [] a) {
		for (int i = 0; i < a.length - 1; i++) {
			a[i]=in.nextLong();
		}
	}
	static int []  shuffleAnArray(int [] a) {

		for (int i = 0; i < a.length; i++) {
			int index = (int)(Math.random()*a.length);
			int temp = a[i];
			a[i]=a[index];
			a[index]=temp;
		}

		return a;

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

	static boolean eulerFunction(int n, int k) {
		return gcd(n,k)==1;
	}
	static String operate(String S, int l,int r,char o,char n) {

		String ss = "";

		for (int i = 0; i < S.length() ; i++) {

			if(i>=l-1 && i<=r-1) {

				if(S.charAt(i)== o) {
					ss+=n;
				}

				else {
					ss+=S.charAt(i);
				}
			}
			else {
				ss+=S.charAt(i);
			}
		}

		return ss;
	}
	static int sumOfArray(int [] a) {
		int sum = 0;
		for (int i = 0; i < a.length; i++)
			if(a[i]>0)sum+=a[i];
		return sum;
	}

	private static long convert(int i) {
		long res = i;
		while(i>0){
			int lastNum = i % 10;
			res = res * 10 + lastNum;
			i /=10;
		}

		return res;
	}

	static int numberOfElementsAboveZero(int [] a) {
		int num = 0;
		for (int i = 0; i < a.length; i++) {
			if(a[i]>0) num++;
		}
		return num;
	}
	static int min(int [] a) {
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < a.length; i++) {
			if(a[i]>0 && a[i]<min) {
				min=a[i];
			}
		}
		return min;
	}
	static void dis(int [] a ,int min) {
		for (int i = 0; i < a.length; i++) {
			a[i]-=min;
		}
	}
	static boolean isPrime(int n) {

		if(n < 2) return false;

		for (int i = 2; i <= (int)Math.sqrt(n); i++)
			if(n%i==0) return false;
			return true;

	}

}


//package B;
/**
 * Created by Eesaa on 1/13/2018.
 */

import java.util.*;

public class B_915 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), pos = in.nextInt(), l = in.nextInt(), r = in.nextInt();
        //go to l and close everything to the left of l if its bigger than 1
        int res = 0;
        if (l != 1) {
            res += Math.abs(pos - l) + 1;
            pos = l;
        }
        if (r != n) {
            res += Math.abs(r-pos) + 1;
        }
        System.out.println(res);

        in.close();
    }
}


import java.util.Scanner;

public class A {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		long x= sc.nextLong();
		long n=0L;
		long result;
		if(x<3)
			result=1;
		else if(x==3)
			result=2;
		else{

		for(long i=1L; i<x; i++){
			if((i*(i-1))/2+1>x){
				i--;
				n= (i*(i-1))/2+1;
				break;
			}
		}
		result=x-n+1;
		}
		System.out.println(result);
	}

}


import java.util.*;

public class Infinite{

	public static long infinite(long n, int i, long[] list){
		for(int k=1;k<i;k++){
			if (list[k]==n)
				return k;
			if (list[k]>n){
				//System.out.println(""+n+list[--k]);
				return n-list[--k];
			}

		}
		return 0;
	}

	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		long n= in.nextLong();
		long[] list = new long[(int)Math.pow(10,7)*8+1];
		int i=1;
		long j=0;
		while (j<=n){
			j=(long)i*(i+1)/2;
			list[i++]=j;
		}

		//System.out.println(Arrays.toString(list));

		System.out.println(infinite(n,i,list));
	}
}


///package main;

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

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

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

    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void run() throws Exception {
        long n = nl();
        //long[] pos = new long[100];
        long[] pos = new long[10000000 * 5];
        pos[0] = 1;

        for(int i=1; i<pos.length; i++) {
            pos[i] = pos[i - 1] + (long)i;
        }

        //pl(Arrays.toString(pos));
        int idx = Arrays.binarySearch(pos, n);
        if(idx < 0) {idx += 2; idx = -idx;}
        long element = pos[idx];
        pl(n - element + 1L);
    }

    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

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

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

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

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


import java.util.Scanner;
public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		long num1;
		long num2;
		long div;
		long Final;
		Scanner input= new Scanner(System.in);
	num1=input.nextLong();
	num2=input.nextLong();

		if(num1 % 2==0){
			div= num1/2;

		}
		else {
			div=num1/2+1;
		}
		if(num2<=div){
		Final=2*num2-1;
		}
		else{
			Final=2*(num2-div);
		}

		System.out.println(Final+"");

		}

	}


public class OddEven {
	public static void main(String[] args) {
		int n=7;
		int k=7;
		int result;
		int mid=n/2;
		//ArrayList<int[]> a=new ArrayList<int[]>();
		int[] a=new int[100000000];
		if (n%2==0){

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

			a[i]=(2*i)+1;
		}
		for (int i=1; i<=mid; i++){
			a[i+(mid-1)]=2*i;
			}
		}
		else {
			for (int i=0; i<mid+1; i++){
				a[i]=(2*i)+1;
			}
			for(int i=1; i<=mid; i++){
				a[i+mid]=2*i;
				}
		}
		result=a[k-1];
		System.out.println(result);

	}

}


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

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

        Scanner s=new Scanner(System.in);
        long n=s.nextLong();

 long k=s.nextLong();
 StringBuffer sb=new StringBuffer();
 for(int i=1;i<=n;i++){
     if(i%2!=0){
         sb.append(i);
     }
 }for(int i=2;i<=n;i++){
     if(i%2==0){
         sb.append(i);
     }
 }System.out.println(sb.charAt((int)(k-1)));

}}


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

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

		InputStream inputStream = System.in;
		InputReader sc = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(System.out);
		long n = sc.nextLong();
		if (n % 2 != 0)
			++n;
		long k = sc.nextLong();
		int e[] = new int[(int) (n / 2)];
		int o[] = new int[(int) (n / 2)];

		int c = 0;
		for (int i = 1; i <= n; i = i + 2) {
			o[c] = i;
			++c;
		}

		c = 0;
		for (int i = 2; i <= n; i = i + 2) {
			e[c] = i;
			++c;
		}
		if (k <= n / 2)
			System.out.println(o[(int) (k - 1)]);
		else
			System.out.println(e[(int) (k - n / 2 - 1)]);

	}

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

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

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

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

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

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

	}

	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 print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
				}
				writer.print(objects[i]);
			}
		}

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

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

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

}