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

        Scanner input = new Scanner(System.in);

        int n = input.nextInt(), counter = 0;
        String str = input.next();

        boolean already_copied = false;

        for (int i = 0; i < n; ++i)
        {
            if (i == n-1)
                counter++;
            else
            {
                int temp_counter = 1, j = i;
                while (j < n-1 && str.charAt(j) == str.charAt(j+1))
                {
                    temp_counter++;
                    j++;
                }
                if (j != i)
                {
                    i += (temp_counter % 2 == 0) ? temp_counter - 1 : temp_counter - 2;
                    counter = counter + (temp_counter / 2) + 1;
                }

                else if (!already_copied && can_be_copied(str, i) && i != 0)
                {
                    counter++;
                    i = i * 2 - 1;
                    already_copied = true;
                }
                else
                    counter++;
            }

        }
        System.out.println(counter);
    }

    public static boolean can_be_copied(String str, int end_position)
    {
        int temp = end_position;
        for (int i = 0; i < end_position; i++, temp++)
        {
            if ( str.charAt(i) != str.charAt(temp) )
                return false;
        }
        return true;
    }

}


import java.util.*;

public class B{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        int max = n;
        for(int i = 0; i <= n/2; i++){
            //String sub1 = s.substring(0, i);
            System.out.println("sub1: "+sub1);
            //String sub2 = s.substring(i, i+sub1.length());
            System.out.println("sub2: "+ sub2);
            if(sub1.equals(sub2)){
                max = Math.min(max, n-sub1.length()+1);
            }
        }
        System.out.println(max);
    }
}


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

 // Oh, Hello there..!!

public class B implements Runnable {

    public void run() {

        InputReader sc = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

		int n=sc.nextInt();
		String s=sc.next();

		int half = s.length()/2;

		while(half>=1)
		{
			//out.println(s.substring(0,half)+"   "+s.substring(half,half*2));
			if(s.substring(0,half).equals(s.substring(half,half*2)))
				break;
			half--;
		}

		out.println(n-half+(half==0?:0:1));

        out.close();
    }

//========================================================

	static class Pair
	{
		int a,b;
		Pair(int aa,int bb)
		{
			a=aa;
			b=bb;
		}
	}

	static int sa(int a[],InputReader sc)
	{
		int x=Integer.MAX_VALUE;
		for(int i=0;i<a.length;i++)
		{
			a[i]=sc.nextInt();
			x = Math.min(x,a[i]);
		}
		return x;
	}

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        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 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 String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

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

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

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

    public static void main(String args[]) throws Exception {
        new Thread(null, new B(),"Main",1<<27).start();
    }
}


import java.util.*;
public class String_Typing {

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

		char[] arr = str.toCharArray();
		if(arr.length == 1 )
			System.out.println(1);
		else
		{
		int op = arr.length;

		String match = arr[0]+""+arr[1];
		int Endindex = -1,startIndex=-1;
		for(int i = 2; i < arr.length;i++)
		{
			for(int j = 0 ; j < match.length();j++)
			{
				if(i+j < arr.length)
				if(match.charAt(j) == arr[i+j])
				{
					if(j == match.length() -1)
					{
						startIndex = i;
						Endindex = i+j;
						match+=""+arr[i];
						break;
					}
					continue;
				}
				else {
					match+=""+arr[i];
					break;
				}
			}
		}
		}
		int duplicates = Endindex +1 - startIndex;

		System.out.println(op-duplicates+1);

	}

}


import java.util.Scanner;

public class A515A{
 public static void main(String args[]){
   Scanner in = new Scanner(System.in);
   int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();

   if(s < a+b || (s - a - b )% 2 == 1)
       System.out.println("No");
   else
       System.out.println("Yes");
 }
}


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

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int s = sc.nextInt();
		int sum = Math.abs(a) + Math.abs(b);
		if (s < sum) {
			System.out.println("No");
			return;
		}
		System.out.println(sum % 2 == s % 2 ? "Yes" : "No");
	}

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

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

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;

		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

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

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

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

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

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

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

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


public class HelloWorld{

     public static void main(String []args){
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        String[] tokens = line.split("\\s+");
        if(Math.abs(Integer.parseInt(tokens[0])) + Math.abs(Integer.parseInt(tokens[1])) <=Integer.parseInt(tokens[2])){
            if((Integer.parseInt(tokens[0]) + Integer.parseInt(tokens[1])) % 2 ==0 && Integer.parseInt(tokens[2]) %2==0){
                System.out.println("Yes");
            }else if((Integer.parseInt(tokens[0]) + Integer.parseInt(tokens[1])) % 2 ==1 && Integer.parseInt(tokens[2]) %2==1){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            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 javaapplication73;

import java.util.Scanner;

/**
 *
 * @author HIMANSHU
 */
public class JavaApplication73 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
       int  a =s.nextInt();
        int  b=s.nextInt();
        int stp=s.nextInt();
         if((a+b)<stp)
        {
            System.out.println("No");
        }
        else
         {

        if(a==0&&b==0)
        {
            System.out.println("Yes");
        }
        else
        {
        if((stp)==(a+b))
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }

        if((a+b)>stp)
        {
            if(stp%2==0)
            {
                System.out.println("Yes");
            }
            else
            {
                System.out.println("No");
            }
        }
        }

    }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import javafx.util.Pair;
import sun.swing.icon.SortArrowIcon;
//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//String tooMuchCodeForASmallTask = br.readLine();
public class ProblemSolving {

    public static void main(String[] args) throws IOException{
        ArrayList<Pair<Character,Integer > > arr = new ArrayList<>();
        arr.add(new Pair('A',0));
        arr.add(new Pair('B',0));
        arr.add(new Pair('C',0));
        String input ;
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        for(int i =0 ; i < 3;i++){
            input = bf.readLine();
            int index1 = (int)input.charAt(0)-65;
            int index2 = (int)input.charAt(2)-65;
            if(input.charAt(1)=='>'){
                arr.set(index1, new Pair(arr.get(index1).getKey(),arr.get(index1).getValue()+2));
            }else{
                arr.set(index2, new Pair(arr.get(index2).getKey(),arr.get(index2).getValue()+2));
            }

        }
        helloThere(arr);

    }
    public static void helloThere(ArrayList<Pair<Character,Integer>> s){
        for(int i =0 ; i < 3 ; i++){
            for(int j =0 ; j < 2 ;j++){
                if (s.get(j).getValue()>s.get(j+1).getValue()){
                    Collections.swap(s, j, j+1);
                }
            }
        }
        System.out.println(s.get(0).getKey()+""+s.get(1).getKey()+""+s.get(2).getKey());
    }
}


package testinggg;

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

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

    static class coins {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            String arr[] = new String[3];
            Integer letter[] = new Integer[3];
            for (int i = 0; i < 3; i++) {
                arr[i] = in.next();
                letter[i] = 0;
            }

            for (int i = 0; i < 3; i++) {
                if (arr[i].charAt(1) == '>') {
                    letter[(int) (arr[i].charAt(0)) % 65] += 1;
                    letter[(int) (arr[i].charAt(2)) % 65] -= 1;
                } else {
                    letter[(int) (arr[i].charAt(0)) % 65] -= 1;
                    letter[(int) (arr[i].charAt(2)) % 65] += 1;
                }

            }
            //out.println("letter 0 is "+letter[0]+"letter 1 is "+letter[1]);
            if (Math.abs(letter[0]) + Math.abs(letter[1]) + Math.abs(letter[2]) == 4) {
                String ans = Arrays.toString(letter);
                //out.println(ans);
                if (ans.equals("[2, 0, -2]")) out.println("CBA");
                else if (ans.equals("[2, -2, 0]")) out.print("BCA");
                else if (ans.equals("[-2, 0, 2]")) out.print("ABC");
                else if (ans.equals("[-2, 2, 0]")) out.print("ACB");
                else if (ans.equals("[0, 2, -2]")) out.print("CAB");
                else if (ans.equals(["0, -2, 2]")) out.print("BAC");
            } else {
                out.print("Impossible");
            }
        }

    }
}


public class Coins {
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		String r=in.next();
		String s=in.next();
		String t=in.next();

		int count1=0,count2=0,count3=0;

		if(r.charAt(1)=='>')
			r=r.substring(0,0)+'1'+r.substring(1);
			else
		 r=r.substring(0,2)+'1';

		if(s.charAt(1)=='>')
			s=s.substring(0,0)+'1'+s.substring(1);
			else
		 s=s.substring(0,2)+'1';

		if(t.charAt(1)=='>')
			t=t.substring(0,0)+'1'+t.substring(1);
			else
		 t=t.substring(0,2)+'1';

		if(r.contains("A"))
			count1++;
		if(s.contains("A"))
			count1++;
		if(t.contains("A"))
		    count1++;
		if(r.contains("B"))
			count2++;
		if(s.contains("B"))
			count2++;
		if(t.contains("B"))
			count2++;
		if(r.contains("C"))
			count3++;
		if(s.contains("C"))
			count3++;
		if(t.contains("C"))
			count3++;

		if(count1==count2||count2==count3||count3==count1)
			System.out.println("Impossible");
		else
		{

			if (count1 == 0 && count2 == 1 && count3 == 2) {
				System.out.print("C");
				System.out.print("B");
				System.out.print("A");
			} else if (count1 == 0 && count2 == 2 && count3 == 1) {
				System.out.print("B");
				System.out.print("C");
				System.out.print("A");
			} else if (count1 == 1 && count2 == 0 && count3 == 2) {
				System.out.print("C");
				System.out.print("A");
				System.out.print("B");
			} else if (count1 == 2 && count2 == 0 && count3 == 1) {
				System.out.print("A");
				System.out.print("C");
				System.out.print("B");
			} else if (count1 == 1 && count2 == 2 && count3 == 0) {
				System.out.print("B");
				System.out.print("A");
				System.out.print("C");
			} else if (count1 == 2 && count2 == 1 && count3 == 0) {
				System.out.print("A");
				System.out.print("B");
				System.out.print("C");
			}
		}
	}
}


// "static void main" must be defined in a public class.
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr =new int[3];
        char[] ans = new char[3];
        for(int i=0; i < 3; i++ ) {
          String s = sc.next();
          if(s.indexOf(">") !=-1 ){
            arr[s.charAt(0)-'A']++;
          }
          else {
            arr[s.charAt(2)-'A']++;
          }
        }
        if(arr[0] == arr[1] || arr[0] == arr[2] || arr[1]== arr[2] ){
          System.out.println("Impossible");
        }
        else{
          for(int i=0; i < 3;i++){
            ans[arr[i]] = (char) ('A' + i) ;
          }
        }
        String ans1 = new String(ans);
        System.out.println(ans1);

    }
}


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

public class Test2a {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = in.nextInt();
		}

		// 找出和不为0的子字符串
		// 如果全是0 为NO 如果只有一个不为0 也是NO
		List<int[]> list = new ArrayList<int[]>();
		int sum = 0;
		for (int i = 0; i < arr.length; i++) {
			if (sum == 0) {
				sum += arr[i];
				if (sum != 0) {
					list.add(new int[] { 1, i + 1 });
				}
			} else if (arr[i] != 0) {
				list.add(new int[] { i + 1, i + 1 });
			} else {
				// 如果是0，和上一个数组合并
				if (!list.isEmpty()) {
					int[] indexs = list.get(list.size() - 1);
					indexs[1] = i + 1;
				}
			}
		}
		if (list.size() > 1) {
			System.out.println("YES");
			System.out.println(list.size());
			for (int[] subIndexs : list) {
				System.out.println(subIndexs[0] + " " + subIndexs[1]);
			}
		} else {
			System.out.println("NO");
		}
	}

}


import java.util.Scanner;

/**
 * Created by USER on 1/6/2017.
 */
public class Div2_2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[][] arr=new String[4][4];
        String l="";
        for (int i = 0; i < 4; i++) {
            l=scanner.next();
            for (int j = 0; j < 4; j++) {
                arr[i][j]=""+l.charAt(j);
            }
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 2; j++) {
                if(arr[i][j].equals("x")){
                    if(arr[i][j+1].equals("x")) {
                        if (arr[i][j + 2].equals(".")) {
                            System.out.println("YES");
                            return;
                        }
                    }else if(arr[i][j+1].equals(".")){
                        if(arr[i][j+2].equals("x")){
                            System.out.println("YES");
                            return;
                        }
                    }
                }else if(arr[i][j].equals(".")){
                    if(arr[i][j+1].equals("x")&&arr[i][j+2].equals("x")){
                        System.out.println("YES");
                        return;
                    }
                }
            }
        }
        for (int j = 0; j < 4; j++) {
            for (int i = 0; i < 2; i++) {
                if(arr[j][i].equals("x")){
                    if(arr[j+1][i].equals("x")) {
                        if (arr[j+2][i].equals(".")) {
                            System.out.println("YES");
                            return;
                        }
                    }else if(arr[j+1][i].equals(".")){
                        if(arr[j+2][i].equals("x")){
                            System.out.println("YES");
                            return;
                        }
                    }
                }else if(arr[j][i].equals(".")){
                    if(arr[j+1][i].equals("x")&&arr[j+2][i].equals("x")){
                        System.out.println("YES");
                        return;
                    }
                }
            }
        }
        if(arr[0][0].equals("x")){
            if(arr[1][1].equals("x")) {
                if (arr[2][2].equals(".")) {
                    System.out.println("YES");
                    return;
                }
            }else if(arr[1][1].equals(".")){
                if(arr[2][2].equals("x")){
                    System.out.println("YES");
                    return;
                }
            }
        }else if(arr[0][0].equals(".")){
            if(arr[1][1].equals("x")&&arr[2][2].equals("x")){
                System.out.println("YES");
                return;
            }
        }
        if(arr[1][1].equals("x")){
            if(arr[2][2].equals("x")) {
                if (arr[3][3].equals(".")) {
                    System.out.println("YES");
                    return;
                }
            }else if(arr[2][2].equals(".")){
                if(arr[3][3].equals("x")){
                    System.out.println("YES");
                    return;
                }
            }
        }else if(arr[1][1].equals(".")){
            if(arr[2][2].equals("x")&&arr[3][3].equals("x")){
                System.out.println("YES");
                return;
            }
        }
        if(arr[1][0].equals("x")){
            if(arr[2][1].equals("x")) {
                if (arr[3][2].equals(".")) {
                    System.out.println("YES");
                    return;
                }
            }else if(arr[2][1].equals(".")){
                if(arr[3][2].equals("x")){
                    System.out.println("YES");
                    return;
                }
            }
        }else if(arr[1][0].equals(".")){
            if(arr[2][1].equals("x")&&arr[3][2].equals("x")){
                System.out.println("YES");
                return;
            }
        }
        if(arr[0][1].equals("x")){
            if(arr[1][2].equals("x")) {
                if (arr[2][3].equals(".")) {
                    System.out.println("YES");
                    return;
                }
            }else if(arr[1][2].equals(".")){
                if(arr[2][3].equals("x")){
                    System.out.println("YES");
                    return;
                }
            }
        }else if(arr[0][1].equals(".")){
            if(arr[1][2].equals("x")&&arr[2][3].equals("x")){
                System.out.println("YES");
                return;
            }
        }
        arr=flipH(arr);
        arr=flipV(arr);
        if(arr[0][0].equals("x")){
            if(arr[1][1].equals("x")) {
                if (arr[2][2].equals(".")) {
                    System.out.println("YES");
                    return;
                }
            }else if(arr[1][1].equals(".")){
                if(arr[2][2].equals("x")){
                    System.out.println("YES");
                    return;
                }
            }
        }else if(arr[0][0].equals(".")){
            if(arr[1][1].equals("x")&&arr[2][2].equals("x")){
                System.out.println("YES");
                return;
            }
        }
        if(arr[1][1].equals("x")){
            if(arr[2][2].equals("x")) {
                if (arr[3][3].equals(".")) {
                    System.out.println("YES");
                    return;
                }
            }else if(arr[2][2].equals(".")){
                if(arr[3][3].equals("x")){
                    System.out.println("YES");
                    return;
                }
            }
        }else if(arr[1][1].equals(".")){
            if(arr[2][2].equals("x")&&arr[3][3].equals("x")){
                System.out.println("YES");
                return;
            }
        }
        if(arr[1][0].equals("x")){
            if(arr[2][1].equals("x")) {
                if (arr[3][2].equals(".")) {
                    System.out.println("YES");
                    return;
                }
            }else if(arr[2][1].equals(".")){
                if(arr[3][2].equals("x")){
                    System.out.println("YES");
                    return;
                }
            }
        }else if(arr[1][0].equals(".")){
            if(arr[2][1].equals("x")&&arr[3][2].equals("x")){
                System.out.println("YES");
                return;
            }
        }
        if(arr[0][1].equals("x")){
            if(arr[1][2].equals("x")) {
                if (arr[2][3].equals(".")) {
                    System.out.println("YES");
                    return;
                }
            }else if(arr[1][2].equals(".")){
                if(arr[2][3].equals("x")){
                    System.out.println("YES");
                    return;
                }
            }
        }else if(arr[0][1].equals(".")){
            if(arr[1][2].equals("x")&&arr[2][3].equals("x")){
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");

    }static String[][] flipH(String[][] a) {
        String[][] b = new String[a.length][a[0].length];
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[0].length; j++) {
                b[i][j] = a[i][a[0].length - j - 1];
            }
        }
        return b;
    }

    static String[][] flipV(String[][] a) {
        String[][] b = new String[a.length][a[0].length];
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[0].length; j++) {
                b[i][j] = a[a.length - i - 1][j];
            }
        }
        return b;
    }
}


gorithm;

import java.util.*;

public class Solution {
    private static boolean
    up(char[][] board, int count, int i, int j) {
        int I = i;
        int J = j - count;
        if (J < 0 || J > 3) {
            return false;
        }
        return board[I][J] == 'x';
    }

    private static boolean
    left(char[][] board, int count, int i, int j) {
        int I = i - count;
        int J = j;
        if (I < 0 || I > 3) {
            return false;
        }
        return board[I][J] == 'x';
    }

    private static boolean
    diagonal(char[][] board, int rotation, int count, int i, int j) {
        int incrementI = -10000;
        int incrementJ = -10000;
        switch (rotation) {
            case 1:
                incrementI = 1;
                incrementJ = 1;
                break;
            case 2:
                incrementI = 1;
                incrementJ = -1;
                break;
        }
        int I;
        int J;
        I = i + incrementI * count;
        J = j + incrementJ * count;
        if (I < 0 || I > 3 || J < 0 || J > 3) {
            return false;
        }
        return board[I][J] == 'x';
    }

    private static boolean checkHorizontal(char[][] board, int i, int j) {
        boolean case1, case2, case3;
        case1 = up(board, 2, i, j) &&
                up(board, 1, i, j);
        case2 = up(board, 1, i, j) &&
                up(board, -1, i, j);
        case3 = up(board, -1, i, j) &&
                up(board, -2, i, j);
        return case1 || case2 || case3;
    }

    private static boolean checkVertical(char[][] board, int i, int j) {
        boolean case1, case2, case3;
        case1 = left(board, 2, i, j) &&
                left(board, 1, i, j);
        case2 = left(board, 1, i, j) &&
                left(board, -1, i, j);
        case3 = left(board, -1, i, j) &&
                left(board, -2, i, j);
        return case1 || case2 || case3;
    }

    private static boolean checkDiagonal(char[][] board, int i, int j) {
        for (int rotation = 1; rotation <= 2; rotation++) {
            boolean case1, case2, case3;
            case1 = diagonal(board, rotation, 2, i, j) &&
                    diagonal(board, rotation, 1, i, j);
            case2 = diagonal(board, rotation, 1, i, j) &&
                    diagonal(board, rotation, -1, i, j);
            case3 = diagonal(board, rotation, -1, i, j) &&
                    diagonal(board, rotation, -2, i, j);
            if (case1 || case2 || case3) {
                return true;
            }
        }
        return false;
    }

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

        for (int i = 0; i < 4; i++) {
            String input = in.nextLine().trim();
            for (int j = 0; j < 4; j++) {
                board[i][j] = input.charAt(j);
            }
        }

        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (board[i][j] != '.') {
                    // Already placed crosses or noughts
                    continue;
                }
                if (checkDiagonal(board, i, j) ||
                        checkHorizontal(board, i, j) ||
                        checkVertical(board, i, j)) {
                    System.out.println("YES");
                    return;
                }
            }
        }

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class B {

  static char[][] grid;
  static int n, m;

  static boolean valid(int i, int j)
  {
    return i != -1 && j != -1 && i != n && j != m ;
  }

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

    Scanner sc=new Scanner(System.in);
    PrintWriter out=new PrintWriter(System.out);

    grid=new char[4][4];
    n=4;
    m=4;
    for (int i = 0; i < 4; i++) {
     String s=sc.nextLine();
     // System.out.println(s);
      for (int j = 0; j <4; j++) {
        grid[i][j]=s.charAt(j);
      }

    }

    boolean can=false;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j <4 ; j++) {
        if(grid[i][j]=='x'||grid[i][j]=='.') {
          if (valid(i, j + 1) && grid[i][j + 1] == 'x' && valid(i, j - 1) && grid[i][j - 1] == 'x')
            can = true;
          if (valid(i, j + 1) && grid[i][j + 1] == 'x' && valid(i, j + 2) && grid[i][j + 2] == 'x')
            can = true;

          if (valid(i, j - 1) && grid[i][j - 1] == 'x' && valid(i, j - 2) && grid[i][j - 2] == 'x')
            can = true;

          if (valid(i + 1, j) && grid[i + 1][j] == 'x' && valid(i - 1, j) && grid[i - 1][j] == 'x')
            can = true;

          if (valid(i + 1, j) && grid[i + 1][j] == 'x' && valid(i + 2, j) && grid[i + 2][j] == 'x')
            can = true;

          if (valid(i - 1, j) && grid[i - 1][j] == 'x' && valid(i - 2, j) && grid[i - 2][j] == 'x')
            can = true;

          if (valid(i + 1, j + 1) && grid[i + 1][j + 1] == 'x' && valid(i - 1, j - 1) && grid[i - 1][j - 1] == 'x')
            can = true;

          if (valid(i + 1, j + 1) && grid[i + 1][j + 1] == 'x' && valid(i + 2, j + 2) && grid[i + 2][j + 2] == 'x')
            can = true;

          if (valid(i - 1, j - 1) && grid[i - 1][j - 1] == 'x' && valid(i - 2, j - 2) && grid[i - 2][j - 2] == 'x')
            can = true;

          if (valid(i + 1, j -1) && grid[i + 1][j - 1] == 'x' && valid(i -1 1, j +1) && grid[i - 1][j +1] == 'x')
            can = true;

          if (valid(i + 1, j - 1) && grid[i + 1][j -1] == 'x' && valid(i + 2, j - 2) && grid[i + 2][j - 2] == 'x')
            can = true;

          if (valid(i - 1, j + 1) && grid[i - 1][j + 1] == 'x' && valid(i - 2, j + 2) && grid[i - 2][j + 2] == 'x')
            can = true;

          if (can) break;
        }
      }
    }
if(can) System.out.println("YES");
    else System.out.println("NO");

    out.flush();

  }

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

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

  }
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;

public class C_432
{
	public static final long[] POWER2 = generatePOWER2();
	public static final IteratorBuffer<Long> ITERATOR_BUFFER_PRIME = new IteratorBuffer<>(streamPrime(1000000).iterator());
	private static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
	private static StringTokenizer stringTokenizer = null;
	private static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

	interface BiFunctionResult<Type0, Type1, TypeResult>
	{
		TypeResult apply(Type0 x0, Type1 x1, TypeResult x2);
	}

	static class Array<Type> implements Iterable<Type>
	{
		private final Object[] array;

		public Array(int size)
		{
			this.array = new Object[size];
		}

		public Array(int size, Type element)
		{
			this(size);
			Arrays.fill(this.array, element);
		}

		public Array(Array<Type> array, Type element)
		{
			this(array.size() + 1);
			for (int index = 0; index < array.size(); index++)
			{
				set(index, array.get(index));
			}
			set(size() - 1, element);
		}

		public Array(List<Type> list)
		{
			this(list.size());
			int index = 0;
			for (Type element : list)
			{
				set(index, element);
				index += 1;
			}
		}

		public Type get(int index)
		{
			return (Type) this.array[index];
		}

		public Array set(int index, Type value)
		{
			this.array[index] = value;
			return this;
		}

		public int size()
		{
			return this.array.length;
		}

		public List<Type> toList()
		{
			List<Type> result = new ArrayList<>();
			for (Type element : this)
			{
				result.add(element);
			}
			return result;
		}

		@Override
		public Iterator<Type> iterator()
		{
			return new Iterator<Type>()
			{
				int index = 0;

				@Override
				public boolean hasNext()
				{
					return this.index < size();
				}

				@Override
				public Type next()
				{
					Type result = Array.this.get(index);
					index += 1;
					return result;
				}
			};
		}

		@Override
		public String toString()
		{
			return "[" + C_432.toString(this, ", ") + "]";
		}
	}

	static class BIT
	{
		private static int lastBit(int index)
		{
			return index & -index;
		}

		private final long[] tree;

		public BIT(int size)
		{
			this.tree = new long[size];
		}

		public void add(int index, long delta)
		{
			index += 1;
			while (index <= this.tree.length)
			{
				tree[index - 1] += delta;
				index += lastBit(index);
			}
		}

		private long prefix(int end)
		{
			long result = 0;
			while (end > 0)
			{
				result += this.tree[end - 1];
				end -= lastBit(end);
			}
			return result;
		}

		public int size()
		{
			return this.tree.length;
		}

		public long sum(int start, int end)
		{
			return prefix(end) - prefix(start);
		}
	}

	static abstract class Edge<TypeVertex extends Vertex<TypeVertex, TypeEdge>, TypeEdge extends Edge<TypeVertex, TypeEdge>>
	{
		public final TypeVertex vertex0;
		public final TypeVertex vertex1;
		public final boolean bidirectional;

		public Edge(TypeVertex vertex0, TypeVertex vertex1, boolean bidirectional)
		{
			this.vertex0 = vertex0;
			this.vertex1 = vertex1;
			this.bidirectional = bidirectional;
			this.vertex0.edges.add(getThis());
			if (this.bidirectional)
			{
				this.vertex1.edges.add(getThis());
			}
		}

		public TypeVertex other(Vertex<TypeVertex, TypeEdge> vertex)
		{
			TypeVertex result;
			if (vertex0 == vertex)
			{
				result = vertex1;
			}
			else
			{
				result = vertex0;
			}
			return result;
		}

		public abstract TypeEdge getThis();

		public void remove()
		{
			this.vertex0.edges.remove(getThis());
			if (this.bidirectional)
			{
				this.vertex1.edges.remove(getThis());
			}
		}

		@Override
		public String toString()
		{
			return this.vertex0 + "->" + this.vertex1;
		}
	}

	public static class EdgeDefault<TypeVertex extends Vertex<TypeVertex, EdgeDefault<TypeVertex>>> extends Edge<TypeVertex, EdgeDefault<TypeVertex>>
	{
		public EdgeDefault(TypeVertex vertex0, TypeVertex vertex1, boolean bidirectional)
		{
			super(vertex0, vertex1, bidirectional);
		}

		@Override
		public EdgeDefault<TypeVertex> getThis()
		{
			return this;
		}
	}

	public static class Vertex<TypeVertex extends Vertex<TypeVertex, TypeEdge>, TypeEdge extends Edge<TypeVertex, TypeEdge>> implements Comparable<Vertex<? super TypeVertex, ? super TypeEdge>>
	{
		public static <TypeVertex extends Vertex<TypeVertex, TypeEdge>, TypeEdge extends Edge<TypeVertex, TypeEdge>> void depthFirstSearch(
				Array<TypeVertex> vertices,
				int indexVertexStart,
				BiConsumer<TypeVertex, TypeEdge> functionPreVisit,
				BiConsumer<TypeVertex, TypeEdge> functionInVisit,
				BiConsumer<TypeVertex, TypeEdge> functionPostVisit
		)
		{
			TypeVertex vertexTo;
			TypeEdge edgeTo;
			boolean[] isOnStack = new boolean[vertices.size()];
			Stack<Operation> stackOperations = new Stack<>();
			Stack<TypeVertex> stackVertices = new Stack<>();
			Stack<TypeEdge> stackEdges = new Stack<>();

			TypeVertex vertexStart = vertices.get(indexVertexStart);
			stackOperations.push(Operation.EXPAND);
			stackVertices.push(vertexStart);
			stackEdges.push(null);
			isOnStack[vertexStart.index] = true;
			while (!stackOperations.isEmpty())
			{
				Operation operation = stackOperations.pop();
				TypeVertex vertex = stackVertices.pop();
				TypeEdge edge = stackEdges.pop();
				switch (operation)
				{
					case INVISIT:
						functionInVisit.accept(vertex, edge);
						break;
					case POSTVISIT:
						functionPostVisit.accept(vertex, edge);
						break;
					case EXPAND:
						stackOperations.push(Operation.POSTVISIT);
						stackVertices.push(vertex);
						stackEdges.push(edge);
						Integer indexTo = null;
						for (int index = 0; indexTo == null && index < vertex.edges.size(); index++)
						{
							edgeTo = vertex.edges.get(index);
							vertexTo = edgeTo.other(vertex);
							if (!isOnStack[vertexTo.index])
							{
								indexTo = index;
							}
						}
						if (indexTo != null)
						{
							edgeTo = vertex.edges.get(indexTo);
							vertexTo = edgeTo.other(vertex);
							stackOperations.push(Operation.EXPAND);
							stackVertices.push(vertexTo);
							stackEdges.push(edgeTo);
							isOnStack[vertexTo.index] = true;
							for (int index = indexTo + 1; index < vertex.edges.size(); index++)
							{
								edgeTo = vertex.edges.get(index);
								vertexTo = edgeTo.other(vertex);
								if (!isOnStack[vertexTo.index])
								{
									stackOperations.push(Operation.INVISIT);
									stackVertices.push(vertex);
									stackEdges.push(edge);
									stackOperations.push(Operation.EXPAND);
									stackVertices.push(vertexTo);
									stackEdges.push(edgeTo);
									isOnStack[vertexTo.index] = true;
								}
							}
						}
						functionPreVisit.accept(vertex, edge);
						break;
				}
			}
		}

		public static <TypeVertex extends Vertex<TypeVertex, TypeEdge>, TypeEdge extends Edge<TypeVertex, TypeEdge>> void depthFirstSearch(
				Array<TypeVertex> vertices,
				int indexVertexStart,
				Consumer<TypeVertex> functionPreVisit,
				Consumer<TypeVertex> functionInVisit,
				Consumer<TypeVertex> functionPostVisit
		)
		{
			depthFirstSearch(
					vertices,
					indexVertexStart,
					(vertex, edge) -> functionPreVisit.accept(vertex),
					(vertex, edge) -> functionInVisit.accept(vertex),
					(vertex, edge) -> functionPostVisit.accept(vertex)
			);
		}

		public static <TypeVertex extends Vertex<TypeVertex, TypeEdge>, TypeEdge extends Edge<TypeVertex, TypeEdge>, TypeResult> TypeResult breadthFirstSearch(
				TypeVertex vertex,
				TypeEdge edge,
				BiFunctionResult<TypeVertex, TypeEdge, TypeResult> function,
				Array<Boolean> visited,
				FIFO<TypeVertex> verticesNext,
				FIFO<TypeEdge> edgesNext,
				TypeResult result
		)
		{
			if (!visited.get(vertex.index))
			{
				visited.set(vertex.index, true);
				result = function.apply(vertex, edge, result);
				for (TypeEdge edgeNext : vertex.edges)
				{
					TypeVertex vertexNext = edgeNext.other(vertex);
					if (!visited.get(vertexNext.index))
					{
						verticesNext.push(vertexNext);
						edgesNext.push(edgeNext);
					}
				}
			}
			return result;
		}

		public static <TypeVertex extends Vertex<TypeVertex, TypeEdge>, TypeEdge extends Edge<TypeVertex, TypeEdge>, TypeResult> TypeResult breadthFirstSearch(
				Array<TypeVertex> vertices,
				int indexVertexStart,
				BiFunctionResult<TypeVertex, TypeEdge, TypeResult> function,
				TypeResult result
		)
		{
			Array<Boolean> visited = new Array<>(vertices.size(), false);
			FIFO<TypeVertex> verticesNext = new FIFO<>();
			verticesNext.push(vertices.get(indexVertexStart));
			FIFO<TypeEdge> edgesNext = new FIFO<>();
			edgesNext.push(null);
			while (!verticesNext.isEmpty())
			{
				result = breadthFirstSearch(verticesNext.pop(), edgesNext.pop(), function, visited, verticesNext, edgesNext, result);
			}
			return result;
		}

		public final int index;
		public final List<TypeEdge> edges;

		public Vertex(int index)
		{
			this.index = index;
			this.edges = new ArrayList<>();
		}

		@Override
		public int compareTo(Vertex<? super TypeVertex, ? super TypeEdge> that)
		{
			return Integer.compare(this.index, that.index);
		}

		@Override
		public String toString()
		{
			return "" + this.index;
		}

		enum Operation
		{
			INVISIT, POSTVISIT, EXPAND
		}
	}

	public static class VertexDefault<TypeEdge extends Edge<VertexDefault<TypeEdge>, TypeEdge>> extends Vertex<VertexDefault<TypeEdge>, TypeEdge>
	{
		public VertexDefault(int index)
		{
			super(index);
		}
	}

	public static class VertexDefaultDefault extends Vertex<VertexDefaultDefault, EdgeDefaultDefault>
	{
		public static Array<VertexDefaultDefault> vertices(int n)
		{
			Array<VertexDefaultDefault> result = new Array<>(n);
			for (int index = 0; index < n; index++)
			{
				result.set(index, new VertexDefaultDefault(index));
			}
			return result;
		}

		public VertexDefaultDefault(int index)
		{
			super(index);
		}
	}

	public static class EdgeDefaultDefault extends Edge<VertexDefaultDefault, EdgeDefaultDefault>
	{
		public EdgeDefaultDefault(VertexDefaultDefault vertex0, VertexDefaultDefault vertex1, boolean bidirectional)
		{
			super(vertex0, vertex1, bidirectional);
		}

		@Override
		public EdgeDefaultDefault getThis()
		{
			return this;
		}
	}

	public static class Tuple2<Type0, Type1>
	{
		public final Type0 v0;
		public final Type1 v1;

		public Tuple2(Type0 v0, Type1 v1)
		{
			this.v0 = v0;
			this.v1 = v1;
		}

		@Override
		public String toString()
		{
			return "(" + this.v0 + ", " + this.v1 + ")";
		}
	}

	static class Wrapper<Type>
	{
		public Type value;

		public Wrapper(Type value)
		{
			this.value = value;
		}

		public Type get()
		{
			return this.value;
		}

		public void set(Type value)
		{
			this.value = value;
		}

		@Override
		public String toString()
		{
			return this.value.toString();
		}
	}

	public static class Tuple3<Type0, Type1, Type2>
	{
		public final Type0 v0;
		public final Type1 v1;
		public final Type2 v2;

		public Tuple3(Type0 v0, Type1 v1, Type2 v2)
		{
			this.v0 = v0;
			this.v1 = v1;
			this.v2 = v2;
		}

		@Override
		public String toString()
		{
			return "(" + this.v0 + ", " + this.v1 + ", " + this.v2 + ")";
		}
	}

	public static class Tuple2Comparable<Type0 extends Comparable<? super Type0>, Type1 extends Comparable<? super Type1>> extends Tuple2<Type0, Type1> implements Comparable<Tuple2Comparable<Type0, Type1>>
	{
		public Tuple2Comparable(Type0 v0, Type1 v1)
		{
			super(v0, v1);
		}

		@Override
		public int compareTo(Tuple2Comparable<Type0, Type1> that)
		{
			int result = this.v0.compareTo(that.v0);
			if (result == 0)
			{
				result = this.v1.compareTo(that.v1);
			}
			return result;
		}
	}

	public static class SingleLinkedList<Type>
	{
		public final Type element;
		public SingleLinkedList<Type> next;

		public SingleLinkedList(Type element, SingleLinkedList<Type> next)
		{
			this.element = element;
			this.next = next;
		}

		public void toCollection(Collection<Type> collection)
		{
			if (this.next != null)
			{
				this.next.toCollection(collection);
			}
			collection.add(this.element);
		}
	}

	public static class Node<Type>
	{
		public static <Type> Node<Type> balance(Node<Type> result)
		{
			while (result != null && 1 < Math.abs(height(result.left) - height(result.right)))
			{
				if (height(result.left) < height(result.right))
				{
					Node<Type> right = result.right;
					if (height(right.right) < height(right.left))
					{
						result = new Node<>(result.value, result.left, right.rotateRight());
					}
					result = result.rotateLeft();
				}
				else
				{
					Node<Type> left = result.left;
					if (height(left.left) < height(left.right))
					{
						result = new Node<>(result.value, left.rotateLeft(), result.right);
					}
					result = result.rotateRight();
				}
			}
			return result;
		}

		public static <Type> Node<Type> clone(Node<Type> result)
		{
			if (result != null)
			{
				result = new Node<>(result.value, clone(result.left), clone(result.right));
			}
			return result;
		}

		public static <Type> Node<Type> delete(Node<Type> node, Type value, Comparator<? super Type> comparator)
		{
			Node<Type> result;
			if (node == null)
			{
				result = null;
			}
			else
			{
				int compare = comparator.compare(value, node.value);
				if (compare == 0)
				{
					if (node.left == null)
					{
						result = node.right;
					}
					else
					{
						if (node.right == null)
						{
							result = node.left;
						}
						else
						{
							Node<Type> first = first(node.right);
							result = new Node<>(first.value, node.left, delete(node.right, first.value, comparator));
						}
					}
				}
				else
				{
					if (compare < 0)
					{
						result = new Node<>(node.value, delete(node.left, value, comparator), node.right);
					}
					else
					{
						result = new Node<>(node.value, node.left, delete(node.right, value, comparator));
					}
				}
				result = balance(result);
			}
			return result;
		}

		public static <Type> Node<Type> first(Node<Type> result)
		{
			while (result.left != null)
			{
				result = result.left;
			}
			return result;
		}

		public static <Type> Node<Type> get(Node<Type> node, Type value, Comparator<? super Type> comparator)
		{
			Node<Type> result;
			if (node == null)
			{
				result = null;
			}
			else
			{
				int compare = comparator.compare(value, node.value);
				if (compare == 0)
				{
					result = node;
				}
				else
				{
					if (compare < 0)
					{
						result = get(node.left, value, comparator);
					}
					else
					{
						result = get(node.right, value, comparator);
					}
				}
			}
			return result;
		}

		public static <Type> Node<Type> head(Node<Type> node, Type value, Comparator<? super Type> comparator)
		{
			Node<Type> result;
			if (node == null)
			{
				result = null;
			}
			else
			{
				int compare = comparator.compare(value, node.value);
				if (compare == 0)
				{
					result = node.left;
				}
				else
				{
					if (compare < 0)
					{
						result = head(node.left, value, comparator);
					}
					else
					{
						result = new Node<>(node.value, node.left, head(node.right, value, comparator));
					}
				}
				result = balance(result);
			}
			return result;
		}

		public static int height(Node node)
		{
			return node == null ? 0 : node.height;
		}

		public static <Type> Node<Type> insert(Node<Type> node, Type value, Comparator<? super Type> comparator)
		{
			Node<Type> result;
			if (node == null)
			{
				result = new Node<>(value, null, null);
			}
			else
			{
				int compare = comparator.compare(value, node.value);
				if (compare == 0)
				{
					result = new Node<>(value, node.left, node.right);
					;
				}
				else
				{
					if (compare < 0)
					{
						result = new Node<>(node.value, insert(node.left, value, comparator), node.right);
					}
					else
					{
						result = new Node<>(node.value, node.left, insert(node.right, value, comparator));
					}
				}
				result = balance(result);
			}
			return result;
		}

		public static <Type> Node<Type> last(Node<Type> result)
		{
			while (result.right != null)
			{
				result = result.right;
			}
			return result;
		}

		public static int size(Node node)
		{
			return node == null ? 0 : node.size;
		}

		public static <Type> Node<Type> tail(Node<Type> node, Type value, Comparator<? super Type> comparator)
		{
			Node<Type> result;
			if (node == null)
			{
				result = null;
			}
			else
			{
				int compare = comparator.compare(value, node.value);
				if (compare == 0)
				{
					result = new Node<>(node.value, null, node.right);
				}
				else
				{
					if (compare < 0)
					{
						result = new Node<>(node.value, tail(node.left, value, comparator), node.right);
					}
					else
					{
						result = tail(node.right, value, comparator);
					}
				}
				result = balance(result);
			}
			return result;
		}

		public static <Type> void traverseOrderIn(Node<Type> node, Consumer<Type> consumer)
		{
			if (node != null)
			{
				traverseOrderIn(node.left, consumer);
				consumer.accept(node.value);
				traverseOrderIn(node.right, consumer);
			}
		}

		public final Type value;
		public final Node<Type> left;
		public final Node<Type> right;
		public final int size;
		private final int height;

		public Node(Type value, Node<Type> left, Node<Type> right)
		{
			this.value = value;
			this.left = left;
			this.right = right;
			this.size = 1 + size(left) + size(right);
			this.height = 1 + Math.max(height(left), height(right));
		}

		public Node<Type> rotateLeft()
		{
			Node<Type> left = new Node<>(this.value, this.left, this.right.left);
			return new Node<>(this.right.value, left, this.right.right);
		}

		public Node<Type> rotateRight()
		{
			Node<Type> right = new Node<>(this.value, this.left.right, this.right);
			return new Node<>(this.left.value, this.left.left, right);
		}
	}

	public static class SortedSetAVL<Type> implements SortedSet<Type>
	{
		public Comparator<? super Type> comparator;
		public Node<Type> root;

		private SortedSetAVL(Comparator<? super Type> comparator, Node<Type> root)
		{
			this.comparator = comparator;
			this.root = root;
		}

		public SortedSetAVL(Comparator<? super Type> comparator)
		{
			this(comparator, null);
		}

		public SortedSetAVL(Collection<? extends Type> collection, Comparator<? super Type> comparator)
		{
			this(comparator, null);
			this.addAll(collection);
		}

		public SortedSetAVL(SortedSetAVL<Type> sortedSetAVL)
		{
			this(sortedSetAVL.comparator, Node.clone(sortedSetAVL.root));
		}

		@Override
		public void clear()
		{
			this.root = null;
		}

		@Override
		public Comparator<? super Type> comparator()
		{
			return this.comparator;
		}

		public Type get(Type value)
		{
			Node<Type> node = Node.get(this.root, value, this.comparator);
			return node == null ? null : node.value;
		}

		@Override
		public SortedSetAVL<Type> subSet(Type valueStart, Type valueEnd)
		{
			return tailSet(valueStart).headSet(valueEnd);
		}

		@Override
		public SortedSetAVL<Type> headSet(Type valueEnd)
		{
			return new SortedSetAVL<>(this.comparator, Node.head(this.root, valueEnd, this.comparator));
		}

		@Override
		public SortedSetAVL<Type> tailSet(Type valueStart)
		{
			return new SortedSetAVL<>(this.comparator, Node.tail(this.root, valueStart, this.comparator));
		}

		@Override
		public Type first()
		{
			return Node.first(this.root).value;
		}

		@Override
		public Type last()
		{
			return Node.last(this.root).value;
		}

		@Override
		public int size()
		{
			return this.root == null ? 0 : this.root.size;
		}

		@Override
		public boolean isEmpty()
		{
			return this.root == null;
		}

		@Override
		public boolean contains(Object value)
		{
			return Node.get(this.root, (Type) value, this.comparator) != null;
		}

		@Override
		public Iterator<Type> iterator()
		{
			Stack<Node<Type>> path = new Stack<>();

			return new Iterator<Type>()
			{
				{
					push(SortedSetAVL.this.root);
				}

				public void push(Node<Type> node)
				{
					while (node != null)
					{
						path.push(node);
						node = node.left;
					}
				}

				@Override
				public boolean hasNext()
				{
					return !path.isEmpty();
				}

				@Override
				public Type next()
				{
					if (path.isEmpty())
					{
						throw new NoSuchElementException();
					}
					else
					{
						Node<Type> node = path.peek();
						Type result = node.value;
						if (node.right != null)
						{
							push(node.right);
						}
						else
						{
							do
							{
								node = path.pop();
							}
							while (!path.isEmpty() && path.peek().right == node);
						}
						return result;
					}
				}
			};
		}

		@Override
		public Object[] toArray()
		{
			List<Object> list = new ArrayList<>();
			Node.traverseOrderIn(this.root, list::add);
			return list.toArray();
		}

		@Override
		public <T> T[] toArray(T[] ts)
		{
			throw new UnsupportedOperationException();
		}

		@Override
		public boolean add(Type value)
		{
			int sizeBefore = size();
			this.root = Node.insert(this.root, value, this.comparator);
			return sizeBefore != size();
		}

		@Override
		public boolean remove(Object value)
		{
			int sizeBefore = size();
			this.root = Node.delete(this.root, (Type) value, this.comparator);
			return sizeBefore != size();
		}

		@Override
		public boolean containsAll(Collection<?> collection)
		{
			return collection.stream()
					.allMatch(this::contains);
		}

		@Override
		public boolean addAll(Collection<? extends Type> collection)
		{
			return collection.stream()
					.map(this::add)
					.reduce(true, (x, y) -> x | y);
		}

		@Override
		public boolean retainAll(Collection<?> collection)
		{
			SortedSetAVL<Type> set = new SortedSetAVL<>(this.comparator);
			collection.stream()
					.map(element -> (Type) element)
					.filter(this::contains)
					.forEach(set::add);
			boolean result = size() != set.size();
			this.root = set.root;
			return result;
		}

		@Override
		public boolean removeAll(Collection<?> collection)
		{
			return collection.stream()
					.map(this::remove)
					.reduce(true, (x, y) -> x | y);
		}

		@Override
		public String toString()
		{
			return "{" + C_432.toString(this, ", ") + "}";
		}
	}

	public static class SortedMapAVL<TypeKey, TypeValue> implements SortedMap<TypeKey, TypeValue>
	{
		public final Comparator<? super TypeKey> comparator;
		public final SortedSetAVL<Entry<TypeKey, TypeValue>> entrySet;

		public SortedMapAVL(Comparator<? super TypeKey> comparator)
		{
			this(comparator, new SortedSetAVL<>((entry0, entry1) -> comparator.compare(entry0.getKey(), entry1.getKey())));
		}

		private SortedMapAVL(Comparator<? super TypeKey> comparator, SortedSetAVL<Entry<TypeKey, TypeValue>> entrySet)
		{
			this.comparator = comparator;
			this.entrySet = entrySet;
		}

		@Override
		public Comparator<? super TypeKey> comparator()
		{
			return this.comparator;
		}

		@Override
		public SortedMapAVL<TypeKey, TypeValue> subMap(TypeKey keyStart, TypeKey keyEnd)
		{
			return new SortedMapAVL<>(this.comparator, this.entrySet.subSet(new AbstractMap.SimpleEntry<>(keyStart, null), new AbstractMap.SimpleEntry<>(keyEnd, null)));
		}

		@Override
		public SortedMapAVL<TypeKey, TypeValue> headMap(TypeKey keyEnd)
		{
			return new SortedMapAVL<>(this.comparator, this.entrySet.headSet(new AbstractMap.SimpleEntry<>(keyEnd, null)));
		}

		@Override
		public SortedMapAVL<TypeKey, TypeValue> tailMap(TypeKey keyStart)
		{
			return new SortedMapAVL<>(this.comparator, this.entrySet.tailSet(new AbstractMap.SimpleEntry<>(keyStart, null)));
		}

		public Entry<TypeKey, TypeValue> firstEntry()
		{
			return this.entrySet.first();
		}

		@Override
		public TypeKey firstKey()
		{
			return firstEntry().getKey();
		}

		public Entry<TypeKey, TypeValue> lastEntry()
		{
			return this.entrySet.last();
		}

		@Override
		public TypeKey lastKey()
		{
			return lastEntry().getKey();
		}

		@Override
		public int size()
		{
			return this.entrySet().size();
		}

		@Override
		public boolean isEmpty()
		{
			return this.entrySet.isEmpty();
		}

		@Override
		public boolean containsKey(Object key)
		{
			return this.entrySet().contains(new AbstractMap.SimpleEntry<>((TypeKey) key, null));
		}

		@Override
		public boolean containsValue(Object value)
		{
			throw new UnsupportedOperationException();
		}

		@Override
		public TypeValue get(Object key)
		{
			Entry<TypeKey, TypeValue> entry = new AbstractMap.SimpleEntry<>((TypeKey) key, null);
			entry = this.entrySet.get(entry);
			return entry == null ? null : entry.getValue();
		}

		@Override
		public TypeValue put(TypeKey key, TypeValue value)
		{
			TypeValue result = get(key);
			Entry<TypeKey, TypeValue> entry = new AbstractMap.SimpleEntry<>(key, value);
			this.entrySet().add(entry);
			return result;
		}

		@Override
		public TypeValue remove(Object key)
		{
			TypeValue result = get(key);
			Entry<TypeKey, TypeValue> entry = new AbstractMap.SimpleEntry<>((TypeKey) key, null);
			this.entrySet.remove(entry);
			return result;
		}

		@Override
		public void putAll(Map<? extends TypeKey, ? extends TypeValue> map)
		{
			map.entrySet()
					.forEach(entry -> put(entry.getKey(), entry.getValue()));
		}

		@Override
		public void clear()
		{
			this.entrySet.clear();
		}

		@Override
		public Set<TypeKey> keySet()
		{
			throw new UnsupportedOperationException();
		}

		@Override
		public Collection<TypeValue> values()
		{
			return new Collection<TypeValue>()
			{
				@Override
				public int size()
				{
					return SortedMapAVL.this.entrySet.size();
				}

				@Override
				public boolean isEmpty()
				{
					return SortedMapAVL.this.entrySet.isEmpty();
				}

				@Override
				public boolean contains(Object value)
				{
					throw new UnsupportedOperationException();
				}

				@Override
				public Iterator<TypeValue> iterator()
				{
					return new Iterator<TypeValue>()
					{
						Iterator<Entry<TypeKey, TypeValue>> iterator = SortedMapAVL.this.entrySet.iterator();

						@Override
						public boolean hasNext()
						{
							return this.iterator.hasNext();
						}

						@Override
						public TypeValue next()
						{
							return this.iterator.next().getValue();
						}
					};
				}

				@Override
				public Object[] toArray()
				{
					throw new UnsupportedOperationException();
				}

				@Override
				public <T> T[] toArray(T[] ts)
				{
					throw new UnsupportedOperationException();
				}

				@Override
				public boolean add(TypeValue typeValue)
				{
					throw new UnsupportedOperationException();
				}

				@Override
				public boolean remove(Object o)
				{
					throw new UnsupportedOperationException();
				}

				@Override
				public boolean containsAll(Collection<?> collection)
				{
					throw new UnsupportedOperationException();
				}

				@Override
				public boolean addAll(Collection<? extends TypeValue> collection)
				{
					throw new UnsupportedOperationException();
				}

				@Override
				public boolean removeAll(Collection<?> collection)
				{
					throw new UnsupportedOperationException();
				}

				@Override
				public boolean retainAll(Collection<?> collection)
				{
					throw new UnsupportedOperationException();
				}

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

		@Override
		public SortedSetAVL<Entry<TypeKey, TypeValue>> entrySet()
		{
			return this.entrySet;
		}

		@Override
		public String toString()
		{
			return this.entrySet().toString();
		}
	}

	public static class FIFO<Type>
	{
		public SingleLinkedList<Type> start;
		public SingleLinkedList<Type> end;

		public FIFO()
		{
			this.start = null;
			this.end = null;
		}

		public boolean isEmpty()
		{
			return this.start == null;
		}

		public Type peek()
		{
			return this.start.element;
		}

		public Type pop()
		{
			Type result = this.start.element;
			this.start = this.start.next;
			return result;
		}

		public void push(Type element)
		{
			SingleLinkedList<Type> list = new SingleLinkedList<>(element, null);
			if (this.start == null)
			{
				this.start = list;
				this.end = list;
			}
			else
			{
				this.end.next = list;
				this.end = list;
			}
		}
	}

	public static class MapCount<Type> extends SortedMapAVL<Type, Long>
	{
		private int count;

		public MapCount(Comparator<? super Type> comparator)
		{
			super(comparator);
			this.count = 0;
		}

		public long add(Type key, Long delta)
		{
			long result;
			if (delta > 0)
			{
				Long value = get(key);
				if (value == null)
				{
					value = delta;
				}
				else
				{
					value += delta;
				}
				put(key, value);
				result = delta;
			}
			else
			{
				result = 0;
			}
			this.count += result;
			return result;
		}

		public int count()
		{
			return this.count;
		}

		public List<Type> flatten()
		{
			List<Type> result = new ArrayList<>();
			for (Entry<Type, Long> entry : entrySet())
			{
				for (long index = 0; index < entry.getValue(); index++)
				{
					result.add(entry.getKey());
				}
			}
			return result;
		}

		@Override
		public void putAll(Map<? extends Type, ? extends Long> map)
		{
			throw new UnsupportedOperationException();
		}

		@Override
		public Long remove(Object key)
		{
			Long result = super.remove(key);
			this.count -= result;
			return result;
		}

		public long remove(Type key, Long delta)
		{
			long result;
			if (delta > 0)
			{
				Long value = get(key) - delta;
				if (value <= 0)
				{
					result = delta + value;
					remove(key);
				}
				else
				{
					result = delta;
					put(key, value);
				}
			}
			else
			{
				result = 0;
			}
			this.count -= result;
			return result;
		}

		@Override
		public SortedMapAVL<Type, Long> subMap(Type keyStart, Type keyEnd)
		{
			throw new UnsupportedOperationException();
		}

		@Override
		public SortedMapAVL<Type, Long> headMap(Type keyEnd)
		{
			throw new UnsupportedOperationException();
		}

		@Override
		public SortedMapAVL<Type, Long> tailMap(Type keyStart)
		{
			throw new UnsupportedOperationException();
		}
	}

	public static class MapSet<TypeKey, TypeValue> extends SortedMapAVL<TypeKey, SortedSetAVL<TypeValue>> implements Iterable<TypeValue>
	{
		private Comparator<? super TypeValue> comparatorValue;

		public MapSet(Comparator<? super TypeKey> comparatorKey, Comparator<? super TypeValue> comparatorValue)
		{
			super(comparatorKey);
			this.comparatorValue = comparatorValue;
		}

		public MapSet(Comparator<? super TypeKey> comparatorKey, SortedSetAVL<Entry<TypeKey, SortedSetAVL<TypeValue>>> entrySet, Comparator<? super TypeValue> comparatorValue)
		{
			super(comparatorKey, entrySet);
			this.comparatorValue = comparatorValue;
		}

		public TypeValue firstValue()
		{
			TypeValue result;
			Entry<TypeKey, SortedSetAVL<TypeValue>> firstEntry = firstEntry();
			if (firstEntry == null)
			{
				result = null;
			}
			else
			{
				result = firstEntry.getValue().first();
			}
			return result;
		}

		public Iterator<TypeValue> iterator()
		{
			return new Iterator<TypeValue>()
			{
				Iterator<SortedSetAVL<TypeValue>> iteratorValues = values().iterator();
				Iterator<TypeValue> iteratorValue = null;

				@Override
				public boolean hasNext()
				{
					return iteratorValues.hasNext() || (iteratorValue != null && iteratorValue.hasNext());
				}

				@Override
				public TypeValue next()
				{
					if (iteratorValue == null || !iteratorValue.hasNext())
					{
						iteratorValue = iteratorValues.next().iterator();
					}
					return iteratorValue.next();
				}
			};
		}

		public TypeValue lastValue()
		{
			TypeValue result;
			Entry<TypeKey, SortedSetAVL<TypeValue>> lastEntry = lastEntry();
			if (lastEntry == null)
			{
				result = null;
			}
			else
			{
				result = lastEntry.getValue().last();
			}
			return result;
		}

		public boolean add(TypeKey key, TypeValue value)
		{
			SortedSetAVL<TypeValue> set = computeIfAbsent(key, k -> new SortedSetAVL<>(comparatorValue));
			return set.add(value);
		}

		public boolean removeSet(TypeKey key, TypeValue value)
		{
			boolean result;
			SortedSetAVL<TypeValue> set = get(key);
			if (set == null)
			{
				result = false;
			}
			else
			{
				result = set.remove(value);
				if (set.size() == 0)
				{
					remove(key);
				}
			}
			return result;
		}

		@Override
		public MapSet<TypeKey, TypeValue> headMap(TypeKey keyEnd)
		{
			return new MapSet<>(this.comparator, this.entrySet.headSet(new AbstractMap.SimpleEntry<>(keyEnd, null)), this.comparatorValue);
		}

		@Override
		public MapSet<TypeKey, TypeValue> tailMap(TypeKey keyStart)
		{
			return new MapSet<>(this.comparator, this.entrySet.tailSet(new AbstractMap.SimpleEntry<>(keyStart, null)), this.comparatorValue);
		}
	}

	static class IteratorBuffer<Type>
	{
		private Iterator<Type> iterator;
		private List<Type> list;

		public IteratorBuffer(Iterator<Type> iterator)
		{
			this.iterator = iterator;
			this.list = new ArrayList<Type>();
		}

		public Iterator<Type> iterator()
		{
			return new Iterator<Type>()
			{
				int index = 0;

				@Override
				public boolean hasNext()
				{
					return this.index < list.size() || iterator().hasNext();
				}

				@Override
				public Type next()
				{
					if (list.size() <= this.index)
					{
						list.add(iterator.next());
					}
					Type result = list.get(index);
					index += 1;
					return result;
				}
			};
		}
	}

	public static <Type> List<List<Type>> permutations(List<Type> list)
	{
		List<List<Type>> result = new ArrayList<>();
		result.add(new ArrayList<>());
		for (Type element : list)
		{
			List<List<Type>> permutations = result;
			result = new ArrayList<>();
			for (List<Type> permutation : permutations)
			{
				for (int index = 0; index <= permutation.size(); index++)
				{
					List<Type> permutationNew = new ArrayList<>(permutation);
					permutationNew.add(index, element);
					result.add(permutationNew);
				}
			}
		}
		return result;
	}

	public static List<List<Integer>> combinations(int n, int k)
	{
		List<List<Integer>> result = new ArrayList<>();
		if (k == 0)
		{
		}
		else
		{
			if (k == 1)
			{
				List<Integer> combination = new ArrayList<>();
				combination.add(n);
				result.add(combination);
			}
			else
			{
				for (int index = 0; index <= n; index++)
				{
					for (List<Integer> combination : combinations(n - index, k - 1))
					{
						combination.add(index);
						result.add(combination);
					}
				}
			}
		}
		return result;
	}

	public static <Type> int compare(Iterator<Type> iterator0, Iterator<Type> iterator1, Comparator<Type> comparator)
	{
		int result = 0;
		while (result == 0 && iterator0.hasNext() && iterator1.hasNext())
		{
			result = comparator.compare(iterator0.next(), iterator1.next());
		}
		if (result == 0)
		{
			if (iterator1.hasNext())
			{
				result = -1;
			}
			else
			{
				if (iterator0.hasNext())
				{
					result = 1;
				}
			}
		}
		return result;
	}

	public static <Type> int compare(Iterable<Type> iterable0, Iterable<Type> iterable1, Comparator<Type> comparator)
	{
		return compare(iterable0.iterator(), iterable1.iterator(), comparator);
	}

	private static String nextString() throws IOException
	{
		while ((stringTokenizer == null) || (!stringTokenizer.hasMoreTokens()))
		{
			stringTokenizer = new StringTokenizer(bufferedReader.readLine());
		}
		return stringTokenizer.nextToken();
	}

	private static String[] nextStrings(int n) throws IOException
	{
		String[] result = new String[n];
		{
			for (int index = 0; index < n; index++)
			{
				result[index] = nextString();
			}
		}
		return result;
	}

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

	public static int[] nextInts(int n) throws IOException
	{
		int[] result = new int[n];
		{
			for (int index = 0; index < n; index++)
			{
				result[index] = nextInt();
			}
		}
		return result;
	}

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

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

	public static long[] nextLongs(int n) throws IOException
	{
		long[] result = new long[n];
		{
			for (int index = 0; index < n; index++)
			{
				result[index] = nextLong();
			}
		}
		return result;
	}

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

	public static void close()
	{
		out.close();
	}

	public static int binarySearchMinimum(Function<Integer, Boolean> filter, int start, int end)
	{
		int result;
		if (start == end)
		{
			result = end;
		}
		else
		{
			int middle = start + (end - start) / 2;
			if (filter.apply(middle))
			{
				result = binarySearchMinimum(filter, start, middle);
			}
			else
			{
				result = binarySearchMinimum(filter, middle + 1, end);
			}
		}
		return result;
	}

	public static int binarySearchMaximum(Function<Integer, Boolean> filter, int start, int end)
	{
		return -binarySearchMinimum(x -> filter.apply(-x), -end, -start);
	}

	public static long divideCeil(long x, long y)
	{
		return (x + y - 1) / y;
	}

	public static Set<Long> divisors(long n)
	{
		SortedSetAVL<Long> result = new SortedSetAVL<>(Comparator.naturalOrder());
		result.add(1L);
		for (Long factor : factors(n))
		{
			SortedSetAVL<Long> divisors = new SortedSetAVL<>(result);
			for (Long divisor : result)
			{
				divisors.add(divisor * factor);
			}
			result = divisors;
		}
		return result;
	}

	public static long faculty(int n)
	{
		long result = 1;
		for (int index = 2; index <= n; index++)
		{
			result *= index;
		}
		return result;
	}

	public static LinkedList<Long> factors(long n)
	{
		LinkedList<Long> result = new LinkedList<>();
		Iterator<Long> primes = ITERATOR_BUFFER_PRIME.iterator();
		Long prime;
		while (n > 1 && (prime = primes.next()) * prime <= n)
		{
			while (n % prime == 0)
			{
				result.add(prime);
				n /= prime;
			}
		}
		if (n > 1)
		{
			result.add(n);
		}
		return result;
	}

	public static long gcd(long a, long b)
	{
		while (a != 0 && b != 0)
		{
			if (a > b)
			{
				a %= b;
			}
			else
			{
				b %= a;
			}
		}
		return a + b;
	}

	public static long[] generatePOWER2()
	{
		long[] result = new long[63];
		for (int x = 0; x < result.length; x++)
		{
			result[x] = 1L << x;
		}
		return result;
	}

	public static boolean isPrime(long x)
	{
		boolean result = x > 1;
		Iterator<Long> iterator = ITERATOR_BUFFER_PRIME.iterator();
		Long prime;
		while ((prime = iterator.next()) * prime <= x)
		{
			result &= x % prime > 0;
		}
		return result;
	}

	public static long knapsack(List<Tuple3<Long, Integer, Integer>> itemsValueWeightCount, int weightMaximum)
	{
		long[] valuesMaximum = new long[weightMaximum + 1];
		for (Tuple3<Long, Integer, Integer> itemValueWeightCount : itemsValueWeightCount)
		{
			long itemValue = itemValueWeightCount.v0;
			int itemWeight = itemValueWeightCount.v1;
			int itemCount = itemValueWeightCount.v2;
			for (int weight = weightMaximum; 0 <= weight; weight--)
			{
				for (int index = 1; index <= itemCount && 0 <= weight - index * itemWeight; index++)
				{
					valuesMaximum[weight] = Math.max(valuesMaximum[weight], valuesMaximum[weight - index * itemWeight] + index * itemValue);
				}
			}
		}
		long result = 0;
		for (long valueMaximum : valuesMaximum)
		{
			result = Math.max(result, valueMaximum);
		}
		return result;
	}

	public static boolean knapsackPossible(List<Tuple2<Integer, Integer>> itemsWeightCount, int weightMaximum)
	{
		boolean[] weightPossible = new boolean[weightMaximum + 1];
		weightPossible[0] = true;
		int weightLargest = 0;
		for (Tuple2<Integer, Integer> itemWeightCount : itemsWeightCount)
		{
			int itemWeight = itemWeightCount.v0;
			int itemCount = itemWeightCount.v1;
			for (int weightStart = 0; weightStart < itemWeight; weightStart++)
			{
				int count = 0;
				for (int weight = weightStart; weight <= weightMaximum && (0 < count || weight <= weightLargest); weight += itemWeight)
				{
					if (weightPossible[weight])
					{
						count = itemCount;
					}
					else
					{
						if (0 < count)
						{
							weightPossible[weight] = true;
							weightLargest = weight;
							count -= 1;
						}
					}
				}
			}
		}
		return weightPossible[weightMaximum];
	}

	public static long lcm(int a, int b)
	{
		return a * b / gcd(a, b);
	}

	public static <T> List<T> permutation(long p, List<T> x)
	{
		List<T> copy = new ArrayList<>();
		for (int index = 0; index < x.size(); index++)
		{
			copy.add(x.get(index));
		}
		List<T> result = new ArrayList<>();
		for (int indexTo = 0; indexTo < x.size(); indexTo++)
		{
			int indexFrom = (int) p % copy.size();
			p = p / copy.size();
			result.add(copy.remove(indexFrom));
		}
		return result;
	}

	public static <Type> String toString(Iterator<Type> iterator, String separator)
	{
		StringBuilder stringBuilder = new StringBuilder();
		if (iterator.hasNext())
		{
			stringBuilder.append(iterator.next());
		}
		while (iterator.hasNext())
		{
			stringBuilder.append(separator);
			stringBuilder.append(iterator.next());
		}
		return stringBuilder.toString();
	}

	public static <Type> String toString(Iterator<Type> iterator)
	{
		return toString(iterator, " ");
	}

	public static <Type> String toString(Iterable<Type> iterable, String separator)
	{
		return toString(iterable.iterator(), separator);
	}

	public static <Type> String toString(Iterable<Type> iterable)
	{
		return toString(iterable, " ");
	}

	public static Stream<BigInteger> streamFibonacci()
	{
		return Stream.generate(new Supplier<BigInteger>()
		{
			private BigInteger n0 = BigInteger.ZERO;
			private BigInteger n1 = BigInteger.ONE;

			@Override
			public BigInteger get()
			{
				BigInteger result = n0;
				n0 = n1;
				n1 = result.add(n0);
				return result;
			}
		});
	}

	public static Stream<Long> streamPrime(int sieveSize)
	{
		return Stream.generate(new Supplier<Long>()
		{
			private boolean[] isPrime = new boolean[sieveSize];
			private long sieveOffset = 2;
			private List<Long> primes = new ArrayList<>();
			private int index = 0;

			public void filter(long prime, boolean[] result)
			{
				if (prime * prime < this.sieveOffset + sieveSize)
				{
					long remainingStart = this.sieveOffset % prime;
					long start = remainingStart == 0 ? 0 : prime - remainingStart;
					for (long index = start; index < sieveSize; index += prime)
					{
						result[(int) index] = false;
					}
				}
			}

			public void generatePrimes()
			{
				Arrays.fill(this.isPrime, true);
				this.primes.forEach(prime -> filter(prime, isPrime));
				for (int index = 0; index < sieveSize; index++)
				{
					if (isPrime[index])
					{
						this.primes.add(this.sieveOffset + index);
						filter(this.sieveOffset + index, isPrime);
					}
				}
				this.sieveOffset += sieveSize;
			}

			@Override
			public Long get()
			{
				while (this.primes.size() <= this.index)
				{
					generatePrimes();
				}
				Long result = this.primes.get(this.index);
				this.index += 1;
				return result;
			}
		});
	}

	public static long totient(long n)
	{
		Set<Long> factors = new SortedSetAVL<>(factors(n), Comparator.naturalOrder());
		long result = n;
		for (long p : factors)
		{
			result -= result / p;
		}
		return result;
	}

	public static void main(String[] args)
	{
		try
		{
			solve();
		} catch (IOException exception)
		{
			exception.printStackTrace();
		}
		close();
	}

	public static class Vector implements Comparable<Vector>
	{
		public static Comparator<Vector> COMPARATOR = Comparator.comparing(Vector::getX0)
				.thenComparing(Vector::getX1)
				.thenComparing(Vector::getX2)
				.thenComparing(Vector::getX3)
				.thenComparing(Vector::getX4);
		public final int x0;
		public final int x1;
		public final int x2;
		public final int x3;
		public final int x4;

		public Vector(int x0, int x1, int x2, int x3, int x4)
		{
			this.x0 = x0;
			this.x1 = x1;
			this.x2 = x2;
			this.x3 = x3;
			this.x4 = x4;
		}

		public Vector() throws IOException
		{
			this(nextInt(), nextInt(), nextInt(), nextInt(), nextInt());
		}

		public int getX0()
		{
			return x0;
		}

		public int getX1()
		{
			return x1;
		}

		public int getX2()
		{
			return x2;
		}

		public int getX3()
		{
			return x3;
		}

		public int getX4()
		{
			return x4;
		}

		public int product(Vector p)
		{
			return this.x0 * p.x0 +
					this.x1 * p.x1 +
					this.x2 * p.x2 +
					this.x3 * p.x3 +
					this.x4 * p.x4;
		}

		public Vector sub(Vector p)
		{
			return new Vector(this.x0 - p.x0, this.x1 - p.x1, this.x2 - p.x2, this.x3 - p.x3, this.x4 - p.x4);
		}

		public boolean acute(Vector p, Vector q)
		{
			Vector ap = p.sub(this);
			Vector aq = q.sub(this);
			return ap.product(aq) > 0;
		}

		@Override
		public int compareTo(Vector that)
		{
			return COMPARATOR.compare(this, that);
		}
	}

	public static Set<Integer> convert(boolean[] bad)
	{
		Set<Integer> result = new SortedSetAVL<>(Comparator.naturalOrder());

		for (int index = 0; index < bad.length; index++)
		{
			if (!bad[index])
			{
				result.add(index);
			}
		}
		return result;
	}

	public static Set<Integer> solveBrute(C_432.Vector[] vectors)
	{
		boolean[] bad = new boolean[vectors.length];
		for (int index = 0; index < vectors.length; index++)
		{
			for (int indexB = 0; indexB < vectors.length; indexB++)
			{
				for (int indexC = 0; indexC < vectors.length; indexC++)
				{
					if (index != indexB && index != indexC && indexB != indexC)
					{
						if (vectors[index].acute(vectors[indexB], vectors[indexC]))
						{
							bad[index] = true;
						}
					}
				}
			}
		}
		return convert(bad);
	}

	public static Set<Integer> solve(Vector[] vectors)
	{
		boolean[] bad = new boolean[vectors.length];
		for (int index = 0; index < vectors.length; index++)
		{
			if (!bad[index])
			{
				for (int indexB = 0; !bad[index] && indexB < vectors.length; indexB++)
				{
					for (int indexC = 0; !bad[index] && indexC < vectors.length; indexC++)
					{
						if (index != indexB && index != indexC && indexB != indexC)
						{
							if (vectors[index].acute(vectors[indexB], vectors[indexC]))
							{
								bad[index] = true;
							}
							else
							{
								bad[indexB] = true;
								bad[indexC] = true;
							}
						}
					}
				}
			}
		}
		return convert(bad);
	}

	public static void solve() throws IOException
	{
		int n = nextInt();
		Vector[] vectors = new Vector[n];
		for (int index = 0; index < n; index++)
		{
			vectors[index] = new Vector();
		}
		Set<Integer> result = solveBrute(vectors);
		out.println(result.size());
		for (Integer index : result)
		{
			out.println(index + 1);
		}
	}
}


import java.util.*;
import java.io.*;
/*
TASK: fivedimpoints
LANG: JAVA
 */

public class fivedimpoints{
    static int n;
    static int[][] coord;
    static long[][][] vect;
    static boolean[] bad;

    public static void main(String[] args) throws IOException{
        FastScanner in = new FastScanner(System.in);
        n = in.nextInt();
        if(n > 10) System.out.println(0);
        coord = new int[n][5];
        vect = new long[n][n][5];
        bad = new boolean[n];
        for(int i = 0;i <n; i++){
            for(int j = 0;j < 5;j++){
                coord[i][j] = in.nextInt();
            }
        }
        for(int i = 0;i < n; i++){
            for(int j = 0;j < n; j++){
                for(int k = 0; k < 5; k++){
                    vect[i][j][k] = coord[j][k] - coord[i][k];
                }
            }
        }
        int count = n;
        long prod;
        for(int i = 0;i < n; i++){
            for(int j = 0;j < n; j++){
                if(j != i){
                    for(int k = 0; k < n; k++){
                        if(k != j && k != i){
                            prod = 0;
                            for(int m = 0; m < 5; m++){
                                prod += vect[j][i][m]*vect[k][i][m];
                            }
                            if(prod > 0 && !bad[i]){
                                bad[i] = true;
                                count--;
                            }
                        }
                    }
                }
            }
        }
        System.out.println(count);
        for(int i = 0;i < n; i++){
            if(!bad[i]){
                System.out.println(i+1);
            }
        }
    }
}
class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

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

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

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

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

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

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

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

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


import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		while(sc.hasNext()){
			int n=sc.nextInt();
			Point[]p=new Point[n];
			for(int o=0;o<n;o++){
				int a=sc.nextInt();
				int b=sc.nextInt();
				int c=sc.nextInt();
				int d=sc.nextInt();
				int e=sc.nextInt();
				p[o]=new Point(a,b,c,d,e,o+1);
			}
			TreeSet<Integer>set=new TreeSet<Integer>();
			for(int i=0;i<n;i++){
				boolean flag=true;
				for(int j=i+1;j<n&&flag;j++){
					for(int k=j+1;k<n&&flag;k++){
						Point t1=p[i].minus(p[j]);
						Point t2=p[i].minus(p[k]);
						double temp=js(t1,t2);
						if(temp>0){
							flag=false;
						}
					}
				}
				if(flag)set.add(i+1)
			}
			pw.println(set.size());
			for(int k:set){
				pw.print(k+" ");
			}
			pw.flush();
		}

	}
	static double js(Point a,Point b){
		double sum=a.a*b.a+a.b*b.b+a.c*b.c+a.d*b.d+a.e*b.e;
		return sum;
	}
}
class Point{
	int a;
	int b;
	int c;
	int d;
	int e;
	int index;
	Point (int a,int b,int c,int d,int e,int index){
		this.a=a;
		this.b=b;
		this.c=c;
		this.d=d;
		this.e=e;
		this.index=index;
	}
	Point minus(Point p){
		return new Point(a-p.a,b-p.b,c-p.c,d-p.d,e-p.e,0);
	}
}
class FastScanner {
	BufferedReader br;
	StringTokenizer st;

	public FastScanner() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in),32768);
			st = new StringTokenizer("");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public boolean hasNext() {
		while (!st.hasMoreTokens()) {
			String line = nextLine();
			if (line == null) {
				return false;
			}
			st = new StringTokenizer(line);
		}
		return true;
	}

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

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

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

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

	public String nextLine() {
		String line = "";
		try {
			line = br.readLine();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return line;
	}
}


package practiseCF;

import fastIO.InputReader;
import java.io.PrintWriter;
import java.util.*;

public class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
//        System.out.println(Math.toDegrees(Math.acos(0.5)));
        int n = in.nextInt();
        if(n >= 100) {
            out.print(0);
        } else {
            int [] a = new int[105];
            int [] b = new int[105];
            int [] c = new int[105];
            int [] d = new int[105];
            int [] e = new int[105];
            for(int i = 1; i <= n; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
                c[i] = in.nextInt();
                d[i] = in.nextInt();
                e[i] = in.nextInt();
            }

            Set<Integer> bad = new HashSet<>();

            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= n; j++) {
                    for(int k = 1; k <= n; k++)
                    {
                        if(i == j || j == k || k == i) {
                            continue;
                        }

                        long ax = a[j] - a[i];
                        long bx = b[j] - b[i];
                        long cx = c[j] - c[i];
                        long dx = d[j] - d[i];
                        long ex = e[j] - e[i];

                        long ay = a[k] - a[i];
                        long by = b[k] - b[i];
                        long cy = c[k] - c[i];
                        long dy = d[k] - d[i];
                        long ey = e[k] - e[i];

                        double val = ax * ay + bx * by + cx * cy + dx * dy + ex * ey;
                        long m1 = ax * ax + bx * bx + cx * cx + dx * dx + ex * ex;
                        long m2 = ay * ay + by * by + cy * cy + dy * dy + ey * ey;
                        val = val / Math.sqrt(m1);
                        val = val / Math.sqrt(m2);
                        if(Math.toDegrees(Math.acos(val)) +  0.000000001 < 90) {
                            bad.add(i);
                        }
                    }
                }
            }

            out.println(n - bad.size());

            for(int i = 1; i <= n; i++) {
                if(!bad.contains(i)) {
                    out.println(i);
                }
            }
        }
    }
}


import java.util.Scanner;
public class EntranceFinder{

	public static void main(String args[])
	Scanner in = new Scanner(System.in);
	int n = in.nextInt();
	int a = in.nextInt();
	int b = in.nextInt();
	in.close();
	int curr;
	int count;

	int core = n-a;
	if(n + b > n){
		int answer = n % b;
	}
	if(n + b <= 0){
		for(int i = b; i>=0; i--){
			count = a;
			count -= 1;
			if(count = 0){
				count = n;
			}
		}
		answer = count;
	}
	if(b=0){
		answer = a;
	}
	System.out.println(answer);
}


import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args)throws IOException
	{
	   int n=stdIO.readInt(),a=stdIO.readInt(),b=stdIO.readInt();
	   if(b<0)b=n+b;
	   int ans=(a+b)%n;
	   if(ans=0)ans=n;
	   stdIO.print(ans);
	}

}
class stdIO {
	  private static InputStream in=System.in;
	  private static PrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	  private static byte[] buffer=new byte[1024];
	  private static int len=0,byteread=0;
	  public static int read() throws IOException
	  {
		  if(len>=byteread)
		  {
			  len=0;
			  byteread=in.read(buffer);
			  if(byteread<=0)return -1;

		  }
		  return buffer[len++];
	  }
	  public static int readInt()throws IOException
	  {
		  int ret=0;
		  boolean flag=false;
		  int c=0;
		  c=read();
		  while(!(c>31&&c<127))c=read();
		  if(c=='-'){flag=true;c=read();}
		  do{

			  if ((c < '0') || (c > '9')) {
	              throw new InputMismatchException();
	          }
			  ret=ret*10+c-'0';
			  c=read();
			}while(isNumber(c));//System.out.println(ret);}
		  return flag?-ret:ret;

	  }
	  public static long readLong()throws IOException
	  {
		  long ret=0;
		  boolean flag=false;
		  int c=0;
		  c=read();
		  while(!(isNumber(c)||c=='-'))c=read();
		  if(c=='-'){flag=true;c=read();}
		  do{

			  ret=ret*10+c-'0';
			  c=read();
			}while(isNumber(c));//System.out.println(ret);}
		  return flag?-ret:ret;

	  }

	   public static double readDouble()throws IOException
	   {
		   int c=read();
	       boolean flag=false;
	       while (!isChar(c)) {
	           c=read();
	       }
	       if (c=='-') {
	           flag=true;
	           c = read();
	       }
	       boolean f=false;
	       double mul=1;
	       double ret=0;
	       do {
	           if ((c =='e')||(c=='E')) {
	               return flag?-ret *Math.pow(10,readInt()):ret *Math.pow(10,readInt());
	           }
	           if ((c<'0')||(c>'9')) {
	               if ((c == '.')&&!f) {
	                   f=true;
	                   c=read();
	                   continue;
	               }
	               throw new InputMismatchException();
	           }
	           if (f) {
	               mul/=10;
	               ret+=(c-'0')*mul;
	               c=read();
	           } else {
	               ret*= 10;
	               ret+= (c - '0');
	               c = read();
	           }
	       } while (isNumber(c)||c=='e'||c=='E'||c=='.');
	       return flag?-ret:ret;
	   }
	   private static boolean isNumber(int c)
	   {
		   return (c>='0'&&c<='9');
	   }
	   private static boolean isChar(int c)
	   {
		   return (c>=33&&c<=126);
	   }
	   public static String readString() throws IOException
	   {
		   StringBuilder sb=new StringBuilder();
		   int c=read();
		   while(!isChar(c))c=read();

		   while(isChar(c))
		   {
			   sb.appendCodePoint(c);
			   c=read();
		   }
		   return sb.toString();
	   }
	   public static String readLine()throws IOException
	   {
		   StringBuilder sb=new StringBuilder();
		   int c=read();
		   while(isChar(c)||c==' ')
		   {
			   sb.appendCodePoint(c);
			   c=read();
			   if(c==10)break;
		   }
		   return sb.toString();
	   }
	   public static void print(Object...objects)
	   {
		   int l=objects.length;
		   for(int i=0;i<l;i++)
			   {
			      out.print(objects[i]);
			      if(i!=l-1)out.print(' ');else out.print('\n');
			   }
		   out.flush();

	   }
	  public static void close()
	  {
		  out.close();
	  }
	}


import java.util.*;
public class RoundHouse
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
int f = 0;
b = Math.abs(b);
if(n == b)
{
    System.out.println(a);
}
if(b == 0)
{
    System.out.println(a);
}
else if(b > 0)
{
    if(a + b < n)
    {
        System.out.println(a + b);
    }
    else
    {
    int h = 0;
    while(f != b)
    {
        f++;
        if(f % n == 0)
        {
            h++;
        }
    }
    System.out.println((a + b) - (n * h));
    }
}
else if(b < 0)
{
    b = Math.abs(b);
    if(Math.abs(a - b) < n)
    {
        System.out.println(Math.abs((a - b));
    }
    else
    {
    int p = 0;
    b = Math.abs(b);
    int l = 0;
    while(p != b)
    {
        p++;
        if(p % n == 0)
        {
            l++;
        }
    }
    System.out.println(Math.abs(Math.abs(((a - 1) - b) - (n * l))));
    }
}
}
}


import static java.lang.Math.*;
import static java.util.Arrays.sort;
import java.util.*;
import static javax.swing.text.StyleConstants.*;

public class JavaApplication1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, a,b1, intr;
        n= sc.nextInt();
        a=sc.nextInt();
        b1 = sc.nextInt();
        if (b1>n){
            intr = (int)(b1-(floor(b1/n)*n)+a);
        }else{
            intr = abs(a+b1);
            if (int==0)
                intr=1;
        }
        System.out.println(intr);
}

}


import java.util.Scanner;

public class Solution implements Runnable {

	public static void main(String[] args)  {
		Scanner s=new Scanner(System.in);
		String first=s.next();
		String last=s.next();
		String pass="";
		char cc=first.charAt(0);
		pass=pass+cc;
		String ros=first.substring(1);
		for(int i=0;i<first.length();i++)
		{
			if(last.charAt(0)>ros.charAt(0))
			{
				pass=pass+ros.charAt(0);
				if(ros.length()>1)
				{
					ros=ros.substring(1);
				}
				else
				{
					break;
				}
			}
			else
			{
				break;
			}
		}
		pass=pass+last.charAt(0);
		System.out.println(pass);
	}

}


import java.util.*;

public class Name
{
    public String lastname;
    public String firstname;

    public Name(String name) {
        int i = name.indexOf(" ");
        this.firstname = name.substring(0, i);
        this.lastname = name.substring(i + 1);
    }

    public String Generate()
    {

        String s1 = new String();
        int n = firstname.length();
        for(int i = 1; i < n; i++)
        {
            if(firstname.charAt(i) < lastname.charAt(0) )
            {
                s1 += firstname.charAt(i);
            }
            else
            {
                break;
            }
        }
        return firstname.charAt(0) + s1 + lastname.charAt(0);

    }

}
public class Main {

    public static void main(String[] args) {
        Scanner ip = new Scanner(System.in);
        String s = ip.nextLine();
        Name name = new Name(s);
        System.out.println(name.Generate());

    }

}


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

public class codeforces {

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

    String input = in.next();

    String[] fullName = input.split(" ");
    String result = fullName[0].charAt(0);

    char first = fullName[0].charAt(0) , second = fullName[1].charAt(0) ;

    for(int i=1;i<fullName[0].length() ; i++) {
        if((second - 'a') < (fullName[0].charAt(i)-'a' ) ) {
            result += second;
            break;
        }else{
            result += fullName[0].charAt(i);
        }

    }

    System.out.print(result);

    }
}


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

public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner scan = new Scanner(System.in);
		String a,b,o = "";
		int i=1;
		a = scan.next();
		b = scan.next();
		o = o  + a.charAt(0);
		if(b.charAt(0)<a.charAt(1))
		    o = o + b.charAt(0);
		else{
		    while(i<=a.length()-1 && a.charAt(i)<b.charAt(0)){
		        if(a.charAt(i)<b.charAt(0)){
		        o = o + a.charAt(i);
		        }
		        i++;
		    }
		    o = o + b.charAt(0);
		}
		System.out.println(o);
	}
}