import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;

public class A
{
        String line;
        StringTokenizer inputParser;
        BufferedReader is;
        FileInputStream fstream;
        DataInputStream in;
        String FInput="";

        void openInput(String file)
        {
            if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
            else
            {
                    try{

                    fstream = new FileInputStream(file);
                    in = new DataInputStream(fstream);
                    is = new BufferedReader(new InputStreamReader(in));
                    }catch(Exception e)
                    {
                            System.err.println(e);
                    }
            }
        }

        void readNextLine()
    	{
    		try {
    			line = is.readLine();
    			inputParser = new StringTokenizer(line, " ,\t");
    			//System.err.println("Input: " + line);
    		} catch (IOException e) {
    			System.err.println("Unexpected IO ERROR: " + e);
    		}
    		catch (NullPointerException e)
    		{
    			line=null;

    		}

    	}

        long NextLong()
        {
                String n = inputParser.nextToken();

                long val = Long.parseLong(n);

                 return val;
        }

        int NextInt()
        {
                String n = inputParser.nextToken();
                int val = Integer.parseInt(n);

                //System.out.println("I read this number: " + val);
                return val;
        }

        double NextDouble()
        {
                String n = inputParser.nextToken();
                double val = Double.parseDouble(n);

                //System.out.println("I read this number: " + val);
                return val;
        }

        String NextString()
        {
                String n = inputParser.nextToken();
                return n;
        }

        void closeInput()
        {
                try {
                        is.close();
                } catch (IOException e) {
                        System.err.println("Unexpected IO ERROR: " + e);
                }

        }

        public static void main(String [] argv)
        {
                //String filePath="circles.in";
                String filePath=null;
                if(argv.length>0)filePath=argv[0];
                new A(filePath);

        }

        //long [] sums = new long[1000001];
        public A(String inputFile)
        {
        	Random rgen = new Random();
        	openInput(inputFile);
    		//readNextLine();
    		int T=1;//NextInt();
    		StringBuilder sb = new StringBuilder();
    		int idLine=0;
    		for(int t=1; t<=T; t++)
    		{
    			readNextLine();
    			String a = "CODEFORCES";
    			String x = NextString();
    			int N = x.length();
    			int p=0;
    			for(int i=0; i<N; i++)
    			{
    				if(x.charAt(i)==a.charAt(p))p++;
    				if(p==a.length())break;
    			}
    			String ret="";
    			if(p==a.length())ret="YES";
    			else ret="NO";
    			sb.append(ret);
    		}
    		System.out.println(sb);

    		closeInput();

        }

        private boolean isOk(int ret, int L, long qM, long B) {
        	//System.out.println(L+" "+ret);
        	/*
        	long sum=ret*(ret+1)/2-(L-1)*(L)/2;
        	long N=ret-L+1;
        	sum += N*(x-1);
        	sum += (N-1)*N/2*(B-1);*/
        	//System.out.println(L+" "+ret+"->"+sum);
        	long sum = A*(ret-L+1)*B;
        	//long sum = sums[(int)ret]-sums[L-1];
			if(sum>qM)return false;
			return true;
		}

}


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

public class a
{
  static FastScanner in = new FastScanner(System.in);
  static StringBuilder sb = new StringBuilder();
  static DecimalFormat df = new DecimalFormat();

  public static void main(String[] args)
  {
    df.setMaximumFractionDigits(20);
    df.setMinimumFractionDigits(20);
    // String formatted = df.format(0.2);
    // Never sort array of primitive type

    Long longer = Long.valueOf(in.nextToken());
    Long shorter = Long.valueOf(in.nextToken());
    Long count = 0L;
    Long k = 1L;
    Long tmp;

    while(shorter > 0) {
        k = (long)Math.floor(longer/shorter);
        // System.out.println(k);
        count += k;
        tmp = longer;
        longer = shorter;
        shorter = tmp - shorter*k;
    }

    sb.append(count);

    System.out.println(sb.toString());
  }

  static BigInteger b(long n) { return BigInteger.valueOf(n);}
  static BigInteger b(String s) { return new BigInteger(s); }
  static BigDecimal bd(double d) { return BigDecimal.valueOf(d);}
  static BigDecimal bd(String s) { return new BigDecimal(s); }
}
class FastScanner
{
  BufferedReader reader;
  StringTokenizer tokenizer;
  FastScanner (InputStream inputStream)
  {
    reader = new BufferedReader(new InputStreamReader(inputStream));
  }
  String nextToken()
  {
    while (tokenizer == null || ! tokenizer.hasMoreTokens())
    {
      try {
        tokenizer = new StringTokenizer(reader.readLine());
      } catch (Exception e){}
    }
    return tokenizer.nextToken();
  }
  boolean hasNext()
  {
    if (tokenizer == null || ! tokenizer.hasMoreTokens())
    {
      try {
        tokenizer = new StringTokenizer(reader.readLine());
      } catch (Exception e){ return false; }
    }
    return true;
  }
  int nextInt()
  {
    return Integer.parseInt(nextToken());
  }
}


import java.util.*;

public class football{
    public static void main (String []args){
        Scanner in=new Scanner (System.in);
        int number=in.nextInt();
        int array[]=new int[number];
        int count=0;

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

        if ((array[i]==1) && (array[i]==0)){
            count++;
        } }

        if (count>=7) {
            System.out.println("YES");
        }else{
            System.out.println ("NO");
        }

    }
}


import java.util.*;
public class B_854
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n,k,i,j=0;
		int[] arr;
		n=sc.nextInt();
		k=sc.nextInt();
		arr=new int[n];
		if(n>k&&k>0)
			System.out.print(1+" ");
		else
			System.out.print(0+" ");
		for(i=0;i<k;i++)
		{
			if(i==0)
				j=j+1;
			else
				j=j+3;
		}
		if(k==0)
			System.out.print(0+" ");
		else if(j>=n-1)
			System.out.print(n-k+" ");
		else
			System.out.print(j-k+2+" ");
	}
}


/**
 * Created by IntelliJ IDEA.
 * User: shakhov
 * Date: 15.06.2011
 * Time: 15:22:46
 * To change this template use File | Settings | File Templates.
 */

//6
//86 402 133 524 405 610   6 4 1

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

public class CodeForces {

	public void solve() throws IOException {
			int n=nextInt();
			int k=nextInt();
			boolean simple[]=new boolean[1001];
			Arrays.fill(simple,true);
			for(int i=2;i<501;i++){
					int c=2;
					while(c*i<1001){
						simple[c*i]=false;
						c++;
					}
			}
			int res=0;
			int c=3,prev=2;
			while(c<=n/2+1){
				if(simple[prev+c+1]) res++;
				prev=c;
				c++;
				while(!simple[c]){
					c++;
				}
			}

			if(res>=k){
				out.print("YES");
			} else {
				out.print("NO");
			}

	}

	private BufferedReader reader;
	private StringTokenizer tokenizer;
	private String separator;
	public PrintWriter out;

	public static void main(String[] args) {
		new CodeForces().run(new InputStreamReader(System.in), new OutputStreamWriter(System.out));
	}

	public void run(Reader reader, Writer writer) {
		try {
			this.reader = new BufferedReader(reader);
			out = new PrintWriter(writer);
			tokenizer = new StringTokenizer("");
			separator = System.getProperty("line.separator");
			separator = Character.toString(separator.charAt(separator.length() - 1));
			long t1 = System.currentTimeMillis();
			solve();
			out.flush();
			reader.close();
			writer.close();
			long t2 = System.currentTimeMillis();
			System.err.println("Time = " + (t2 - t1));
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

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


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

import static java.lang.Math.*;

public class CF121A_Lucky_Sum extends PrintWriter {
    private int next(int n) {
        boolean isNext = false;
        while (!isNext) {
            isNext = true;
            String strn = Integer.toString(n);
            for (int i = 0; i < strn.length(); i++) {
                char cur = strn.charAt(i);
                if (cur != '4' && cur != '7') {
                    isNext = false;
                    break;
                }
            }

            if (!isNext)
                n++;
            else
                return n;
        }

        return n;
    }

    public void solve() throws IOException {
        int l = nextInt();
        int r = nextInt();
        int sum = 0;

        for (int i = l; i <= r; i++) {
            sum += next(i);
        }

        println(sum);
    }

    BufferedReader in;
    StringTokenizer stok;

    public void run() {
        try {
            solve();
            close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(abs(-1));
        }
    }

    CF121A_Lucky_Sum() throws IOException {
        super(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    CF121A_Lucky_Sum(String s) throws IOException {
        super("".equals(s) ? "output.txt" : (s + ".out"));
        in = new BufferedReader(new FileReader("".equals(s) ? "input.txt" : (s + ".in")));
    }

    public static void main(String[] args) throws IOException {
        try {
            Locale.setDefault(Locale.US);
        } catch (Exception ignored) {
        }
        new CF121A_Lucky_Sum().run();
    }

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

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

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

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

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

    <T> List<T>[] createAdjacencyList(int countVertex) {
        List<T>[] res = new List[countVertex];
        for (int i = 0; i < countVertex; i++) {
            res[i] = new ArrayList<T>();
        }
        return res;
    }
}


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

public class Solution {

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	void solve() throws IOException {
		int r1 = nextPos();
		int r2 = nextPos();
		int wk = nextPos();
		int bk = nextPos();
		int r1x = r1 / 8;
		int r1y = r1 % 8;
		int r2x = r2 / 8;
		int r2y = r2 % 8;
		int wkx = wk / 8;
		int wky = wk % 8;
		int bkx = bk / 8;
		int bky = bk % 8;
		for (int dx = -1; dx <= 1; ++dx) {
			for (int dy = -1; dy <= 1; ++dy) {
				int x = bkx + dx;
				int y = bky + dy;
				if (x >= 0 && x < 8 && y >= 0 && y < 8 &&
					(x != r1x && y != r1y || x == r1x && y == r1y) &&
					(x != r2x && y != r2y || x == r2x && y == r2y) &&
					Math.max(Math.abs(x - wkx), Math.abs(y - wky)) > 1) {
					out.println("OTHER");
					return;
				}
			}
		}
		out.println("CHECKMATE");
	}

	private int nextPos() throws IOException {
		String s = next();
		return (s.charAt(0) - 'a') * 8 + s.charAt(1) - '1';
	}

	Solution() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		eat("");

		solve();

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

	private void eat(String str) {
		st = new StringTokenizer(str);
	}

	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}

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

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

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

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


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

public class NewYear
{
      public static void main(String[] args)
      {
            Scanner sc = new Scanner(System.in);
            String s = sc.next();
            int c = 0;
            char[] ch = s.toCharArray();

            for(int i=0;i<s.length();i++)
            {
                  if(ch[i] == 'a' || ch[i] == 'e' || ch[i] == 'i' || ch[i] == 'o' || ch[i] == 'u')
                  {
                        c++;
                  }
                  else if(ch[i] == '1' || ch[i] == '3' || ch[i] == '5' || ch[i] == '7' || ch[i] == '9')
                  {
                        c++;
                  }
            }

            System.out.println(c);
}


import java.util.Scanner;

/**
 * Created by kirh on 02.02.2017.
 */
public class Round {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int z = scanner.nextInt();
        int i = n;
        int result = 0;
        while (i < z){
            int j = m;
            while (j < z){
                if (i == j)
                    result++;
            }
            i += n;
        }
        System.out.print(result);
    }
}


import java.util.Scanner;

/**
 *
 * @author HoBaa
 */
public class Calls {
    public static void main(String[] args) {
        Scanner s =new Scanner(System.in);
        long x=0;
        long n =s.nextLong();
        long m =s.nextLong();
        long z =s.nextLong();
        for(int i=0;i<=z;i+=n){
            for (int j=0;j<=i;i+=m){
                if(i==j&&i+j!=0)
                    x++;
            }
        }
        System.out.println(x);
    }

}


import java.util.*;
public class MaximBuysAnApartment
{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int min=Integer.MAX_VALUE;
		int max=Integer.MIN_VALUE;
		int n=sc.nextInt();
		int k=sc.nextInt();
		if(n==k)
		{
			System.out.println("0 0");
		}

		else if(k==0)
		{
			System.out.println("0 0");
		}
		else
		{
			min=1;
			int count=0;
			int a[]=new int[n];
			if(count<k)
			{
				for(int i=1;i<n;i=i+3)
				{
					a[i]=1;
					count++;
					if(count==k)
					{
						break;
					}
				}
			}

			if(count<k)
			{
				for(int i=n-1;i>=0;i--)
				{
					if(a[i]==0)
					{
						a[i]=1;
						count++;
						if(count==k)
						{
							break;
						}
					}
				}
			}
//			for(int i=0;i<n;i++)
//			{
//				System.out.print(a[i]+" ");
//			}
//			System.out.println();
			int count1=0;
			for(int i=0;i<n;i++)
			{
				if(i==0 && a[i+1]==1 && a[i]==0)
				{
					count1++;
				}
				if((i>0 && i<n-1))
				{
					if(a[i]==0 && (a[i+1]==1||a[i-1]==1))
					count1++;
				}

				else if(i==n-1 && a[n-2]==1 && a[i]==0)
				{
					count1++;
				}
			}

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


//package acc;
import java.util.*;
import java.io.*;
import java.math.BigInteger;
   public  class ACC {
//************Main*****************//
        static long arr[][]=new long[30001][600];
        static int gems[]=new int[30001];
        static int d=0,a=0;

        static long solve(int ind,int l){
            if(ind>30000||ind>a) return 0;
            if(arr[ind][l+300]!=-1) return arr[ind][l+300];
            long ans1=solve(ind+d+l,l);
            long ans2=solve(ind+d+l+1,l+1);
            long ans3=0;
            if(d+l>1) ans3=solve(ind+d+l-1,l-1);
            long ans=gems[ind]+Math.max(ans1, Math.max(ans2, ans3));
            return arr[ind][l+300]=ans;
        }
         public static void main(String[] args) throws IOException
			 {
             //   PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
              //  Scanner in=new Scanner (System.in);
               InputStream inputStream = System.in;
                OutputStream outputStream = System.out;
                InputReader in = new InputReader(inputStream);
                PrintWriter out = new PrintWriter(outputStream);
                long c=in.nextInt(),hr=in.nextInt(),hb=in.nextInt(),wr=in.nextInt(),wb=in.nextInt();
                double val1=(double)hr/wr;
                double val2=(double)hb/wb;
                if(val2>val1){
                    long t=hr;
                    hr=hb;
                    hb=t;
                    t=wr;
                    wr=wb;
                    wb=t;
                }
                if(wr>c) out.print(c/wb*hb);
                else{
                    long rem=c%wr;
                    long x=(rem*hb)/(hr*wb-hb*wr);
                    long numr=c/wr;
                    long ans=numr*hr+(rem/wb)*hb;

                    for(int i=1;i<=x&&i<=numr;i++){
                        long y=(rem+i*wr)/wb;
                        long ans1=(numr-i)*hr+y*hb;
                        if(ans1>ans) ans=ans1;
                    }
                    out.print(ans);
                }
                out.close();
         }

   }
    class Pair implements Comparable<Pair>{
    int x,y;
    public  Pair(int X,int Y){
        super();
x=X;
y=Y;
}
    @Override
      public int compareTo(Pair p){
          if((x)==(p.x)) return Integer.compare((y), (p.y));
       return Integer.compare((x), (p.x));
}
  }

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

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

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

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


import java.util.Scanner;

public class A363 {

    public static void main(String[] args) {
        Scanner36 in = new Scanner(System.in);
        int n = in.nextInt();
        String digits[] = { "O-|-OOOO", "O-|O-OOO", "O-|OO-OO", "O-|OOO-O",
                "O-|OOOO-", "-O|-OOOO", "-O|O-OOO", "-O|OO-OO", "-O|OOO-O",
                "-O|OOOO-" };
        if (n == 0) {
            System.out.println(digits[0]);
            return;
        }
        while (n > 0) {
            System.out.println(digits[n % 10]);
            n /= 10;
        }

    }

}


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

public class medium2 {
	public static void main(String[] args) throws Exception {
		FastScanner in = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		long n = in.nextLong();
		ArrayList<Long> primes = new ArrayList<>();
		if (n % 2l == 0) {
			primes.add(2l);
            while (n % 2l == 0) {
                n /= 2l;
            }
		}
		if (n % 3l == 0) {
			primes.add(3l);
            while (n % 3l == 0) {
                n /= 3l;
            }
		}
        for (long i = 3; i <= Math.sqrt(n); i += 2) {
            if (n % i == 0) {
                primes.add(i);
                while (n % i == 0) {
                    n /= i;
                }
            }
        }
        if (n != 1l) primes.add(n);
        if (primes.size() >= 2l) pw.println(1l);
        else pw.println(primes.get(0));
		pw.close();
	}
}

@SuppressWarnings("all")
class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

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

    String nextToken() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

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


import java.io.*;
import java.util.*;
public class train
{
	public static void main(String[] Args)
	{
		Scanner p = new Scanner(System.in);
		int n=p.nextInt();
		int me=p.nextInt();
		int tt=p.nextInt();
		Scanner pp=new Scanner(System.in);
		String move=pp.nextLine();
		String Schedule= pp.nextLine();
		char minute[]= new char[Schedule.length()];
		int ttmove=0;
		if(move.charAt(3)=='h')
		{
			ttmove=-1;
		}
		else
		{
			ttmove=1;
		}
		int c=0;
		while((c<Schedule.length())&&(me!=tt))
		{
			if(Schedule.charAt(c)=='0')
			{
				if(me>tt)
				{
					if(me!=n)
					{
						me++;
					}
					else
					{
						if((me-1)!=tt)
						{
							;
						}
					}
				}
				else
				{
					if(me!=1)
					{
						me--;
					}
					else
					{
						;
					}
				}
			}
			else
			{
				if((ttmove==1)&&(tt!=1))
				{
					me=tt-1;
				}
				else if((ttmove==-1)&&(tt!=n))
				{
					me=tt+1;
				}
				else
				{
					me+=ttmove;
				}
			}
			c++;
			tt+=ttmove;
			if(tt==n)
			{
				ttmove=-1;
			}
			else if(tt==1)
			{
				ttmove=1;
			}
		}
		if(c==Schedule.length())
		{
			System.out.println("Stowaway");
		}
		else
		{
			System.out.println("Controller "+c);
		}
	}
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package srm68;

import java.util.Scanner;

/**
 *
 * @author dody
 */
public class ProbB {
    int n,c,s;
    String dir;

    public void moveC(){
        if(dir.equals("to head") && n !=1)
                c--;
            else if(n != 1)
                c++;

            if(c == 0){
                c = 2;
                dir = "to tail";
            }
            if(c == n + 1){
                c = n-1;
                dir = "to head";
            }
    }

    public void moveS(){
        int r = Math.abs(c-(s+1));
        int l = Math.abs(c-(s-1));
        if(r > l){
            if(s+1 <= n )
                s++;
        }else{
            if(s-1 > 0)
                s--;
        }
    }

    public void enterTrain(){
        if(dir.equals("to head")){
            if(c != n)
                s = n;
            else
                s = 1;
        }else{
            if(c != 1)
                s = 1;
            else
                s = n;
        }
    }
    public void run(){
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        s = scanner.nextInt();
        c = scanner.nextInt();
        scanner.nextLine();
        dir = scanner.nextLine();
        String timeLine = scanner.nextLine();

        for (int i = 0; i < timeLine.length(); i++) {
            if(timeLine.charAt(i) == '0'){
                moveS();
                moveC();
                if(c == s){
                    System.out.println("Controller "+(i+1));
                    return;
                }

            }else{
                s = -1;
                moveC();
                enterTrain();
                if(c == s){
                    System.out.println("Controller "+(i+1));
                    return;
                }
            }
        }
        System.out.println("Stowaway");
    }
    public static void main(String[] args){
        new ProbB().run();
    }
}


import java.util.Arrays;
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
     	Scanner sc=new Scanner(System.in);
	int a[]=new int[6];
	for(int i=0;i<6;i++)a[i]=sc.nextInt();
	Arrays.sort(a);
	int a1=0,a2=0,a3=0;
	for(int i=0;i<6;i++)
        {
		if(a[3]==a[i] && a1<4)
			a1++;
		else
                {
			if(a2==0)c2=a[i];
                        else a3=a[i];
                }
	}

        if(a2<a3 && a1==4)System.out.println("Bear");
	else if(a2==a3 && a1==4)System.out.println("Elephant");
        else System.out.println("Alien");
    }
}


import java.util.Scanner;

public class C357A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = Integer.parseInt(sc.nextLine().trim());
		boolean answer = false;

		boolean[] b = new boolean[1000000001];
		b[0] = true;
		for(int a=1; a<=1000000000; a++){
			if((a>=1234 && b[a-1234])||(a>=123456 && b[a-123456])||(a>=1234567 && b[a-1234567])){
				b[a] = true;
			}
		}

		/*while(i>0){

		}*/
		if(b[i]){
			System.out.print("YES");
		}
		else{
			System.out.print("NO");
		}
	}

}


import java.util.Scanner;
public class a{

    public static void main(String []a){
        public int sumDigits(int x){
            if(x<10)return x;
            else return sumDigits(x/10) +(x-(x/10)*10);
        }
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for(int i=0 ;true;i++){
            if(sumDigits(n+i)%4==0)
                    System.out.print(n+i);

        }

    }

}


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

public class findamir {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		System.out.println((n-1)/2);

	}
}


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

public class C {
  private static class Task {
    boolean check(long n, long p) {
      long ans = 0;
      for (long k = 2; k * k * k <= n; k++) {
        ans += n / (k * k * k);
        if (ans > p) break;
      }
      return ans == p;
    }

    void solve(FastScanner in, PrintWriter out) {
      long p = in.nextLong();

      long h = 100000000000000;
      long l = 0;
      while (h - l > 1) {
        long n = (h + l) / 2;
        long ans = 0;
        for (long k = 2; k * k * k <= n; k++) {
          ans += n / (k * k * k);
          if (ans > p) break;
        }
        if (ans >= p) {
          h = n;
        } else {
          l = n;
        }
      }

      for (long n = Math.max(1, l + 1 - 10); n < l + 1 + 10; n++) {
        if (check(n, p)) {
          out.println(n);
          return;
        }
      }
      out.println(-1);
    }
  }

  // Template
  public static void main(String[] args) {
    OutputStream outputStream = System.out;
    FastScanner in = new FastScanner();
    PrintWriter out = new PrintWriter(outputStream);
    Task solver = new Task();
    solver.solve(in, out);
    out.close();
  }
  private static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int bufferLength = 0;

    private boolean hasNextByte() {
      if (ptr < bufferLength) {
        return true;
      } else {
        ptr = 0;
        try {
          bufferLength = in.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (bufferLength <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) return buffer[ptr++];
      else return -1;
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    boolean hasNext() {
      skipUnprintable();
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

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

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

    double[][] nextDoubleMap(int n, int m) {
      double[][] map = new double[n][];
      for (int i = 0; i < n; i++) {
        map[i] = nextDoubleArray(m);
      }
      return map;
    }

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

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


import java.io.*;
import java.util.Scanner;
public class Main {
public static void main(String args[])throws IOException
{
	Scanner s1=new Scanner(System.in);
	int n=Integer.parseInt(s1.next());
	int counter=0;
	for(int a=1;a<=n;a++)
	{
		for(int b=a+1;b<=n;b++)
		{
			for(int c=b+1;c<=n;c++)
			{
				if((a*a)+(b*b)==(c*c))
					counter++;
			}
		}
	}
	System.out.println(counter);
}
}


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

public class D {

	static final int P = 1_000_000_007;

	static final int N = 52;

	void submit() {
		int n = nextInt();
		int m = nextInt();

		int[][] f = new int[N + 1][N + 1];

		f[0][1] = 1;

		for (int sz = 1; sz <= n; sz++) {

			int[][] dp = new int[sz + 1][N + 1];
			dp[0][1] = 1;

			int[][] cnt = new int[sz + 1][N + 1]; // [size][cut]

			for (int szL = 0; szL + 1 <= sz; szL++) {
				for (int cutL = 1; cutL <= N; cutL++) {
					for (int szR = 0; szL + szR + 1 <= sz; szR++) {
						for (int cutR = 1; cutR <= N; cutR++) {

							int szLR = szL + szR + 1;
							int cutLR = Math.min(cutL, cutR);

							cnt[szLR][cutLR] += (int) ((long) f[szL][cutL]
									* f[szR][cutR] % P);
							if (cnt[szLR][cutLR] >= P) {
								cnt[szLR][cutLR] -= P;
							}
						}
					}
				}
			}

//			System.err.println("sz = " + sz);
//			for (int i = 0; i < cnt.length; i++) {
//				for (int j = 0; j < cnt[i].length; j++) {
//					if (cnt[i][j] != 0) {
//						System.err.println(i + " " + j + " --> " + cnt[i][j]);
//					}
//				}
//			}

			for (int addSz = 1; addSz <= sz; addSz++) {
				for (int addCut = 1; addCut <= N; addCut++) {

					int[][] nextDp = new int[sz + 1][];
					for (int i = 0; i <= sz; i++) {
						nextDp[i] = dp[i].clone();
					}

					for (int cntAdd = 1; cntAdd <= sz; cntAdd++) {

						int ways = getCoef(cnt[addSz][addCut], cntAdd);

						for (int i = sz; i >= 0; i--) {
							for (int j = N; j >= 1; j--) {

								if (i + addSz * cntAdd <= sz
										&& j + addCut * cntAdd <= N) {

									nextDp[i + addSz * cntAdd][j + addCut * cntAdd] += (int) ((long) dp[i][j]
											* ways % P);
									if (nextDp[i + addSz * cntAdd][j + addCut
											* cntAdd] >= P) {
										nextDp[i + addSz * cntAdd][j + addCut
												* cntAdd] -= P;
									}

								}

							}
						}

					}

					dp = nextDp;

				}
			}

			for (int j = 1; j <= N; j++) {
				f[sz][j] = dp[sz][j];
			}

		}
//
//		for (int i = 0; i <= n; i++) {
//			for (int j = 1; j <= N; j++) {
//				if (f[i][j] != 0) {
//					System.err.println(i + " " + j + " -> " + f[i][j]);
//				}
//			}
//
//			System.err.println();
//		}

		out.println(f[n][m]);

	}

	int[] inv = new int[1000];
	{
		inv[0] = 0;
		inv[1] = 1;
		for (int i = 2; i < inv.length; i++) {
			inv[i] = P - (int) ((long) (P / i) * inv[P % i] % P);
		}
	}

	int getCoef(int x, int y) {

		// y into x summands
		// C(x+y-1, y)
		int ret = 1;
		for (int i = 0; i < y; i++) {
			int lol = Math.floorMod(x + y - 1 - i, P);
			ret = (int)((long)ret * lol % P * inv[i + 1] % P);
		}

//		System.err.println(x + " " + y + " -> " + ret);

		return ret;
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	D() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

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

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

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

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

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


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

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		BigInteger k = in.nextBigInteger();
		BigInteger b = in.nextBigInteger();
		int n = in.nextInt();
		BigInteger t = in.nextBigInteger();

		BigInteger f[] = new BigInteger[n+1];
		f[0] = BigInteger.ONE;
		BigInteger cur = BigInteger.ONE;
		for(int i=1;i<=n;i++){
			cur = cur.multiply(k);
			f[i] = f[i-1].add(cur);
		}

		BigInteger z = cur.add(b.multiply(f[n-1]));
		cur = BigInteger.ONE;
		for(int i=0;i<=n;i++){
			BigInteger c;
			if (i > 0){
				c = cur.multiply(t).add(b.multiply(f[i-1]));
			}else{
				c = t;
			}
			if (c.compareTo(z) >= 0){
				System.out.println(i);
				return;
			}
			cur = cur.multiply(k);
		}
	}
}


import java.util.*;

public class xx  {
	static int a1=0;
	static int a2=0;
	static StringBuilder s1=new StringBuilder();
	public static void main(String   []     args){
	Scanner sc=new Scanner(System.in);
long a=sc.nextLong();
long x=sc.nextLong();
long y=sc.nextLong();

cal(a,x,y);
String s2=s1.toString();
for(long i=x-1;i<y;i++){
	if(s2.charAt((int)i)=='1'){
		a1++;
	}
}
System.out.println(a1);

}
public static void cal(long a,long x,long y){
	if(a<=1){

		s1.append(a);

		return;
	}
	cal(a/2,x,y);
	if(a%2==0){
		s1.append(0);
	}
	else{
		s1.append(1);
	}
	s1.append(s1);
	s1.deleteCharAt(s1.length()-1);
}

}


import java.util.*;
public class MyClass {
     static long mod(long a,long m)
{
	return (a%m + m) % m;
}

    public static void main(String args[]) {
    Scanner s=new Scanner(System.in);
    int x=s.nextInt();
   int y=s.nextInt();
    int n=s.nextInt();
   int i=3;
    long []f=new long[n+1];
    f[1]=x;
    f[2]=y;
    for(i=3;i<=n;i++)
    f[i]=0;
    for(i=3;i<=n;i++)
    {

        f[i]=f[i-1]-f[i-2];
    }

    System.out.println(mod(f[n],1000000007));
    }
}


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

public class Main
{

    //Life's a bitch
    //I'll never stop.
    public static boolean[] sieve(long n)
    {
        boolean[] prime = new boolean[(int)n+1];
        Arrays.fill(prime,true);
        prime[0] = false;
        prime[1] = false;
        long m = (long)Math.sqrt(n);
        for(int i=2;i<=m;i++)
        {
            if(prime[i])
            {
                for(int k=i*i;k<=n;k+=i)
                {
                    prime[k] = false;
                }
            }
        }
        return prime;
    }

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

    static long CountCoPrimes(long n)
    {
        long res = n;
        for(int i=2;i*i<=n;i++)
        {
            if(n%i==0)
            {
                while(n%i==0)
                {
                    n/=i;
                }
                res-=res/i;
            }
        }
        if(n>1)
        {
            res-=res/n;
        }
        return res;
    }

    long expo(long a,long  b)
    {
        long result = 1;

          while (b>0){
            if ((b%2)==1){
              result *= a;
            }
            b >>=1 ;
            a *= a;
          }

      return result;
    }

    static boolean isSorted(int[] a)
    {
        for(int i=0;i<a.length-1;i++)
        {
            if(a[i]>a[i+1])
            {
                return false;
            }
        }
        return true;
    }

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

        new Main().run();

    }

    static long LCM(long a,long b)
    {
        return (a*b)/GCD(a,b);
    }

    Scanner in = new Scanner(System.in);
    // static int[] arr,tree[],lev;
    void run() throws IOException
    {
        long mod = (long)1e9+7;

            long x = nl();
            long y = nl();
            long n = nl();
            long[] dp = new long[(int)n+1];
            dp[1] = x;
            // printL(dp[1]);
            dp[2] = y;
            for(int i=2;i<n;i++)
            {
                dp[i+1] = dp[i] - dp[i-1];
                // printL(dp[i-1]);

            }

            if(dp[(int)n]<0){
                printL(mod+dp[(int)n]);
            }
            else{
                printL(dp[(int)n]%mod);
            }

    }

    //xor range query
    static long xor(long n)
    {

        if(n%4==0)
        {
            return n;
        }
        if(n%4==1)
        {
            return  1;
        }
        if(n%4==2)
        {
            return n+1;
        }
        return 0;
    }

    static long xor(long a,long b)
    {
        return xor(b)^xor(a-1);
    }

     void printL(long a)
    {
        System.out.println(a);
    }
    void printS(String s)
    {
        System.out.println(s);
    }

     void printD(Double d)
    {
        System.out.println(d);
    }

    static void swap(char[] c,int a,int b)
    {
        char t = c[a];
        c[a] = c[b];
        c[b] = t;
    }

    static long max(long n,long m)
    {
        return Math.max(n,m);
    }
    static long min(long n,long m)
    {
        return Math.min(n,m);
    }

    double nd() throws IOException
    {
        return Double.parseDouble(in.next());
    }
    int ni() throws IOException
    {
        return Integer.parseInt(in.next());
    }

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

    String si() throws IOException
    {
        return in.next();
    }

    static long abs(long n)
    {
        return Math.abs(n);
    }

    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 boolean ready() throws IOException {return br.ready();}

    }

}

class Pair implements Comparable<Pair>
{
   int x,y;
    public Pair(int x,int y)
    {
        this.x = x;
        this.y = y;
    }
    public int compareTo(Pair o)
    {
        if(o.x==this.x)
        {
            return this.y-o.y;
        }
        return this.x-o.x;
    }
}


import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

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

    private static String result, line;
    private static Scanner in;

    public static void main(String[] args) {
        in = new Scanner(System.in);
        isTrue(0, 0);
        System.out.println(result);

    }

    public static void isTrue(int score1, int score2) {
        if (!in.hasNext()) {
            if (score1 == score2) {
                result = "YES";
            }else{
                result = "NO";
            }
            return;
        }
        line = in.next();
        Pattern p = Pattern.compile("(BW){4}");
        Pattern p1 = Pattern.compile("(WB){4}");
        Matcher m = p.matcher(line);
        Matcher m1 = p1.matcher(line);
        if (m.find()) {
            score1++;
            isTrue(score1, score2);
        } else if (m1.find()) {
            score2++;
            isTrue(score1, score2);
        } else {
            result = "NO";
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            String s = in.next();
            char[] a1 = s.toCharArray();
            //char[] a2= Arrays.copyOf(a1,n);
            if (n == 1 && a1[0]=='?') {
                out.println("Yes");
                return;
            }
            int c1 = 0;
            for (int i = 1; i < n; i++) {
                if (a1[i] != '?') {
                    if (a1[i] == a1[i - 1]) {
                        out.println("No");
                        return;
                    }
                } else c1++;
            }
            if(a1[0]=='?')c1++;
            if(a1==0)
            {
                out.println("No");
                return;
            }
            if (a1[0] == '?' || a1[n - 1] == '?') {
                out.println("Yes");
                return;
            }
            int cnt = 0;
            for (int i = 1; i < n - 1; i++) {
                if (a1[i] == '?') {
                    if (a1[i - 1] != a1[i + 1] && a1[i - 1] != '?' && a1[i + 1] != '?') {
                        cnt++;
                    } else {
                        cnt = Integer.MIN_VALUE;
                    }
                }
            }
            if (cnt >= 0) {
                out.println("No");
                return;
            }
            out.println("Yes");
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

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

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

    }

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

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

        public int read() {

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

        public int 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 String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

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

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

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

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

        }

    }
}


import static java.lang.Long.max;
import static java.lang.Math.abs;
import java.math.BigInteger;
import java.util.Scanner;

public class NewClass {
    static long x,y,d;
    public static long mcd(long a, long b){
        return a==0 ? b : mcd(b%a,a);
    }

    public static long mcm(long a,long b){
     return a*(b/mcd(a,b));
    }

    public static void extendedEuclid(long a, long b){
        if(a==0){x=0;y=1;d=b;return;}
        extendedEuclid(b%a,a);
        long x1=y-(b/a)*x;
        long y1=x;
        x=x1;
        y=y1;
      }

    public static void main(String[] args) {
        long a1,b1,a2,b2,l,r;
        Scanner sc = new Scanner(System.in);
        a1 = sc.nextInt();
        b1 = sc.nextInt();
        a2 = sc.nextInt();
        b2 = sc.nextInt();
        l = sc.nextInt();
        r = sc.nextInt();
        extendedEuclid(a1,a2);
        if(abs(b2-b1)%d!=0){
            System.out.println("0");
            return;
        }
        x*=((b2-b1)/d);
        y*=((b2-b1)/d);
        d=b2-b1;
        BigInteger Bx = new BigInteger(Double.toString((x)));
        BigInteger Ba1 = new BigInteger(Double.toString((a1)));
        BigInteger Bb1 = new BigInteger(Double.toString((b1)));
        Long jaux=mcm(a1,a2);
        BigInteger j = new BigInteger(jaux.toString());
        BigInteger p= new BigInteger("");
        p =  Bx.multiply(Ba1).add(Bb1);
        Long a=max(b1,b2);
        BigInteger aa = new BigInteger(a.toString());
        if( p.compareTo(aa) < 0){
            BigInteger aux=(p.subtract(aa)).abs();
            aux = aux.divide(j);
            aux = aux.add(BigInteger.ONE);
            p = p.add(aux.multiply(j));
        }
        if(p.compareTo(aa)>0){
            BigInteger aux=(p.subtract(aa)).divide(j);
            p = p.subtract(aux.multiply(j));
        }
        l = l - Long.parseLong(p.toString()) + Long.parseLong(j.toString());
        r = r - Long.parseLong(p.toString()) + Long.parseLong(j.toString());
        long res;
        l=max(0,l);
        r=max(0,r);
        res = r/Long.parseLong(j.toString()) - l/Long.parseLong(j.toString());
        if(l%Long.parseLong(j.toString())==0){
            if(l!=0)res++;
        }

        System.out.println(res);

    }
}


import java.util.HashMap;

import java.util.Scanner;

public class LadderB {

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

	public static void main(String[] args) {
        suffixStructures();
    }

public static void suffixStructures(){
		String s = scn.next(), t = scn.next();

		HashMap<Character,Integer> map = new HashMap<>();

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

			char ch = s.charAt(i);
			if(map.containsKey(ch)){
				map.put(ch, map.get(ch)+1);
			} else{
				map.put(ch, 1);
			}
		}

		boolean check = true;
		StringBuilder str = new StringBuilder();

		for(int i = 0; i<t.length();i++){
			char ch = t.charAt(i);

			if(!map.containsKey(ch)){
				check = false;
				break;
			} else {
				if(map.get(ch) == 1){
					map.remove(ch);
				} else {
					map.put(ch, map.get(ch)-1);
				}

				str.append(ch);
			}
		}

		String st = str.toString();

//		System.out.println(st);
		if(!check){
			System.out.println("need tree");
		} else{
			if(map.size()==0){
				System.out.println("array");
			} else{
				boolean see = subset(st,s,"");

				if(see){
					System.out.println("automaton");
				} else{
					System.out.println("both");
				}
			}
		}
	}

	public static boolean subset(String check, String ques, String ans){

		if(0 == ques.length()){

			if(check.equals(ans)){
				return true;
			} else{
				return false;
			}
		}

		boolean one = subset(check,ques.substring(1),ans+ques.charAt(0));

		if(one){
			return true;
		}

		boolean two = subset(check,ques.substring(1),ans);

		if(two){
			return true;
		}

		return false;
	}
}


import java.util.Arrays; import java.util.Scanner; public class cf401d_10DIMENSIONSBABY { static int[] digitcounts = new int[10]; static int len, mod; static long[][][][][][][][][][][] memo; public static long dp(int[] counts, int cmod) { if (memo[counts[0]][counts[1]][counts[2]][counts[3]][counts[4]][counts[5]][counts[6]][counts[7]][counts[8]][counts[9]][cmod] != -1) { return memo[counts[0]][counts[1]][counts[2]][counts[3]][counts[4]][counts[5]][counts[6]][counts[7]][counts[8]][counts[9]][cmod]; } long tot = 0; // try adding each digit for (int i = 0; i < 10; i++) { if (counts[i] < digitcounts[i]) { counts[i]++; // System.out.println(cmod + " --(" + i + ")--> " + (((10 * // cmod) + i) % mod)); tot += dp(counts, ((10 * cmod) + i) % mod); counts[i]--; } } memo[counts[0]][counts[1]][counts[2]][counts[3]][counts[4]][counts[5]][counts[6]][counts[7]][counts[8]][counts[9]][cmod] = tot; return tot; } public static long fact(int i) { long res = 1; for (int j = 2; j <= i; j++) res *= j; return res; } public static void main(String[] args) { Scanner s = new Scanner(System.in); long N = s.nextLong(); mod = s.nextInt(); String Nrep = "" + N; len = Nrep.length(); for (char i : Nrep.toCharArray()) digitcounts[i - '0']++; memo = new long[digitcounts[0] + 1][digitcounts[1] + 1][digitcounts[2] + 1][digitcounts[3] + 1][digitcounts[4] + 1][digitcounts[5] + 1][digitcounts[6] + 1][digitcounts[7] + 1][digitcounts[8] + 1][digitcounts[9] + 1][mod]; for (long[][][][][][][][][][] a : memo) for (long[][][][][][][][][] b : a) for (long[][][][][][][][] c : b) for (long[][][][][][][] d : c) for (long[][][][][][] e : d) for (long[][][][][] f : e) for (long[][][][] g : f) for (long[][][] h : g) for (long[][] i : h) for (long[] j : i) Arrays.fill(j, -1); Arrays.fill( memo[digitcounts[0]][digitcounts[1]][digitcounts[2]][digitcounts[3]][digitcounts[4]][digitcounts[5]][digitcounts[6]][digitcounts[7]][digitcounts[8]][digitcounts[9]], 0); memo[digitcounts[0]][digitcounts[1]][digitcounts[2]][digitcounts[3]][digitcounts[4]][digitcounts[5]][digitcounts[6]][digitcounts[7]][digitcounts[8]][digitcounts[9]][0] = 1; long res = 0; for (int i = 1; i < 10; i++) { if (digitcounts[i] != 0) { int[] count = new int[10]; count[i]++; res += dp(count, i % mod); } } System.out.println(res); s.close(); } }


package tryAndLean;

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

public class Main {
	static final Integer N = Integer.valueOf(1000010), MOD = Integer.valueOf(1000000007);

	public static Integer mul(Integer x, Integer y) {
		Long ret = Long.valueOf(x.intValue());
		ret = (ret * y) % MOD;
		return Integer.valueOf(ret.intValue());
	}

	public static Integer power(Integer basic, Integer times) {
		Integer ret = Integer.valueOf(1);
		while(times > 0) {
			if((times & 1) == 1) ret = mul(ret, basic);
			basic = mul(basic, basic);
			times >>= 1;
		}
		return ret;
	}

	public static Integer[] extGcd(Integer a, Integer b) {
		Integer [] ret = new Integer[3];
		if(b == 0) {
			ret[0] = Integer.valueOf(a.intValue());
			ret[1] = Integer.valueOf(1);
			ret[2] = Integer.valueOf(0);
		} else {
			Integer [] tmp = extGcd(b, a % b);
			Integer g = tmp[0], ta = tmp[2], tb = tmp[1] - a / b * tmp[2];
			if(ta < 0) {
				Integer t = ta / (b / g);
				ta -= t * (b / g);
				tb += t * (a / g);
			}
			if(ta < 0) {
				ta += b / g;
				tb -= a / g;
			}
			ret[0] = g;
			ret[1] = ta;
			ret[2] = tb;
		}
		return ret;
	}

	public static Integer inv(Integer x) {
//		0-> gcd   1->ta    2->tb
//		Integer [] results = extGcd(x, MOD);
//		return results[1];
		return power(x, MOD - 2);
	}

	public static Integer solve(Integer n, Integer m) {
//		System.out.println(n + " " + m);

		Integer [] f = new Integer[m + 3];
		f[0] = Integer.valueOf(0);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++)
			f[i] = Integer.valueOf((f[i - 1] + power(i, m)) % MOD);
//		System.out.println(power(Integer.valueOf(2), Integer.valueOf(100)));

//		for(Integer i = Integer.valueOf(1); i <= m + 2; i++)
//			System.out.print(f[i] + " ");
//		System.out.println("");

		if(n <= m + 2) return f[n];

		Integer [] lagrange = new Integer[m + 3];
		Integer [] fact = new Integer[m + 3];
		fact[0] = Integer.valueOf(1);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++)
			fact[i] = mul(fact[i - 1], i);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++) {
			lagrange[i] = f[i];
			lagrange[i] = mul(lagrange[i], inv(mul(fact[i - 1], fact[m + 2 - i])));
			if(((m + 2 - i) & 1) == 1)
				lagrange[i] = MOD - lagrange[i];
//			System.out.print(lagrange[i] + " ");
		}
//		System.out.println("");

		Integer fullDenominator = Integer.valueOf(1);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++)
			fullDenominator = mul(fullDenominator, n - i);
//		System.out.println(fullDenominator);

		Integer ret = Integer.valueOf(0);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++) {
			Integer denominator = Integer.valueOf(mul(fullDenominator, inv(n - i)));
//			System.out.print(denominator + " ");
			ret = (ret + mul(denominator, lagrange[i])) % MOD;
		}
		return ret;
	}

	public static void main(String[] args) throws IOException {
		Scanner reader = new Scanner(System.in);
		Integer n = new Integer(reader.nextInt());
		Integer k = new Integer(reader.nextInt());

		Integer ans = solve(n, k);

		System.out.println(ans);

		reader.close();
	}
}


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

public class Main {
	static final Integer N = Integer.valueOf(1000010), MOD = Integer.valueOf(1000000007);

	public static Integer mul(Integer x, Integer y) {
		Long ret = Long.valueOf(x.intValue());
		ret = (ret * y) % MOD;
		return Integer.valueOf(ret.intValue());
	}

	public static Integer power(Integer basic, Integer times) {
		Integer ret = Integer.valueOf(1);
		while(times > 0) {
			if((times & 1) == 1) ret = mul(ret, basic);
			basic = mul(basic, basic);
			times >>= 1;
		}
		return ret;
	}

	public static Integer[] extGcd(Integer a, Integer b) {
		Integer [] ret = new Integer[3];
		if(b == 0) {
			ret[0] = Integer.valueOf(a.intValue());
			ret[1] = Integer.valueOf(1);
			ret[2] = Integer.valueOf(0);
		} else {
			Integer [] tmp = extGcd(b, a % b);
			Integer g = tmp[0], ta = tmp[2], tb = tmp[1] - a / b * tmp[2];
			if(ta < 0) {
				Integer t = ta / (b / g);
				ta -= t * (b / g);
				tb += t * (a / g);
			}
			if(ta < 0) {
				ta += b / g;
				tb -= a / g;
			}
			ret[0] = g;
			ret[1] = ta;
			ret[2] = tb;
		}
		return ret;
	}

	public static Integer inv(Integer x) {
//		0-> gcd   1->ta    2->tb
		Integer [] results = extGcd(x, MOD);
		return results[1];
	}

	public static Integer solve(Integer n, Integer m) {
//		System.out.println(n + " " + m);

		Integer [] f = new Integer[m + 3];
		f[0] = Integer.valueOf(0);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++)
			f[i] = Integer.valueOf((f[i - 1] + power(i, m)) % MOD);
//		System.out.println(power(Integer.valueOf(2), Integer.valueOf(100)));

//		for(Integer i = Integer.valueOf(1); i <= m + 2; i++)
//			System.out.print(f[i] + " ");
//		System.out.println("");

		if(n <= m + 2) return f[n];

		Integer [] lagrange = new Integer[m + 3];
		Integer [] fact = new Integer[m + 3];
		fact[0] = Integer.valueOf(1);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++)
			fact[i] = mul(fact[i - 1], i);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++) {
			lagrange[i] = f[i];
			lagrange[i] = mul(lagrange[i], inv(mul(fact[i - 1], fact[m + 2 - i])));
			if(((m + 2 - i) & 1) == 1)
				lagrange[i] = MOD - lagrange[i];
//			System.out.print(lagrange[i] + " ");
		}
//		System.out.println("");

		Integer fullDenominator = Integer.valueOf(1);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++)
			fullDenominator = mul(fullDenominator, n - i);
//		System.out.println(fullDenominator);

		Integer ret = Integer.valueOf(0);
		for(Integer i = Integer.valueOf(1); i <= m + 2; i++) {
			Integer denominator = Integer.valueOf(mul(fullDenominator, inv(n - i)));
//			System.out.print(denominator + " ");
			ret = (ret + mul(denominator, lagrange[i])) % MOD;
		}
		return ret;
	}

	public static void main(String[] args) throws IOException {
		Scanner reader = new Scanner(System.in);
		Integer n = new Integer(reader.nextInt());
		Integer k = new Integer(reader.nextInt());

		Integer ans = solve(n, k);

		System.out.println(ans);

		reader.close();
	}
}


import java.util.*;
import java.io.*;
public class a
{
	public static void main(String[] arg)
	{
		new a();
	}
	public a()
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int bx = in.nextInt();
		String x = "";
		for(int i = 0; i < n; i++)
		{
			x = x+in.next();
		}
		int m = in.nextInt();
		int by = in.nextInt();
		String y = "";
		for(int i = 0; i < m; i++)
		{
			y = y+in.next();
		}
		long op1 = Long.parseLong(x, bx);
		long op2 = Long.parseLong(y, by);
		if(op1 == op2) out.println("=");
		if(op1 < op2) out.println("<");
		if(op1 > op2) out.println(">");
		in.close(); out.close();
	}
}


import java.util.Scanner;

public class Jzzu {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        long x=s.nextLong(),y=s.nextLong();
        int n=s.nextInt();
        long ans=solve(x,y,n);
        System.out.println(ans);
    }

    private static long solve(long x, long y, int n) {
        long[] f=new long[n+1];
        f[0]=x;
        f[1]=y;
        for (int i = 2; i <n ; i++) {
            f[i]= (long) ((f[i-1]-f[i-2]+(Math.pow(10,9)+7))%(Math.pow(10,9)+7));
        }
        return (long) ((long) (f[n-1]+(Math.pow(10,9)+7))%(Math.pow(10,9)+7));

    }
}


/**
 * Program  :   Jzzhu and Sequences
 * Platform :   Codeforces
 * URL      :   http://codeforces.com/problemset/problem/450/B
 * Verdice  :
 */
import java.util.*;

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

        long f_1 = scan.nextLong();
        long f_2 = scan.nextLong();

        int n = scan.nextInt();

        long a[] = new long[(n+1)];
        a[0] = 0;
        a[1] = f_1;
        a[2] = f_2;

        long m = ((int) Math.pow(10,9) + 7);

        for( int i = 3; i <= n; i++){
            a[i] = ((a[i-1]% m + m)%m - (a[i-2]% m + m)%m)%m;
        }

       // System.out.println(a[n]);

        System.out.println((a[n] % m + m ) % m);

    }
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Sequence {

	public static int[] getArray(int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++) {
			array[i] = sr.nextInt();
		}
		return array;
	}

	public static int[][] getMatrix(int sizeI, int sizeJ) {
		int[][] array = new int[sizeI][sizeJ];
		for (int i = 0; i < sizeI; i++) {
			for (int j = 0; j < sizeJ; j++) {
				array[i][j] = sr.nextInt();
			}
		}
		return array;
	}

	public static boolean isSimpleNumber(int val) {
		for (int i = 2; i <= Math.sqrt(val); i++) {
			if (val % i == 0)
				return false;
		}
		return true;
	}

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

	public static int NOK(int a, int b) {
		return a * b / NOD(a, b);
	}

	public static long factorial(int i) {
		long res = 1;
		for (int j = 2; j <= i; j++) {
			res *= j;
		}
		return res;
	}

	static char letters[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
			's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };

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

	public static void main(String[] args) {

		int val = 1000000000 + 7;
		int lastLast = sr.nextInt();
		int last = sr.nextInt();
		int n = sr.nextInt();
		int values[] = new int[n];
		values[0] = lastLast;
		values[1] = last;

		int fn = 0;
		for (int i = 2; i < n; i++) {
			values[i] = values[i - 1] - values[i - 2];
		}

		int res = values[n - 1];
		if (res >= 0) {
			System.out.println(res % val);
		} else {
			System.out.println(val - Math.abs(res));
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Locale;

public class d
{
    private static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static String readln() throws IOException
    {
        String line = input.readLine();
        return line;
    }

    public static void main(String[] args) throws IOException
    {
        Locale.setDefault(Locale.US);
        String input = d.readln();
        String[] entries = input.split("\\s+");

        input = d.readln();
        entries = input.split("\\s+");

        ArrayList<point> pointsA = new ArrayList<>();
        for(int i = 0; i < entries.length; i+=2){
            int x = Integer.parseInt(entries[i]);
            int y = Integer.parseInt(entries[i + 1]);
            pointsA.add(new point(x, y));
        }

        input = d.readln();
        entries = input.split("\\s+");

        ArrayList<point> pointsB = new ArrayList<>();
        for(int i = 0; i < entries.length; i+=2){
            int x = Integer.parseInt(entries[i]);
            int y = Integer.parseInt(entries[i + 1]);
            pointsB.add(new point(x, y));
        }

        int sum1A = 0;
        for(point p : pointsA) {
            int sum = 0;
            for(point p2 : pointsB) {
                // calculate number of meshes
                boolean xMatch = (p.x == p2.x || p.x == p2.y);
                boolean yMatch = (p.y == p2.x || p.y == p2.y);

                if(xMatch ^ yMatch){
                    sum++;
                }
            }
            p.matches = sum;
            if(sum > 1) {
                System.out.println(-1);
                return;
            }
            if(sum == 1){
                sum1A++;
            }
        }

        int sum1B = 0;
        int last = -1;
        for(point p : pointsB) {
            HashSet<Integer> matched = new HashSet<>();
            for(point p2 : pointsA) {
                // calculate number of meshes
                boolean xMatch = (p.x == p2.x || p.x == p2.y);
                boolean yMatch = (p.y == p2.x || p.y == p2.y);

                if(xMatch ^ yMatch){
                    if(xMatch) {
                        last = p.x;
                        matched.add(last);
                    }

                    if(yMatch){
                        last = p.y;
                        matched.add(last);
                    }
                }
            }
            p.matches = matched;
            if(matched.size() > 1) {
                System.out.println(-1);
                return;
            } if (matched.size() == 1){
                sum1B++;
            }
        }

        // Now check how many of the matches == 1. If only one match == 1, print the number that matches.
        if(sum1A == 1 && sum1B == 1){
            System.out.println(last);
            return;
        }

        System.out.println("0");
        // If more than one match == 1, print 0.

    }

    private static class point {
        int x;
        int y;
        HashSet<Integer> matches;

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


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

public class Main {

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

class M{

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

    void solve(){
        P o = new P(in.nextInt() , in.nextInt()) ;
        int x2 = in.nextInt() ;
        int y2 = in.nextInt() ;
        P[] ps = {new P(x2-1,y2-1),new P(x2-1,y2+1),new P(x2+1,y2-1),new P(x2+1,y2+1)} ;
        int res = 0 ;
        for(int i = 0 ; i < ps.length ; i++){
            res = Math.max(res , o.dis(ps[i])) ;
        }
        out.println(Math.max(8 , res*2));
        out.flush();
    }
}

class P{
    int x ;
    int y ;
    P(int x , int y){
        this.x = x ;
        this.y = y ;
    }
    int dis(P o){
        return Math.abs(this.x - o.x) + Math.abs(this.y - o.y) ;
    }
}


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

public class GFG {
	public static void main(String[] args)
	{
		FastReader fi = new FastReader();
	    int n = fi.nextInt();
	    ArrayList<Integer> al1 = new ArrayList<>();
	    ArrayList<Integer> al2 = new ArrayList<>();
        int rem;
        int j=0;
        int num = fi.nextInt();
        while(j != 2 *n)
        {
            j++;
            rem = num %10;
            num/=10;
            if(j <=n)
                al1.add(rem);
            else
                al2.add(rem);
        }

        Collections.sort(al1);
        Collections.sort(al2);
        int last = 0;
        for(int i = 0; i < n; i++){
            if(al1.get(i) < al2.get(i))
            {

                if(last < 0)
                {
                  System.out.print("NO");
                  return;
                }
                last = 1;
            }
            if(al1.get(i) == al2.get(i))
            {
                    System.out.print("NO");
                    return;
            }
            if(al1.get(i) > al2.get(i))
            {

                if(last > 0)
                {
                  System.out.print("NO");
                  return;
                }
                last = -1;
            }

        }

        System.out.print("YES");

	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

	}
}


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

public class A {

	static int[] fac;
	static int N = 500005;
	static int MOD = (int) 1e6 + 3;

	static int multiset(int n, int k) {
		return nck(n + k - 1, k);
	}

	static int nck(int n, int k) {
		if (k > n) {
			return 0;
		}
		int num = fac[n];
		int den = modInverse((int) (fac[k] * 1L * fac[n - k] % MOD));
		return (int) (num * 1L * den % MOD);
	}

	static void proceesFac() {
		fac = new int[N];
		fac[0] = 1;
		for (int i = 1; i < N; i++)
			fac[i] = (int) (i * 1L * fac[i - 1] % MOD);
	}

	static int pow(long b, int e) {
		long ans = 1;
		while (e > 0) {
			if (e % 2 == 1)
				ans = ans * b % MOD;
			e >>= 1;
			b = b * b % MOD;
		}
		return (int) ans;
	}

	static int modInverse(int x) {
		return pow(x, MOD - 2);
	}

	static int starsAndBars(int n, int k) {
		return multiset(n + 1, k - 1);
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), c = sc.nextInt(), ans = 0;
		proceesFac();
		for (int i = 1; i <= n; i++) {
			ans += starsAndBars(i, c);
			if(ans>=MOD)
				ans-=MOD;
		}
		out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

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

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

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

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

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

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

	}

}


import java.util.*;
public class Cakeminator{
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        int r = scn.nextInt();
        int c = scn.nextInt();
        char[][] arr = new char[r][c];
        HashMap<Integer, Integer> listx = new HashMap<>();
        HashMap<Integer, Integer> listy = new HashMap<>();
        for(int i = 0; i < r; i++){
            for(int j = 0; j < c; j++){
                arr[i][j] = scn.next().charAt(0);
                if(arr[i][j] == 'S'){
                    listx.put(i, 0);
                    listy.put(j, 0);
                }
            }
        }
        System.out.println(2 * (listx.size() + listy.size()));
    }
}


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

public class ProblemB {

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

	public static void main(String[] args) throws IOException {
		int n = sc.nextInt(), k = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt()  ;
			x+= x%2 ;
			sum+=x ;
		}
		if(sum<n*8)pw.println("YES");
		else pw.println("NO");
		pw.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();
		}

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


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

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

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

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

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

	}

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

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

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

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

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

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

	}

	static class OutputWriter {
		private final PrintWriter writer;

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

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

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

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

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

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

}


package questao1;

import java.util.Scanner;

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

        int[] lido= new int[scanner.nextInt()];

        for(int i =0; i<lido.length;i++){
            lido[i] = scanner.nextInt();
        }
        int atual = lido[0];;
        for (int y = 1; y < lido.length; y++) {

                int outro = lido[y];

                while (outro >= atual) {
                    atual++;
                    outro--;
                }

        }

        System.out.println(atual - lido[0]);
    }
}


import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

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

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int c = in.nextInt();
        int d = in.nextInt();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();

        int totalRemParticipants = n * m - k;
        if (totalRemParticipants <= 0) {
            out.println('0');
            return;
        }
        int ans = 0;
        if (c <= n * d) {
            if (totalRemParticipants % n == 0) {
                ans = (totalRemParticipants / n) * c;
            } else {
                int rem = Math.abs((totalRemParticipants - n) % n);
                ans = Math.min( (totalRemParticipants / n) * c + c, (totalRemParticipants / n) * c + d * rem);

            }
        }  else {
            ans = d * totalRemParticipants;
        }
        out.println(ans);
    }
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		if (System.getProperty("ONLINE_JUDGE") == null) {
			inputStream = new FileInputStream("input.inp");
			// outputStream = new FileOutputStream("output.out");
		} else {
			inputStream = System.in;
			outputStream = System.out;
		}
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(in, out);
		out.close();
	}

	static final int N = 100005;
	static final int oo = 1000000007;
	static final double pi = Math.acos(-1);

	static class Task {
		public void solve(InputReader in, PrintWriter out) {
			int[] a = new int[3];
			for (int i = 0; i < 3; ++i) a[i] = in.nextInt();
			int ans = 0;
			Arrays.sort(a);
			ans += a[0];
			a[1] -= a[0];
			a[2] -= a[0];
			a[0] = 0;
			while (a[2] != 0 && a[1] + a[2] >= 3) {
				int temp = Math.min(a[2] / 2, a[1]);
				ans += temp;
				a[2] -= temp;
				a[1] -= temp*2;
				Arrays.sort(a);
			}
			out.print(ans);
		}
	}

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

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

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

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

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

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

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


import java.util.*;
public class susbus{
   public static void main(String[] args){
     Scanner in = new Scanner (System.in);

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

    	       if(Math.floor(Math.hypot(a,b))==Math.hypot(a,b))
    	       	 System.out.print("black");

    	       	 else if(a*b>0){

    	       	 	double d=Math.hypot(a,b);

    	       	 	if(Math.floor(d)%2==1)
    	       	 		System.out.print("white");

    	       	 	else if(Math.floor(d)%2==0)
                     	System.out.print("black");

    	       	 }

    	       	 else if(a*b<0){

    	       	 		double d=Math.hypot(a,b);

    	       	 	if(Math.floor(d)%2==0)
    	       	 		System.out.print("white");

    	       	 	else if(Math.floor(d)%2==1)
                     	System.out.print("black");
      }
      }
   }
}


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

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

    static class TaskA {
        int dx = {-1, -1, -1, 0, 0, 1, 1, 1};
        int dy = {-1, 0, 1, -1, 1, -1, 0, 1};

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String input = in.nextLine();
            int x = input.charAt(0) - 'a';
            int y = input.charAt(1) - '0';
            int res = 0;
            for (int i = 0; i < dx.length; i++) {
                int newX = x + dx[i];
                int newY = y + dy[i];
                if (legit(newX) && legit(newY)) {
                    res++;
                }
            }
            out.println(res);
        }

        private boolean legit(int coord) {
            return coord >= 0 && coord < 8;
        }

    }
}


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

public class Solver {

	private void run(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d = in.nextInt();
		HashSet<Long> found = new HashSet<Long>();
		for (int x1 = 1; x1 <= n; x1++) {
			int x2 = x1 - c + b;
			int x4 = x1 - d + a;
			int x5 = x4 + b - c;
			if (inRange(x2, 1, n) && inRange(x4, 1, n) && inRange(x5, 1, n)) {
				long mask = 1;
				mask <<= 17;
				mask |= x1;
				mask <<= 17;
				mask |= x2;
				mask <<= 17;
				mask |= x4;
				found.add(mask);
			}
		}
		out.println(found.size() * n);
	}

	private boolean inRange(int k, int a, int b) {
		return k >= a && k <= b;
	}

	public static void main(String[] args) {
		Solver solver = new Solver();
		InputReader in;
		if (LOCAL) {
			in = new InputReader(solver.getClass().getResourceAsStream("input"));
		} else {
			in = new InputReader(System.in);
		}
		PrintWriter out = new PrintWriter(System.out);
		solver.run(in, out);
		out.flush();
		out.close();
	}

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

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

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

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

	private static final boolean LOCAL = true;
}


import java.util.*;
import java.io.*;
public class divis
{
    public static void main(String[] args)
    {
    Scanner sc = new Scanner(System.in);

    long a = sc.nextLong();
    int counter =0;
    int flag=0;

counter=a/2520;

    System.out.println(counter);

}
}


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

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

            int n = sc.nextInt();

            int ans = 0,p=1,q=0;

            while(q <= n)
            {
                  if(q != 0 && n%q == 0)
                  {
                        ans = q;
                  }

                  q = (Math.pow(2,p)-1)*Math.pow(2,p-1);
                  p++;
            }

            System.out.println(ans);

      }
}


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

	public static void main(String[] args)  throws java.lang.Exception
    {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine()),x=0;
		StringTokenizer st = new StringTokenizer(br.readLine());
		int a[]=new int[n];
		while(x<n) {a[x]=Integer.parseInt(st.nextToken());++x;}
		int min=Integer.MAX_VALUE,max=-1;
		for(int i=0; i<n-2; i++) {
			for(int j=0; j<n-1; j++) {
				if(j+1==i+1) max=Math.max(max, a[j+2]-a[j]);
				else max=Math.max(max, a[j+1]-a[j]);

			}
			min=Math.min(min, max);
		}
		System.out.println(min);
    }

}


import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.next();
        char[] a1 = s1.toCharArray();

        String s2 = in.next();
        char[] a2 = s2.toCharArray();

        String s3 = in.next();
        char[] a3 = s3.toCharArray();

        if (a1[1] == a3[1] && a2[0] == a2[2]){
            if (a1[0] == a3[0]){
                if (a1[2] == a3[2]){
                    System.out.println("YES");
                }else{
                    System.out.println("YES");
                }
            }else if (a1[0] == a3[2]){
                if (a1[2] == a3[0]){
                    System.out.println("YES");
                }else{
                    System.out.println("NO");
                }
            }else{
                System.out.println("NO");
            }
        }else{
            System.out.println("NO");
        }

    }

}


import java.util.Scanner;

public class P334C
{

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		int pow = 1;
		while (Math.pow(3, pow) <=n)
		{
			pow ++;
		}
		pow --;
		int counter = 0;
		for (int i=0; i <= pow; i++)
		{
			long number = n;
			int temp = 0;
			while (Math.pow(3, i) <= number)
			{

					number -= Math.pow(3, i);
					temp ++;
			}
			if (number != 0) counter = Math.max(counter, temp+1);
		}
		System.out.println(counter==0?(n/3+(n%3==0?0:1)):counter);

	}

}


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

public class Solution {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
		int a = 0;
		int b = 0;
		int lastA = 0;
		List<Integer> aList = new ArrayList<>();
		List<Integer> bList = new ArrayList<>();
		int result = 0;
        for(int i = 0; i < s.length(); i++) {
			if('Q' == s.charAt(i)) {
				if(b == 0) a++;
				else lastA++;
			}
			else
			if('A' == s.charAt(i)) {
				if(lastA == 0) b++;
				else
				if(a*b != 0) {
					aList.add(a);
					bList.add(b);
					a = lastA;
					b = 1;
					for(int j = 0; j < aList.size(); j++) {
						for(int k = j; k < bList.size(); k++) {
							result += lastA * aList.get(j) * bList.get(k);
						}
					}
					lastA = 0;
				}
			}
		}
		if(a*b != 0) {
			aList.add(a);
			bList.add(b);
			for(int j = 0; j < aList.size(); j++) {
				for(int k = j; k < bList.size(); k++) {
					result += lastA * aList.get(j) * bList.get(k);
				}
			}
		}
		System.out.println(result);
    }
}


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

    public static void main(String[] args)throws IOException {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int []shops=[n];
        for(int i=0;i<n;i++){
            shops[i]=Scan.nextInt();
        }
        Arrays.sort(shops);
        int q=scan.nextInt();
        int []money=[q];
        int left=0;
        int right=n-1;
        for(int i=0;i<q;i++){
            money[i]=Scan.nextInt();
            while (left<right){
                int middle=(left+right)/2;
                if(money[i]<middle){
                    right=middle;
                }else if(money[i])
            }
        }
        while(left<right){
            int middle=(left + right)/2;
            if(arr[mid]==1){
                right =mid;
            }else{
                left=mid+1 ;
            }
        }
        System.out.println(right);
        int [] arr={3,4,6,9,13};
        int numToInsert = 10;
        int left=0;
        int right=length-1;
        while(left<right){
            int mid=(left+right)/2;
            if(arr[mid]<numToInsert){
                left=mid+1;
            }else if(arr[mid]==numToInsert){
                left=mid;
                right=mid;
            }else{
                right=mid;
            }
        }

    }
}


public class Mahipal{
     public static void main(String arr[]){
          Scanner sc = new Scanner(System.in);
          String s = sc.next();
          char c='a';
          String t="";
          for(int i=0;i<s.length();i++)if(s.charAt(i)>c)c=s.charAt(i);
          for(int i=0;i<s.length();i++)if(s.charAt(i)==c)t=t+c;
          System.out.println(t);
     }
}


import static java.util.Arrays.deepToString;

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

public class Main {

    static void solve() {
        int n = nextInt();
        int m = nextInt();
        int x = nextInt();
        int y = nextInt();
        int a = nextInt();
        int b = nextInt();
        int g = gcd(a, b);
        a = a / g;
        b = b / g;
        int xx = 0, yy = 0;
        double x1, y1, x2, y2;
        boolean flag = false;
        for (int i = n; i >= 0; i--) {
            for (int j = m; j >= 0; j--) {
                if (i * b == j * a) {
                    flag = true;
                    xx = i;
                    yy = j;
                    break;
                }
            }
            if (flag) {
                break;
            }
        }
        x1 = x - xx / 2.0;
        x2 = x + xx / 2.0;
        y1 = y - yy / 2.0;
        y2 = y + yy / 2.0;
        if (x1 < 0) {
            x1 = 0;
            x2 = xx;
        }
        if (x2 > n) {
            x2 = n;
            x1 = n - xx;
        }
        if (y1 < 0) {
            y1 = 0;
            y2 = yy;
        }
        if (y2 > m) {
            y2 = m;
            y1 = m - yy;
        }
        System.out.println("" + (int) Math.floor(x1) + " "
                + (int) Math.floor(y1) + " " + (int) Math.floor(x2) + " "
                + (int) Math.floor(y2));
    }

    static int gcd(int a, int b) {
        int r;
        if (a < b) {
            int temp = a;
            a = b;
            b = temp;
        }
        while (a % b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        return b;
    }

    public static void main(String[] args) throws Exception {
        reader = new BufferedReader(new InputStreamReader(System.in));
        writer = new PrintWriter(System.out);

        setTime();
        solve();
        printTime();
        printMemory();

        writer.close();
    }

    static BufferedReader reader;
    static PrintWriter writer;
    static StringTokenizer tok = new StringTokenizer("");
    static long systemTime;

    static void debug(Object... o) {
        System.err.println(deepToString(o));
    }

    static void setTime() {
        systemTime = System.currentTimeMillis();
    }

    static void printTime() {
        System.err.println("Time consumed: "
                + (System.currentTimeMillis() - systemTime));
    }

    static void printMemory() {
        System.err.println("Memory consumed: "
                + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime()
                        .freeMemory()) / 1000 + "kb");
    }

    static String next() {
        while (!tok.hasMoreTokens()) {
            String w = null;
            try {
                w = reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (w == null)
                return null;
            tok = new StringTokenizer(w);
        }
        return tok.nextToken();
    }

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

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

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

    static BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}


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

public class D {

	private static StringTokenizer tokenizer;
    private static BufferedReader bf;
    private static PrintWriter out;

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

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

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

    private static int gcd(int x, int y) {
    	if(x == 0)   return y;
    	if(y == 0)   return x;
    	if(x > y)   return gcd(y, x % y);
    	else   return gcd(x, y % x);
    }

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

		bf = new BufferedReader(new InputStreamReader(System.in));
    	tokenizer = null;
    	out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    	int n = nextInt();   int m = nextInt();
    	int x = nextInt();   int y = nextInt();
    	int a = nextInt();   int b = nextInt();
    	int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
    	int c = gcd(a, b);
    	int a1 = a/c;   int b1 = b/c;
    	int up = Math.min(n/a1, m/b1);
    	for(int t = up; t > 0; t--) {
    		int max1 = Math.max(0, x - a1*t);
    		int min1 = Math.min(x, n - a1*t);
    		int max2 = Math.max(0, y - b1*t);
    		int min2 = Math.min(y, m - b1*t);
    		if(max1 <= min1 && max2 <= min2) {
    			int indx = 0; double disx = Integer.MAX_VALUE;
    			int indy = 0; double disy = Integer.MAX_VALUE;
    			for(x1 = max1; x1 <= min1; x1++) {
    				if(Math.abs(x1 + (double) a1*t/2.0 - x) < disx) {
    					disx = Math.abs(x1 + (double) a1*t/2.0 - x);
    					indx = x1;
    				}
    			}
    			for(y1 = max2; y1 <= min2; y1++) {
    				if(Math.abs(y1 + (double) b1*t/2.0 - y) < disy) {
    					disy = Math.abs(y1 + (double) b1*t/2.0 - y);
    					indy = y1;
    				}
    			}
    			x1 = indx;   y1 = indy;
    			x2 = indx + a1*t;   y2 = indy + b1*t;
    			break;
    		}
    	}
    	out.print(x1 + " " + y1 + " " + x2 + " " + y2);
    	out.close();
	}

}


package main;

import java.util.Scanner;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int res = 0;
		if (m >= n / 2)
			res = n - m;
		else
			res = m;
		System.out.println(res);
	}

}


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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            char[] v = in.next().toCharArray();
            boolean[] a = new boolean[26];
            int res = 0;
            boolean one = false;
            List<Integer> pos = new ArrayList<>();
            for (int i = 0; i < n; ++i) {
                if (Character.isLowerCase(v[i])) {
                    pos.add(i);
                    one = true;
                }
            }
            for (int i = 0; i < pos.size() - 1; ++i) {
                boolean fail = false;
                for (int j = pos.get(i) + 1; j < pos.get(i + 1); ++j) {
                    if (Character.isUpperCase(v[j])) {
                        fail = true;
                        break;
                    }
                }
                if (!fail) {
                    a[v[pos.get(i)] - 'a'] = a[v[pos.get(i + 1)] - 'a'] = true;
                }
            }
            for (int i = 0; i < 26; ++i) {
                if (a[i]) ++res;
            }
            out.println(one && res == 0 ? 1 : res);
        }

    }

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

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

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

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

    }
}