import java.util.*;
 import java.io.*;
public class MonochromaticBoard {
  public int theMin(String[] board) {
    char [][]b = new char[board.length][];
        for (int i = 0; i < board.length; ++i) {
            b[i] = board[i].toCharArray();
        }
        int res = 0;
        int n = b.length, m = b[0].length;
        if (n < m) {
            boolean painted[] = new boolean[n];
            for (int i = 0; i < n; ++i) {
                boolean ok = true;
                for (char x : b[i]) {
                    ok &= x == 'B';
                }
                if (ok) {
                    ++res;
                    painted[i] = true;
                }
            }
            for (int i = 0; i < m; ++i) {
                for (int j = 0; j < n; ++j) {
                    if (b[j][i] == 'B' && !painted[j]) {
                        ++res;
                        break;
                    }
                }
            }
        } else {
            boolean painted[] = new boolean[m];
            for (int i = 0; i < m; ++i) {
                boolean ok = true;
                for (int j = 0; j < n; ++j) {
                    ok &= b[j][i] == 'B';
                }
                if (ok) {
                    ++res;
                    painted[i] = true;
                }
            }
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    if (b[i][j] == 'B' && !painted[j]) {
                        ++res;
                        break;
                    }
                }
            }
        }
        return res;
  }
  public static void main(String... args) throws Throwable {
      String []board = new String[8];
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      for (int i = 0; i < 8; ++i) board[i]= in.readLine();
      System.out.println(theMin(board));
  }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package codeforces;
import java.util.*;
/**
 *
 * @author Ashraf
 */
public class DVA {
    public static void main(String []args){
        Scanner in=new Scanner(System.in);
        long n=in.nextLong();
        int k=in.nextInt();
        if(k==0){
            System.out.println(n);
        }
        else if(k==1){
            if(n%10==0){
                System.out.println(n);
            }
            else{
                for(int i=1;i<=10;i++){
                    if((n*i)%10==0){
                        System.out.println(n*i);
                        System.exit(0);
                    }
                }
            }
        }
        else if(k==2){
            if(n%100==0){
                System.out.println(n);
            }
            else {
                for(int i=2;i<=100;i++){
                    if((n*i)%100==0&&(n*i)%k==0){
                        System.out.println(n*i);
                        System.exit(0);
                    }
                }
            }
        }
        else if(k==3){
            if(n%1000==0){
                System.out.println(n);
            }
            else {
                 for(int i=3;i<=1000;i++){
                    if((n*i)%1000==0&&(n*i)%k==0){
                        System.out.println(n*i);
                        System.exit(0);
                    }
                }
            }
        }
        else if(k==4){
            if(n%10000==0){
                System.out.println(n);
            }
            else {
                 for(int i=4;i<=10000;i+=4){
                    if((n*i)%10000==0){
                        System.out.println(n*i);
                        System.exit(0);
                    }
                }
            }
        }
        else if(k==5){
            if(n%100000==0){
                System.out.println(n);
            }
            else{
                for(int i=5;i<=100000;i+=5){
                    if((n*i)%100000==0){
                        System.out.println(n*i);
                        System.exit(0);
                    }
                }
            }
        }
        else if(k==6){
            if(n%1000000==0){
                System.out.println(n);
            }
            else{
                for(int i=6;i<=100000;i+=6){
                    if((n*i)%100000==0&&(n*i)%k==0){
                        System.out.println(n*i);
                        System.exit(0);
                    }
                }
            }
        }
        else if(k==7){
            if(n%10000000==0){
                System.out.println(n);
            }
            else{
                for(int i=7;i<=10000000;i+=7){
                    if((n*i)%10000000==0&&(n*i)%k==0){
                        System.out.println(n*i);
                        System.exit(0);
                    }
                }
            }
        }
        else if(k==8){
            if(n%100000000==0){
                System.out.println(n);
            }
            else {
                for(int i=8;i<=125000000;i++){
                    if((n*i)%100000000==0&&(n*i)%k==0){
                        System.out.println(n*i);
                        System.exit(0);
                    }
                }
                System.out.println(n*100000000);
            }
        }
    }
}


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

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

       PrintWriter pw=new PrintWriter(System.out);

       BufferedReader br = new BufferedReader(
                              new InputStreamReader(System.in));

        InputReader in=new InputReader(System.in);

        char[] ch=in.nextLine().toCharArray();
        int n=ch.length;
        if(ch[0]=='0'){
            System.out.println("0");
            return;
        }
        for(int i=1;i<ch.length;i++){
            if(ch[i]=='1'){
                n++;
                break;
            }
        }
        pw.println(n/2);

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

   }

   static class Pair implements Comparable<Pair>{
        int x;
        int y;
        Pair(int a,int b){
            x=a;
            y=b;
        }
        public int compareTo(Pair t){
            if(x>t.x)return 1;
            else if(x==t.x){
                if(y>=t.y)return 1;
                else return -1;
            }
            else return -1;
        }
        public boolean equals(Object obj){
            if(bliss==obj)return true;
            Pair blat=(Pair)obj;
            if(bliss.x==blat.x && bliss.y==blat.y)return true;
            return false;
        }
        public String toString(){
            return bliss.x+" "+bliss.y;
        }
    }
    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, numChars;
        private SpaceCharFilter filter;

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

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

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

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

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

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

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

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

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

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


import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;

public class Frog {

    public static int canFrogReachDestination(final int destination, final int maximumStep, final List<Integer> allowedPaths) {
        final int actualDestination = destination - 1;
        final List<Integer> dp = new ArrayList<>();
        dp.add(0);
        IntStream.range(1, allowedPaths.size()).forEach(x -> dp.add(Integer.MAX_VALUE-10));

        for (int currentPos = 1; currentPos <= actualDestination; currentPos++) {
            if(allowedPaths.get(currentPos)==1) {
                for(int i=currentPos-1;i>=currentPos-maximumStep;i--) {
                    if(i<0) {
                        break;
                    }
                    dp.set(currentPos, Integer.min(dp.get(currentPos), dp.get(i)+1));
                }
            }
        }
        if(dp.get(actualDestination) == Integer.MAX_VALUE-10) {
            dp.set(actualDestination, -1);
        }
        return dp.get(actualDestination);
    }

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

        final int a = scan.nextInt();
        final int b = scan.nextInt();

        final List<Integer> result = new ArrayList<>();

        for(final char i : scan.nextLine().toCharArray()) {
            result.add(Character.getNumericValue(i));
        }
        out.print(canFrogReachDestination(a, b, result));
        out.close();
    }

}


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

public class Main {

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

        java.io.BufferedReader r = new java.io.BufferedReader( new java.io.InputStreamReader( System.in ) );

        String[] tokens = r.readLine().split( " " );

        List<Integer> towerOne = new ArrayList<>();
        List<Integer> towerTwo = new ArrayList<>();

        int max = Math.max( Integer.parseInt( tokens[0] ), Integer.parseInt( tokens[1] ) );
        int min = Math.min( Integer.parseInt( tokens[1] ), Integer.parseInt( tokens[0] ) );

        if ( (max / min) > min ) {
            if (max == Integer.parseInt( tokens[0] )) {
                System.out.println( max * 2 );
            } else {
                System.out.println( max * 3 );
            }

            return;
        }

        for( int i = 0; i < Integer.parseInt( tokens[0] ); i++ ) {
            towerOne.add( (i + 1) * 2 );
        }

        for( int i = 0; i < Integer.parseInt( tokens[1] ); i++ ) {
            towerTwo.add( (i + 1) * 3 );
        }

        for (int i = 1 ; i <= max( towerOne, towerTwo ); i++){
            if ( towerOne.contains( i ) && towerTwo.contains( i ) ){
                if ( height(towerOne) + 2 > height( towerTwo ) + 3 ){
                    towerTwo.add( height( towerTwo ) + 3 );
                } else {
                    towerOne.add( height( towerOne ) + 2 );
                }
            }
        }

        System.out.println( max( towerOne, towerTwo ) );
    }

    private static Integer max(List<Integer> l1, List<Integer> l2){
        if ( l1.size() == 0 ) return l2.get( l2.size() - 1 );
        if ( l2.size() == 0 ) return l1.get( l1.size() - 1 );

        return Math.max( l2.get( l2.size() - 1 ), l1.get( l1.size() - 1 ) );
    }

    private static Integer height(List<Integer> l){
        if (l.size() == 0) {
            return 0;
        } else {
            return l.get( l.size() - 1 );
        }
    }

}


public class Domino {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        if(b==1)
        System.out.print(a-1);
        else
        System.out.print(a*(b-1));
    }
}


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

public class Main {
    public static void main (String [] Args ) throws Exception {
         Scanner sc = new Scanner(System.in);
         int x,y;
         x = sc.nextInt(); y = sc.nextInt();
         if(x==0 || y==0 ) System.out.println("black");
         else {
           int cr = -1;
           if(x>0 && y>0) cr = 0;
           else if(x<0 && y>0) cr = 1;
           else if(x<0 && y<0) cr = 2;
           else if(x>0 && y<0) cr = 3;
           int d = x*x+y*y;
           for(int i=0;i<=1000;++i){
             if(i*i==d) { System.out.println("black"); break;}
             else {
               if(i*i<d && d<i*i+2*i+1){
                 if(cr%2==0 && i%2==0) System.out.println("black");
                 else if(cr%2==0 && i%2==1) System.out.println("white");
                 else if(cr%2==1 && i%2==0) System.out.println("white");
                 else System.out.println("black");

               }

             }
           }

         }

    }
}


import java.util.Scanner;

public class CodeForces835A {
    public static void main(String[] args) {
        try (Scanner s = new Scanner(System.in)) {
System..out.println((s.nextInt()-1)/2);
       }
   }
}


import java.util.Scanner;

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

}


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

     public class Solution implements Runnable
    {

         public  static void solve()
          {

              int n=i();
              int a=0;
              int b=0;
              for(int i=0;i<n;i++)a+=i();
               for(int i=0;i<n;i++)b+=i();
              if(a==b){
                System.out.println("-1");
              } else if(a>b){
                System.out.println("1");
              } else {
                System.out.println(b-a);
              }
          }

          public void run()
          {
              solve();
              out.close();
          }

          public static void main(String[] args) throws IOException
          {
                new Thread(null, new Sample(), "whatever", 1<<26).start();
          }
           static class Pair implements Comparator<Pair>{
            String a;
            long b;
            long c;

            Pair(){}
            Pair(String a,long b,long c)
            {
                       this.a=a;
                       this.b=b;
                       this.c=c;
            }
            public int compare(Pair p1,Pair p2)
            {
               if(p1.c==0 && p2.c==0)
               {
                return Long.compare(p1.b,p2.b);
               }
               if(p1.c==0)
               {
                return -1;
               }
               if(p2.c==0)
               {
                return 1;
               }
               else
              return Long.compare(p2.b*p1.c,p1.b*p2.c);

            }

        }

    ////////////////////////////////////////////////////// Merge Sort ////////////////////////////////////////////////////////////////////////

   static class Merge
   {

        public static void sort(long inputArr[])
        {
            int length = inputArr.length;
            doMergeSort(inputArr,0, length - 1);
        }

        private static void doMergeSort(long[] arr,int lowerIndex, int higherIndex)
        {
            if (lowerIndex < higherIndex) {
                int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
                doMergeSort(arr,lowerIndex, middle);
                doMergeSort(arr,middle + 1, higherIndex);
                mergeParts(arr,lowerIndex, middle, higherIndex);
            }
        }

        private static void mergeParts(long[]array,int lowerIndex, int middle, int higherIndex)
        {
            long[] temp=new long[higherIndex-lowerIndex+1];
            for (int i = lowerIndex; i <= higherIndex; i++)
            {
                temp[i-lowerIndex] = array[i];
            }
            int i = lowerIndex;
            int j = middle + 1;
            int k = lowerIndex;
            while (i <= middle && j <= higherIndex)
            {
                if (temp[i-lowerIndex] < temp[j-lowerIndex])
                {
                    array[k] = temp[i-lowerIndex];
                    i++;
                } else {
                    array[k] = temp[j-lowerIndex];
                    j++;
                }
                k++;
            }
            while (i <= middle)
            {
                array[k] = temp[i-lowerIndex];
                k++;
                i++;
            }
            while(j<=higherIndex)
            {
                array[k]=temp[j-lowerIndex];
                k++;
                j++;
            }
        }

    }

    /////////////////////////////////////////////////////////// Methods ////////////////////////////////////////////////////////////////////////

     static boolean isPal(String s)
     {
        for(int i=0, j=s.length()-1;i<=j;i++,j--)
        {
                if(s.charAt(i)!=s.charAt(j)) return false;
        }
        return true;
     }
     static String rev(String s)
     {
                StringBuilder sb=new StringBuilder(s);
                sb.reverse();
                return sb.toString();
     }
     static int gcd(int a,int b){return (a==0)?b:gcd(b%a,a);}
     static long gcdExtended(long a,long b,long[] x)
     {

        if(a==0){
            x[0]=0;
            x[1]=1;
            return b;
        }
        long[] y=new long[2];
        long gcd=gcdExtended(b%a, a, y);

        x[0]=y[1]-(b/a)*y[0];
        x[1]=y[0];

        return gcd;
    }

     boolean findSum(int set[], int n, long sum)
    {
      if (sum == 0)
         return true;
      if (n == 0 && sum != 0)
         return false;
      if (set[n-1] > sum)
         return findSum(set, n-1, sum);
      return findSum(set, n-1, sum) ||findSum(set, n-1, sum-set[n-1]);
    }

      public static long modPow(long base, long exp, long mod)
     {
        base = base % mod;
        long result = 1;
        while (exp > 0)
       {
            if (exp % 2 == 1)
            {
                result = (result * base) % mod;
            }
            base = (base * base) % mod;
            exp = exp >> 1;
       }
        return result;
    }

    static long[] fac;
    static long[] inv;
    static long mod=(long)1e9+7;
    public static void cal()
    {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= 1000000; i++)
        {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = (inv[i - 1] * modPow(i, mod - 2, mod)) % mod;
        }
    }

    public static long ncr(int n, int r)
    {
        return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
    }

////////////////////////////////////////// Input Reader ////////////////////////////////////////////////////////////////////////////////////////////////////

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

    static class InputReader {

          private final InputStream stream;
          private final byte[] buf = new byte[8192];
          private int curChar, snumChars;
          private SpaceCharFilter filter;

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

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

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

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

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

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

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

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

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

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

    }

    static int i()
    {
        return sc.nextInt();
    }
    static long l(){
        return sc.nextLong();
    }
    static int[] iarr(int n)
    {
        return sc.nextIntArray(n);
    }
    static long[] larr(int n)
    {
        return sc.nextLongArray(n);
    }
    static String s(){
        return sc.nextLine();
    }

 }


import java.util.*;
public class BigInfo
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int res = {1,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0};
System.out.print(res[a]);
}
}


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

public class B236_EasyNumberChallenge {
    public static void main(String[] arg) {
        FastReader sc = new FastReader();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        long sum = 0;
        int[] usedDivisors = new int[a*b*c + 1];

        for (int i=1; i<=a; i++) {
            for (int j=1; j<=b; j++) {
                for (int k=1; k<=c; k++) {
                    if (usedDivisors[i*j*k == 0]) {
                        usedDivisors[i*j*k] = numDivisors(i*j*k);
                    }
                    sum += usedDivisors[i*j*k];
                }
            }
        }
        System.out.println(sum % 1073741824);
    }

    static int numDivisors(int i) {

        int numDivisors = 0;
        for (int j = 1; j < Math.sqrt(i); j++) {
            if (i % j == 0) {
                numDivisors += 2;
            }
        }
        if (i % Math.sqrt(i) == 0) {
            numDivisors++;
        }

        return numDivisors;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

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

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException	{
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int qq = 1;
		//int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++)	{
			Map<Integer, Integer> map = new HashMap<Integer, Integer>();
			for(int i = 0; i < 6; i++) {
				int key = readInt();
				if(!map.containsKey(key)) map.put(key, 0);
				map.put(key, 1 + map.get(key));
			}
			if(map.size() == 1) {
				pw.println("Elephant");
			}
			else if(map.size() > 3) {
				pw.println("Alien");
			}
			else if(map.size() == 3) {
				boolean four = false;
				for(int out: map.keySet()) {
					if(map.get(out) == 4) {
						four = true;
					}
				}
				if(four) {
					pw.println("Bear");
				}
				else {
					pw.println("Alien");
				}
			}
			else {
				boolean four = false;
				boolean fine = false;
				for(int out: map.keySet()) {
					if(map.get(out) == 4) {
						four = true;
					}
					if(map.get(out) == 5) {
						four = true;
					}
				}
				if(five) {
					pw.println("Bear");
				}
				else if(four) {
					pw.println("Elephant");
				}
				else {
					pw.println("Alien");
				}
			}
		}
		pw.close();
	}

	private static void exitImmediately()	{
		pw.close();
		System.exit(0);
	}

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

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

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

	private static String nextToken() throws IOException	{
		while(st == null || !st.hasMoreTokens())	{
			if(!br.ready())	{
				exitImmediately();
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}


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

public class cf30b {
  public static void main(String[] args) {
    FastIO in = new FastIO(), out = in;
    String[] v2 = in.next().trim().split("[.]");
    String[] v1 = in.next().trim().split("[.]");
    boolean ok = false;
    ok |= go(new String[]{v1[0],v1[1],v1[2]}, v2);
    ok |= go(new String[]{v1[0],v1[2],v1[1]}, v2);
    ok |= go(new String[]{v1[1],v1[0],v1[2]}, v2);
    ok |= go(new String[]{v1[1],v1[2],v1[0]}, v2);
    ok |= go(new String[]{v1[2],v1[0],v1[1]}, v2);
    ok |= go(new String[]{v1[2],v1[1],v1[0]}, v2);
    out.println(ok?"YES":"NO");
    out.close();
  }
  static int[] day = {31,28,31,30,31,30,31,31,30,31,30,31};
  static boolean isValid(int d, int m, int y) {
    if(m <= 0 || m > 12) return false;
    int maxdays = day[m-1];
    if(isLeapYear(y) && m == 2) maxdays++;
    return d > 0 && d <= maxdays;
  }
  static boolean isLeapYear(int y) {
    return y%4 == 0;
  }
  static boolean go(String[] a, String[] b) {
    int d1 = Integer.parseInt(a[0]);
    int m1 = Integer.parseInt(a[1]);
    int y1 = 2000+Integer.parseInt(a[2]);
    int d2 = Integer.parseInt(b[0]);
    int m2 = Integer.parseInt(b[1]);
    int y2 = 2000+Integer.parseInt(b[2]);
    if(!isValid(d1,m1,y1)) return false;
    y1+=18;
    if(y1 < y2) return true;
    if(y1 > y2) return false;
    if(m1 < m2) return true;
    if(m1 > m2) return false;
    return d1 <= d2;
  }
  static class FastIO extends PrintWriter {
    BufferedReader br;
    StringTokenizer st;

    public FastIO() {
      this(System.in, System.out);
    }

    public FastIO(InputStream in, OutputStream out) {
      super(new BufferedWriter(new OutputStreamWriter(out)));
      br = new BufferedReader(new InputStreamReader(in));
      scanLine();
    }

    public void scanLine() {
      try {
        st = new StringTokenizer(br.readLine().trim());
      } catch (Exception e) {
        throw new RuntimeException(e.getMessage());
      }
    }

    public int numTokens() {
      if (!st.hasMoreTokens()) {
        scanLine();
        return numTokens();
      }
      return st.countTokens();
    }

    public String next() {
      if (!st.hasMoreTokens()) {
        scanLine();
        return next();
      }
      return st.nextToken();
    }

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

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

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


import java.util.*;

public class laddering {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

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

System.out.println(Math.max(a,b)-1 + " " + Math.min(a,b);

}
}


import java.util.*;

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

   int N, M;
   int[][][] memo;

   int go(int i, int j, int mask)
   {
      if (i == N)
         return go(0, j+1, mask);
      if (j == M)
      {
         int mm = mask%(1<<N);
         if (mm == 0)
            return N*M;
         return 0;
      }
      if (memo[i][j][mask] != -1)
         return memo[i][j][mask];

      int res = N*M;
      int pr = mask%2;
      if (pr == 1)
      {
         // We have the option to skip here
         int rr = go(i+1, j, mask/2);
         if (rr < res)
            res = rr;
      }

      // Now place a spider cluster here
      int nMask = mask/2;
      int prevMask = 0;
      if (i > 0)
         prevMask = 1 << (N-2);
      int nextMask = 0;
      if (i < (N-1))
         nextMask = 1 << (N);
      int curMask = 1 << (N-1);
      int nextRowMask = 1 << (N+N);
      nMask = nMask|prevMask|nextMask|curMask|nextRowMask;
      int rr = 1+go(i+1, j, nMask);
      if (rr < res)
         res = rr;

      memo[i][j][mask] = res;
      return res;
   }

   public E(Scanner in)
   {
      int[] vals = new int[2];
      vals[0] = in.nextInt();
      vals[1] = in.nextInt();
      Arrays.sort(vals);

      N = vals[0];
      M = vals[1];
      memo = new int[N][M][1<<(N+N+1)];
      fill3(memo, -1);

      int r1 = go(0, 0, (1<<N)-1);
      int res = N*M-r1;
      System.out.printf("%d%n", res);

   }

   void fill3(int[][][] vvv, int val)
   {
      for (int[][] vv : vvv)
         for (int[] v : vv)
            Arrays.fill(v, val);
   }
}


import java.util.*;
public class a {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int[] arr = new int[n];
    for (int i = 0; i  < n; i++)
        arr[i] = in.nextInt();
        Arrays.sort(arr);
        int a =-1. b = -1, c = -1;
        for (int i = 0; i < n;i++) {
            if (a == arr[i] ||  a== -1) a = arr[i];
            else if (b == arr[i] ||  b== -1) b = arr[i];
            else if (c == arr[i] ||  c== -1) c = arr[i];
            else {
                System.out.println(-1);
                return;
            }

        }
        if (c == -1 || c - b != b - a) System.out.println(-1);
        else System.out.println(b-a);
    }
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt(),x=sc.nextInt();
	    int a[]=new int[n];
	    int ans=0;
	    Set<Integer> set=new HashSet<>();
	    for(int i=0;i<n;i++){
	        a[i]=sc.nextInt();
	        if(a[i]<x)set.add(a[i]);
	    }
	    ans=x-set.size();ac
	    if(n==1 && a[0]==0)ans=1;
	    System.out.println(ans);
	}
}


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

public class Main {

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

	}

	static class TaskC {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int a = in.nextInt();
			int b = in.nextInt();
			int bars = 0 ;

			int max = Math.max(a,b )	 ;
			int min = Math.min(a, b) ;

			if(n>=4*a + 2*b)
				bars = 1 ;
			else if(n>=3*a + b + max)
				bars = 2 ;
			else if(n>=3*a + b + min)
				bars = 2 ;
			else if(n>=2*a + b + max)
				bars = 2 ;
			else if(n>=2*a + b + min)
				bars = 2 ;
			else if(n>=a + b + max)
				bars = 2 ;
			else if(n>=a + b + min)
				if(min==a)
					bars = 2 ;
				else
					if (n>2*a)
						bars =3 ;
					else
						bars=4 ;
			else if(n>=a + b)
				if(n>=2*a)
					bars = 3 ;
				else
					bars = 4 ;
			else bars =6 ;

			out.print(bars);

		}
		public static boolean isPrime (long num){
			if (num < 2) return false;
			if (num == 2) return true;
			if (num % 2 == 0) return false;
			for (long i = 3*1l; i * i <= num; i += 2)
				if (num % i == 0) return false;
			return true;
		}
	}
	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());
		}

	}
	static class Vertix{
		int x ;
		ArrayList<Vertix> children;
		Vertix parent;

		public Vertix(int x){
			this.x = x ;
			this.children= new ArrayList<Vertix>();
		}

	}

	static class Pair implements Comparable<Pair> {
		int x ;
		int y ;

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

		}

		@Override
		public int compareTo(Pair p) {
			if (this.x < p.x)
				return -1;
			else if (this.x > p.x)
				return 1;
			else
				return 0;

		}
		//
	}

}


import java.util.Scanner;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), a = 1, r = 0, aa = 2
        while (n - a >= 0) {
            n = n - a;
            a = a + aa;
            aa++;
            r++;
        }
        System.out.println(r);
    }
}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.lang.Math;

public class Lo {
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      double a = sc.nextInt();
      double b = sc.nextInt();
      double c = sc.nextInt();
      double s1 = math.sqrt(a*(b/c));
      double s2 = b/s1;
      double s3 = c/s2;
      System.out.println((int)(6*(s1+s2+s3)));

    }
}


import java.util.*;
public class A697b
{
	public static void main(String...arg)
	{
		Scanner sc=new Scanner(System.in);
		long d=0,i,t,s,x,c=0,k;
		t=sc.nextInt();
		s=sc.nextInt();
		x=sc.nextInt();
		if(x==t)
			d=1;

		if((x<t)||(x==t+1))
		{
			c=0;

		}
		else if (x>=s)
		{
		if((x-t)%s==0)
			{
				c=1;
			}
		else if((x-t-1)%s==0)
		{
			c=1;
		}
		else
		{
			c=0;
		}}

		if((c==1)||(d==1))
		{
			System.out.println("YES");
		}}}
		else
			System.out.println("NO");

	}


import java.util.*;
public class b256
{
	public static void main(String ar[])
	{
		Scanner obj=new Scanner(System.in);
		String s=obj.nextLine();
		String t=obj.nextLine();
		CharSequence t1=t;
		int ls=s.length();
		int lt=t.length();
		int arr[]=new int[26];
		Arrays.fill(arr,0);
		for(int i=0;i<ls;i++)
		arr[s.charAt(i)-97]++;
		for(int i=0;i<lt;i++)
		arr[t.charAt(i)-97]--;
		Arrays.sort(arr);
		if(arr[0]<0)
		System.out.println("need tree");
		else if
		{int j = 0 ;
				for (int i = 0  ; i < s.length() && j < t.length(); i++ )
					if (t.charAt(j) == s.charAt(i))
						j++;
				//System.out.print(j);
				if (j == t.length())
				System.out.print("automaton");

			else
				System.out.print("both");
			}
		else
		{
			if(arr[25]!=0)
			System.out.println("both");
			else
			System.out.println("array");
		}
	}
}


public class PizzaSeparation {

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

        int min = 360;
        for (int i = 0; i < slices; i++)  {
            int temp1 = 360;
            int temp2 = 0;
            temp1 -= array[i];
            temp2 += array[i];
            if (Math.abs(temp1 - temp2) < min) {
                min = Math.abs(temp1 - temp2);
            }

            for (int j = 0; j < slices; j++) {
                if (i == j) {
                    continue;
                }
                if (Math.abs(temp1 - temp2) < min) {
                    min = Math.abs(temp1 - temp2);
                }
                temp1 -= array[j];
                temp2 += array[j];
            }
        }
        System.out.println(min);
    }
}


public class Test {

    static int h, w, u1, d1, u2, d2;

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner reader = new Scanner(System.in);
        w = reader.nextInt();
        h = reader.nextInt();
        d1 = reader.nextInt();
        u1 = reader.nextInt();
        d2 = reader.nextInt();
        u2 = reader.nextInt();

        for (int i = h; i > 0; i--) {
            w = w + i;
            if (i == u1) {
                w = w - d1;
            } else if (i == u2) {
                w = w - d2;
            }
        }

        System.out.println(w);

    }

}


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

import jdk.nashorn.internal.ir.Flags;

public class Pangram {
public static void main (String[]args) throws NumberFormatException, IOException{
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine())   ;
    if (n<26) {
        System.out.println("NO");
    }else{
        char[] c=new char[26];
        c[0]='a';
        for (int i = 1; i < c.length; i++) {
            c[i]=(char) (c[i-1]+1);

        }
        String s=br.readLine();
        String m=s.toLowerCase();
        //System.out.println(m);
        Boolean flag=false;
        for (int i = 0; i < c.length; i++) {
             flag=false;

            for (int j = 0; j < m.length(); j++) {
                if (c[i]==m.charAt(j)) {
                    flag=true;
                    break;
                }
            }
            if (flag==false) {
                System.out.println("NO");
                break;
            }

        }
        if(flag)
            System.out.println("YES");

    }

}
}


import java.util.Scanner;

/**
 * @author stran
 * @version 1.0 (14/06/2016).
 */
public class P678B_SameCalendar {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int y = scanner.nextInt(),
            next = y, sumOdd = (isLeapYear(next) ? 2 : 1);
        boolean yLeap = isLeapYear(y),
            nextLeap;

        do {
            next++;
            sumOdd += (isLeapYear(next) ? 2 : 1);
            nextLeap = isLeapYear(next + 1);
        } while (sumOdd % 7 != 0 || nextLeap != yLeap);

        System.out.println(next + 1);
    }

    private static boolean isLeapYear(int year) {
        return (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0));
    }
}


mport java.util.*;
public class ninety_mins {

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

		for(int i=0;i<a;i++)
		{
			inp[i]=sc.nextInt();
		}

		 int max[]=new int[a];
		  max[a-1]=0;

		   if(inp[0]>15)
			{
				System.out.println("15");
			}

		   else

		{

		for(int i=1;i<a;i++)
		{

			if(inp[i] - inp[i-1] >15 )
			{
				System.out.println(inp[i-1]+15);
				break;
			}

			max[i] = inp[i];

			}
		}

		  if(max[a-1]!=0 )

		{
			System.out.println(90);
		}

		   if(a==1 && inp[0] <=15 )
					{
						System.out.println(15+inp[a-1]);
					}

	/*

		*/

}

}


import java.util.*;

public class Main {

	// global
	static long fact[];
	static long inverse[];
	static int n;
	static int mod;

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

	static long modinv(long n) {
	    return pow(n, mod-2);
	}

	static long comb(int n,int k){
	    if(n<0 || k<0 || n<k)return 0;
	    return fact[n]*(inverse[k]*inverse[n-k]%mod) %mod;
	}

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

		// main method
		fact=new long[200000];
		fact[0]=1;
		inverse=new long[200000];
		inverse[0]=1;
		for(int i=1;i<200000;i++){
		    fact[i]=(fact[i-1]*(long)i)%mod;
		    inverse[i]=modinv(fact[i]);
		}

		long ans = 0L;
		for (int i=1;i<=n;i++) {
			// ans = (ans + (((((n-(i-1))*fact[n])%mod*(n-1))%mod*fact[i])%mod*fact[n-i])%mod*modinv(fact[n])%mod)%mod;
			ans = (ans + (((((n-(i-1)))%mod*(n-(i-1)))%mod*fact[i])%mod*fact[n-i])%mod)%mod;
		}
		System.out.println(ans);
	}
}


//package practice_problems;

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

/**
 *
 * @author Tushar Jan 6, 2017
 */
public class A_390 {

    long mod = 1000000007;

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

        int t=1;
        while(t-->0)
        {
            int[][] arr= new int[100][2];
            int count=0;
            int index=0;
            int a=0;
            boolean sol=true;
            int n=in.nextInt();
            for(int i=1;i<=n;){

                a=in.nextInt();

                index=i;
                i++;
                arr[count][0]=index;
                while(a==0)
                {
                    if(i<=n){
                        a=in.nextInt();
                        index++;
                        i++;
                    }
                    else if(i==n+1)
                    {
                        continue;
                    }
                    else{

                        sol=false;
                        break;
                    }
                }
                arr[count][1]=index;
                count++;

            }
            if(sol){
                out.println("YES");
                out.println(count);
                for(int i=0;i<count;i++)
                {
                    out.println(arr[i][0]+" "+arr[i][1]);
                }
            }
            else
                out.println("NO");

        }

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

    }

    long power(long x, long n) {
        if (n <= 0) {
            return 1;
        }
        long y = power(x, n / 2);

        if ((n & 1) == 1) {
            return (((y * y) % mod) * x) % mod;
        }

        return (y * y) % mod;
    }

    public long gcd(long a, long b) {
        a = Math.abs(a);
        b = Math.abs(b);
        return BigInteger.valueOf(a).gcd(BigInteger.valueOf(b)).longValue();
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

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

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

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

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

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

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

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

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

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

}


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

public class Main {

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

       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc=new Scanner(System.in);
       String[] s=br.readLine().split(" ");
        long a1=Long.parseLong(s[0]);
        long b1=Long.parseLong(s[1]);
        if(a1==b1)bw.write("=");
        else
            if(a1==1)
                bw.write("<");
        else
            if(b1==1)
                bw.write(">");
        else
            if(a1==2)
            {
                if(b1==3)
                    bw.write("<");
                else
                    if(b1==4)
                        bw.write("=");
                else
                    bw.write(">");
            }
        else
              if(b1==2)
            {
                if(a1==3)
                    bw.write("<");
                else
                    if(a1==4)
                        bw.write("=");
                else
                    bw.write(">");
            }
        else
            if(x>y)
                bw.write(">");
        else
            if(y>x)
                bw.write("<");
        bw.flush();
}
}


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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class C{
    Scanner sc=new Scanner(System.in);

    int INF=1<<28;
    double EPS=1e-9;

    String line;
    int n, m;

    void run(){
        int range=210;

        line=sc.nextLine();
        n=sc.nextInt();
        m=line.length();

        char[] cs=line.toCharArray();

        int[][][][] dp=new int[range][range][4][n+1];
        dp[range/2][range/2][0][0]=1;
        int[][][][] dp2=new int[range][range][4][n+1];

        int[] dx={-1, 0, 1, 0};
        int[] dy={0, 1, 0, -1};

        boolean[][][] visit=new boolean[m+1][range][range];
        visit[0][range/2][range/2]=true;

        for(int k=0; k<m; k++){
            for(int y=0; y<range; y++){
                for(int x=0; x<range; x++){
                    for(int d=0; d<4; d++){
                        for(int i=0; i<n; i++){
                            dp2[y][x][d][i]=dp[y][x][d][i];
                        }
                    }
                }
            }

            for(int y=1; y<range-1; y++){
                for(int x=1; x<range-1; x++){
                    if(x<1||x>=range-1){
                        continue;
                    }
                    if(y<1||y>=range-1){
                        continue;
                    }
                    if(!visit[k][y][x]){
                        continue;
                    }
                    for(int d=0; d<4; d++){
                        for(int i=0; i<n; i++){
                            if(dp2[y][x][d][i]==1){
                                int x2=x+dx[d];
                                int y2=y+dy[d];
                                int d2=(d+1)%4;
                                if(cs[k]=='F'){
                                    dp[y2][x2][d][i]=1;
                                    dp[y][x][d2][i+1]=1;
                                }else{
                                    dp[y][x][d2][i]=1;
                                    dp[y2][x2][d][i+1]=1;
                                }
                                visit[k+1][y][x]=true;
                                visit[k+1][y2][x2]=true;
                            }
                        }
                    }
                }
            }
        }

        int max=0;
        for(int y=0; y<range; y++){
            for(int x=0; x<range; x++){
                for(int d=0; d<4; d++){
                    if(dp[y][x][d][n]==1){
                        max=max(max, abs(x-range/2)+abs(y-range/2));
                    }
                }
            }
        }

        println(max+"");

    }

    class P implements Comparable<P>{
        int x, y;

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

        @Override
        public int compareTo(P p){
            if(y!=p.y){
                return y-p.y;
            }else{
                return x-p.x;
            }
        }
    }

    void run2(){
        line=sc.nextLine();
        n=sc.nextInt();
        int m=line.length();

        int countT=0;
        for(int i=0; i<m; i++){
            if(line.charAt(i)=='T'){
                countT++;
            }
        }
        if(countT<=n){
            println(m-(n-countT)+"");
            return;
        }

        run_();

        int[] dx={-1, 0, 1, 0};
        int[] dy={0, 1, 0, -1};

        int ans=0;
        char[] cs=line.toCharArray();
        for(int j=0; j<n; j++){
            int max=-1;
            int index=-1;
            for(int i=0; i<m; i++){
                if(cs[i]=='F'){
                    // continue;
                }
                // iを
                int x=0, y=0;
                int d=0;
                for(int k=0; k<m; k++){
                    int op=cs[k]=='F'?0:1;
                    if(k==i){
                        op=1-op;
                    }
                    if(op==0){
                        x+=dx[d];
                        y+=dy[d];
                    }else{
                        d=(d+1)%4;
                    }
                }
                // debug(cs, x, y);
                if(abs(x)+abs(y)>max){
                    max=abs(x)+abs(y);
                    index=i;
                }
            }
            debug(max);
            if(j==n-1){
                ans=max(ans, max);
            }
            cs[index]=cs[index]=='F'?'T':'F';
            debug(j, cs);
        }
        println(ans+"");
    }

    void run_(){
        char[] cs;
        int[] dx={-1, 0, 1, 0};
        int[] dy={0, 1, 0, -1};

        int max=0;
        String best=null;
        for(int sup=0; sup<1<<m; sup++){
            if(Integer.bitCount(sup)==n){
                cs=line.toCharArray();
                for(int i=0; i<m; i++){
                    if((sup>>i&1)==1){
                        if(cs[i]=='F'){
                            cs[i]='T';
                        }else{
                            cs[i]='F';
                        }
                    }
                }
                int x=0, y=0;
                int d=0;
                for(int i=0; i<m; i++){
                    if(cs[i]=='F'){
                        x+=dx[d];
                        y+=dy[d];
                    }else{
                        d=(d+1)%4;
                    }
                }
                if(abs(x)+abs(y)>max){
                    max=abs(x)+abs(y);
                    best=new String(cs);
                }
            }
        }
        debug(line);
        debug(best);
        debug("run_", max);
    }

    void println(String s){
        System.out.println(s);
    }

    void print(String s){
        System.out.print(s);
    }

    void debug(Object... os){
        // System.err.println(Arrays.deepToString(os));
    }

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


public class abc{

    public static void Main(String[] args) {

        int a;
        int b;
        int answer = 0;
        int mod = 0;

        Scanner in = new Scanner(System.in);
        a = in.nextInt();
        b = in.nextInt();
        if (a < b) {
            System.out.print(0);
        }
        else {
            answer += a;

            while (a > 0) {

                if (a >= b) {

                    mod = a % b;

                    a = a / b;
                    answer += a;

                    a = a + mod;

                }
                else {
                    break;
                }

            }
            System.out.print(answer);
        }
    }
}


import java.util.*;

public class A1{
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        long r=s.nextInt();
        long finalx=-1,finaly=-1;
        for(long x=1;x<=(int)1e6;i++){
            long temp=r-x*x-x-1;
            if(temp!=0&&temp%(2*x)==0){
                finaly=temp;
                break;
            }
        }
        if(finalx!=-1 && finaly!=-1)System.out.println(finalx+" "+finaly);
        else System.out.println("NO");

    }
}


mport java.util.*;

public class Main5 {
	public static void main(String[] args) {
	      // Use the Scanner class
	     try{
	      Scanner sc = new Scanner(System.in);
	      String s=sc.next();
	      int r=0,v=0;
	      for(int i=0; i<s.length()-1;i++){
	    	  if(s.charAt(i)=='V' && s.charAt(i+1)=='K'){
	    		  s=s.substring(0,i)+"--"+s.substring(i+2);
	    		  r++;
	    	  }
	    	  if((s.charAt(i)=='V' && s.charAt(i+1)=='V') || (s.charAt(i)=='K' && s.charAt(i+1)=='K')){
	    		  v++;
	    		  s=s.substring(0, i+1)+'-'+s.substring(i+2);
	    	  }
	      }

	      if(v>0) r++;
	      System.out.println(r);
	     }
	     catch(NoSuchElementException e){

	     }
	  }
}


import java.util.Scanner;
public class CF618A
{
  public static void main(String[] args)
  {
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    int temp=n;
    int l=0;
    while(temp>0)
    {
      temp>>=1;
      ++l
    }
    temp=1<<(l-1);
    String s="";
    for(int i=l;i>0;--i)
    {
      if(n&temp!=0)
        s+=(s.lenth==0?i:(" "+i));
      temp>>=1;
    }
    System.out.print(s);
  }
}


import java.util.*;
public class again3
{
    public static void main(String args[])
    {
        Scanner ex=new Scanner(System.in);
        int n=ex.nextInt();
        int m=ex.nextInt();
        int dig[]=new int[10];
        int arrn[][]=new int[n][2];
        int arrm[][]=new int[m][2];
        for(int i=0;i<n;i++)
        {
            arrn[i][0]=ex.nextInt();
            arrn[i][1]=ex.nextInt();
        }
        for(int i=0;i<m;i++)
        {
            arrm[i][0]=ex.nextInt();
            arrm[i][1]=ex.nextInt();
        }
        int gf=0;
        for(int i=0;i<n;i++)
        {
            int n1=arrn[i][0];
            int n2=arrn[i][1];
            int num=0,flag1=0,flag2=0;
            for(int j=0;j<m;j++)
            {
                int m1=arrm[j][0];
                int m2=arrm[j][1];
                if((n1==m1||n1==m2)&&n2!=m1&&n2!=m2)
                {
                    flag1=1;
                    num=n1;
                }
                else if((n2==m1||n2==m2)&&n1!=m1&&n1!=m2)
                {
                    flag2=1;
                    num=n2;
                }
            }
            if(flag1==1&&flag2==1)
            {
                gf=1;
                break;
            }
            else if(flag1==1||flag2==1)
            dig[num]++;
        }
        if(gf==1)
        System.out.println("-1");
        else
        {
            int count=0,num=0;
            for(int i=0;i<10;i++)
            {
                if(dig[i]>0)
                {
                    count++;
                    num=i;
                }
            }
            if(count>1)
            System.out.println("0");
            else
            System.out.println(num);
        }
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class code2 {
	InputStream is;
	PrintWriter out;
	ArrayList<Integer> al[];
	long mod=(int)Math.pow(10,9)+7;
	int dp[][][][][],a[];
	void solve()
	{
		int n=ni();
		a=na(n);
		dp=new int[310+1][310+1][5][8][n];
		visited=new boolean[310+1][310+1];
		rec(155,155,a[0],2,0);
		int count=0;
		for(int i=0;i<=310;i++)
		{
			for(int j=0;j<=310;j++)
			{
				if(visited[i][j])
					count++;
			}
		}
		out.print(count);
	}
	boolean visited[][];
	void rec(int x,int y,int used,int dir,int level)
	{
		//if(used<0||level>=a.length)
			//return;
		if(dp[x][y][used][dir][level]!=0)
			return ;
		visited[x][y]=true;
		dp[x][y][used][dir][level]=1;
		if(used!=1)
		{
			int gox=x+getx(dir);
			int goy=y+gety(dir);
			rec(gox,goy,used-1,dir,level);
		}else{
			if(level+1<a.length) {
				rec(x,y,a[level+1]+1,(dir+1)%8,level+1);
				rec(x,y,a[level+1]+1,(dir-1+8)%8,level+1);
			}
		}
	}
	int getx(int dir)
	{
		if(dir==1||dir==2||dir==3)
			return -1;
		if(dir==5||dir==6|dir==7)
			return 1;
		return 0;
	}
	int gety(int dir)
	{
		if(dir==1||dir==0||dir==7)
			return 1;
		if(dir==3||dir==4|dir==5)
			return -1;
		return 0;
	}
	boolean isPrime(int num)
	{
		for(int i=2;i*i<=num;i++)
		{
			if(num%i==0)
				return false;
		}
		return true;
	}
	public static void mergeSort(int[] arr, int l ,int r){
		if((r-l)>=1){
			int mid = (l+r)/2;
			mergeSort(arr,l,mid);
			mergeSort(arr,mid+1,r);
			merge(arr,l,r,mid);
		}
	}
	public static void merge(int arr[], int l, int r, int mid){
		int n1 = (mid-l+1), n2 = (r-mid);
		int left[] = new int[n1];
		int right[] = new int[n2];
		for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
		for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
		int i =0, j =0, k = l;
		while(i<n1 && j<n2){
			if(left[i]>right[j]){
				arr[k++] = right[j++];
			}
			else{
				arr[k++] = left[i++];
			}
		}
		while(i<n1) arr[k++] = left[i++];
		while(j<n2) arr[k++] = right[j++];
	}
	public static void mergeSort(long[] arr, int l ,int r){
		if((r-l)>=1){
			int mid = (l+r)/2;
			mergeSort(arr,l,mid);
			mergeSort(arr,mid+1,r);
			merge(arr,l,r,mid);
		}
	}
	public static void merge(long arr[], int l, int r, int mid){
		int n1 = (mid-l+1), n2 = (r-mid);
		long left[] = new long[n1];
		long right[] = new long[n2];
		for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
		for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
		int i =0, j =0, k = l;
		while(i<n1 && j<n2){
			if(left[i]>right[j]){
				arr[k++] = right[j++];
			}
			else{
				arr[k++] = left[i++];
			}
		}
		while(i<n1) arr[k++] = left[i++];
		while(j<n2) arr[k++] = right[j++];
	}
	 static class Pair implements Comparable<Pair>{

	        int x,y,k,i;

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

		public int compareTo(Pair o) {
					return this.y-o.y;
		}

	        public boolean equals(Object o) {
	            if (o instanceof Pair) {
	                Pair p = (Pair)o;
	                return p.x == x && p.y == y && p.k==k;
	            }
	            return false;
	        }

	        @Override
	        public String toString() {
	            return  "("+x + " " + y +" "+k+" "+i+" )";
	        }

	    }

	    public static boolean isPal(String s){
	        for(int i=0, j=s.length()-1;i<=j;i++,j--){
	                if(s.charAt(i)!=s.charAt(j)) return false;
	        }
	        return true;
	    }
	    public static String rev(String s){
			StringBuilder sb=new StringBuilder(s);
			sb.reverse();
			return sb.toString();
	    }

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

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

	    public static long gcdExtended(long a,long b,long[] x){

	        if(a==0){
	            x[0]=0;
	            x[1]=1;
	            return b;
	        }
	        long[] y=new long[2];
	        long gcd=gcdExtended(b%a, a, y);

	        x[0]=y[1]-(b/a)*y[0];
	        x[1]=y[0];

	        return gcd;
	    }

	    public static int abs(int a,int b){
		return (int)Math.abs(a-b);
	    }

	    public static long abs(long a,long b){
		return (long)Math.abs(a-b);
	    }

	    public static int max(int a,int b){
		if(a>b)
			return a;
		else
			return b;
	    }

	    public static int min(int a,int b){
		if(a>b)
			return b;
		else
			return a;
	    }

	    public static long max(long a,long b){
		if(a>b)
			return a;
		else
			return b;
	    }

	    public static long min(long a,long b){
		if(a>b)
			return b;
		else
			return a;
	    }

	    public static long pow(long n,long p,long m){
		 long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    if(result>=m)
		    result%=m;
		    p >>=1;
		    n*=n;
		    if(n>=m)
		    n%=m;
		}
		return result;
	    }

	    public static long pow(long n,long p){
		long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    p >>=1;
		    n*=n;
		}
		return result;
	    }
	    public static void debug(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
	    void run() throws Exception {
			is = System.in;
			out = new PrintWriter(System.out);
			solve();
			out.flush();
		}

	    public static void main(String[] args) throws Exception {
	    	new Thread(null, new Runnable() {
				public void run() {
					try {
						new code2().run();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}, "1", 1 << 26).start();

	    	//new code2().run();
		}

	    private byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		private int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b));
			return b;
		}

		private double nd() {
			return Double.parseDouble(ns());
		}

		private char nc() {
			return (char) skip();
		}

		private String ns() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		private char[] ns(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		private char[][] nm(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = ns(m);
			return map;
		}

		private int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = ni();
			return a;
		}

		private int ni() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		private long nl() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

}


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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            char[] s = in.next().toCharArray();
            char[] t = in.next().toCharArray();
            int wildCardLoci = 1000000;
            if (N - 1 > M) {
                out.println("NO");
                return;
            }
            for (int i = 0; i < s.length; i++) {
                if (i >= M || s[i] != t[i]) {
                    if (s[i] != '*') {
                        out.println("NO");
                        return;
                    }
                    wildCardLoci = i;
                    break;
                }
            }
            if (wildCardLoci == 1000000 && N != M) {
                out.println("NO");
                return;
            }
            for (int i = N - 1; i > wildCardLoci; i--) {
                if ((t[M - (N - i)] != s[i])) {
                    out.println("NO");
                    return;
                }
            }
            out.println("YES");
        }

    }

    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 class A {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int x= s.nextInt();
		s.next();
		String info = s.next();
		boolean isWeek = info.equals("week")?true:false ;

		if (isWeek){
			if (x == 5 || x == 6){
				System.out.println(53);
			}else{
				System.out.println(52);
			}
		}else{
			if (x == 31){
				System.out.println(7);
			}
			else if (x==30){
				System.out.println(11);
			}
			else{
				System.out.println(12);
			}
		}
		s.close();
	}
}


import java.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x%2 == 0){
			System.out.println("home");
		} else{
			System.out.println("contest");
		}
	}
}


import java.awt.Point;
import java.io.PrintWriter;
import java.util.*;

public class A {

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

		int X = sc.nextInt();
		int Y = sc.nextInt();

		// 0 = right
		// 1 = up
		// 2 = left
		// 3 = down
		int count = 0;
		int idx = 0;
		int dir = 0;
		int factor = 1;
		Point start = new Point(0, 0);
		int ans = 0;
		int[] x = { 1, 0, -1, 0 };
		int[] y = { 0, 1, 0, -1 };
		while (start.x != X || start.y != Y) {
			start.translate(factor * x[idx], factor * y[idx]);
			if (dir == 0 && idx == 0) {

			} else {
				dir++;
				ans++;
			}
			idx++;
			if (idx == 4) {
				idx = 0;
			}
			count++;
			if (count % 2 == 0 && count != 0)
				factor++;
		}

		out.println(ans);

		sc.close();
		out.close();
	}
}


import org.omg.Messaging.SYNC_WITH_TRANSPORT;

import javax.print.DocFlavor;
import java.util.*;

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

            Scanner input = new Scanner(System.in);
            String car = input.next();
            String k = "qwertyuiopasdfghjkl;zxcvbnm,./";
            String in = input.next();
            ArrayList<Character> bla = new ArrayList<>();
            for (int i = 0; i < k.length();i++) {
                bla.add(k.charAt(i));
            }
            String ans = "";
            if (car.equals("R")) {
                for (int i = 0; i < in.length() ; i++) {
                  ans += bla.get(bla.indexOf(in.charAt(i)) - 1);
                }
            } else {
                for (int i = 0; i < in.length() ; i++) {
                    ans += bla.get(bla.indexOf(in.charAt(i)) +1);
                }
            }
            System.out.println(ans);

        }
    }


import java.io.*;
import java.util.*;
public class B {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        int i,j,k,len,n,flag=0;
        String s2;
        len=s.length();
        outer:for(i=0;i<=len-3;i++){
            for(j=i+1;j<=len-2;j++){
                for(k=j+1;k<=len-1;k++){
                    s2="";
                    s2=s2+s.charAt(i)+s.charAt(j)+s.charAt(k);
                    n=Integer.parseInt(s2.toString());
                    if(n%8==0){
                        System.out.println("YES");
                        System.out.println(n);
                        flag=1;
                        break outer;
                    }
                }
            }
        }
        int a,b;
        if(len<=2){
            n=Integer.parseInt(s);
            if(n%8==0){
                System.out.println("YES");
                System.out.println(n);
                flag=1;
            }
	}
            if (len==2 && (n%8)!=0) {
                a = Integer.parseInt("" + s.charAt(0));
                b = Integer.parseInt("" + s.charAt(1));
                if ((a == 0) || (a == 8)) {
                    System.out.println("YES");
                    System.out.println(a);
                    flag = 1;
                }
                else if ((b == 0) || (b == 8)) {
                    System.out.println("YES");
                    System.out.println(b);
                    flag = 1;

                }
            }
        }
        if(flag==0)
            System.out.println("NO");
    }
}


import java.io.BufferedReader;

public class Main {

    public static void main(String args[]){
        MyScanner sc = new MyScanner();
        String s = sc.next();
        int x = sc.nextInt();
        int algarisms[] = new int[s.length()];
        int nAlgarisms=s.length();

        for(int i=0; i<s.length(); i++){
            algarisms[i] = Character.digit(s.charAt(i), 10);
        }

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

        int i=0;
        int subArray[] = new int[x+1];

        while(x>0 && i<algarisms.length-1){
            subArray = getSubArray(algarisms, i, x);

            int maxIndex = getMaxIndexArray(subArray);
            x -= maxIndex;
            for(int j=maxIndex; j>0; j--){
                int temp=algarisms[i+j];
                algarisms[i+j]=algarisms[i+j-1];
                algarisms[i+j-1]=temp;
            }
            i++;
            subArray = new int[x+1];

        }

        double result=0;
        for(int j=nAlgarisms-1; j>=0; j--){
            result+=Math.pow(10,j)*(double)(algarisms[nAlgarisms-1-j]);
        }
        System.out.println(String.format("%.0f",result));
        //System.out.println(result);
        //System.out.println(Arrays.toString(algarisms));

    }

    public static int getMaxIndexArray(int array[]){
        int max = 0;
        int index = 0;
        for(int i=0; i<array.length; i++){
            //In case of draw, will return the first index
            if(array[i]>max){
                max=array[i];
                index=i;
            }
        }

        return index;
    }

    public static int[] getSubArray(int array[], int startIndex, int plus){
        int newArray[] = new int[plus+1];
        int endIndex = startIndex+plus<array.length? startIndex+plus:array.length-1;

        for(int i=startIndex; i<=endIndex; i++){
            newArray[i-startIndex] = array[i];
        }

        return newArray;
    }

    public static class MyScanner {
          BufferedReader br;
          StringTokenizer st;

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

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

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

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

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

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

       }
}


public class CodeForces {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println((n * 2) / 3 + (n % 3 != 0 ? 1 : 0));
	}
}


public class Main {
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
     long n,m;
     n=in.nextLong();
     m=in.nextLong();
     int i=1;
    while(m!=0)
    {
        if(m>=i){
       m=m-i;
       i++;}
       else{
            System.out.println(m);
        break;
       }
       if(m==0)
            System.out.println("0");
       if(i>n)
        i=1;
    }

}}


public class LuckyCard {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.println("Enter 6 digits : ");
        String lc = s.next();
        int arr[] = new int[6];
        int r=0;//Number of replacements

        //Enter the numbers into the array
        for (int i = 0; i < arr.length; i++) {
            arr[i] =Integer.parseInt(lc.charAt(i)+"");
        }

        //sorted by bubble sort
        int n = arr.length;
        int temp = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j < (n - i); j++) {
                if (arr[j - 1] > arr[j]) {
                    //swap elements
                    temp = arr[j - 1];
                    arr[j - 1] = arr[j];
                    arr[j] = temp;
                }
            }
        }

        int sum1=0;
        int sum2=0;

        for (int i = 0 ;i<=2 ;i++)//sum of the first three numbers
        sum1=sum1+arr[i];

        for (int i = 3 ;i<=5 ;i++)//sum of the second three numbers
        sum2=sum2+arr[i];

        int d = sum2-sum1;

        if (d>0 && d < 9)
            r=1;
        else if (d>=9 &&d<18)
            r=2;
        else if (d>=18 && d< 27)
            r=3;

        System.out.println(r);
    }

}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = 2 * n - 1;
		int l = Integer.toString(m).length();
		char[] c = Integer.toString(m).toCharArray();
		boolean b = true;
		for (int i = 0; i < c.length; i++) {
			if (c[i] != '9')
				b = false;
		}
		if (b)
			System.out.println(1);
		else {
			l--;
			String s="";
			for (int i=0; i<l; i++) s+="9";
			int k=Integer.parseInt(s);
			int k1=k+1;
			int n1=k;
			int count=0;
			while (n1<=m){
				if (n1<n) count+=(n1/2); else {
					count+=n1/2;
					count-=Math.max((n1-n-1),0);
				}

				n1+=k1;
			}
			System.out.println(count);
		}
	}

}


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

public class M {ain

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		System.out.println(method_Max(l, r));
	}

	private static int method_Max(int l, int r) {
		// TODO Auto-generated method stub
		int[] pfact = {2,3,5};
		int c2=0,c3=0,c5=0,c7=0,els =1;
		for(int i=l;i*i<=r;i++){
			if(i%pfact[0]==0)
				c2++;
			else if(i%pfact[1]==0)
				c3++;
				else
				continue;
		}
		Arrays.sort(pfact);
		if(pfact[0]>els)
		 return pfact[0];
		else
			return els;
	}
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        int n = input.nextInt();
        int insertWeight = input.nextInt();
        int doubleWeight = input.nextInt();

        int ans[] = new int[n + 1];
        ans[0] = 0;
        ans[1] = insertWeight;
        for (int i = 2; i < n+1; i++) {
            if (i % 2 == 1) {
                ans[i] = Math.min(ans[(i - 1)] + insertWeight, ans[(i + 1) / 2] + insertWeight + doubleWeight;
            } else {
                ans[i] = Math.min(ans[i / 2] + doubleWeight, ans[i - 1] + insertWeight);

            }
        }

        System.out.print(ans[n]);
    }
}


import java.util.Scanner;
public class a
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int m=s.nextInt();
        int n=s.nextInt();
        double k=s.nextDouble();
        int value=(int)(k/2)*((2*m)+(k-1)*m);
        System.out.println(value-n);
    }
}


import java.util.*;
public class C {
    public static void main(String args[])throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long b = sc.nextLong();
        long copy = n;
        Map<Long, Long> hm = new HashMap<>();
        for (long i = 2l; i * i <= n; i++) {
            long cnt = 0l;
            while (n % i == 0) {
                cnt ++;
                n /= i;
            }
            if (cnt > 0l)
            hm.put(i, cnt);
        }
        hm.put(b, 1);
        int pow = Integer.MAX_VALUE;
        for (Long i : hm.keySet()) {
            int p = 0;
            for (long j = i; j <= copy; j *= i)
            p += copy / j;
            pow = Math.min(pow, p);
        }
        System.out.print(pow);
    }
}


//package com.acabra.gtechdevalgs.codeforces.below1000;

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

//public class CardGame1097A {
    public class Solution implements Runnable {
        // solution
        void solve() throws IOException {
            System.out.println(solution(help));
        }

        public static String solution(Help help) throws IOException {
            String openCard = help.next();
            String handCard;
            for (int i = 0; i < 5; ++i) {
                handCard = help.next();
                if (sameSuit(openCard, handCard) || sameRank(openCard, handCard)) {
                    return "YES";
                }
            }
            return "NO";
        }

        private static boolean sameRank(String openCard, String handCard) {
            return openCard.charAt(1) == handCard.charAt(1);
        }

        private static boolean sameSuit(String openCard, String handCard) {
            return openCard.charAt(0) == handCard.charAt(0);
        }

        //--START helper submission code
        private final Help help;
        private final boolean onlineJudge;
        static class Help {
            final BufferedReader bf;final PrintWriter out;StringTokenizer tokenizer;
            public Help(BufferedReader bf, PrintWriter out) {this.bf = bf;this.out = out;}
            public int nInt() throws IOException {return Integer.parseInt(next());}
            public long nLong() throws IOException {return Long.parseLong(next());}
            public double nDouble() throws IOException {return Double.parseDouble(next());}
            String next() throws IOException {while (tokenizer == null || !tokenizer.hasMoreTokens()) {tokenizer = new StringTokenizer(bf.readLine());}return tokenizer.nextToken();}
            public void close() throws IOException {bf.close();out.flush();}
            public static Help of(InputStream in) { return of(in, new OutputStreamWriter(System.out)); }
            public static Help of(String fileName) { return of(fileAsStream(fileName), new OutputStreamWriter(System.out)); }
            static Help of(InputStream in, OutputStreamWriter iOut) {return new Help(new BufferedReader(new InputStreamReader(in)), new PrintWriter(iOut));}
        }
        public Solution(InputStream in, OutputStreamWriter iOut, boolean isOnlineJudge) {this.help = new Solution.Help(new BufferedReader(new InputStreamReader(in)), new PrintWriter(iOut)); this.onlineJudge = isOnlineJudge;}
        private static Solution ofConsole() { return new Solution(System.in, new OutputStreamWriter(System.out), true); }
        public static InputStream fileAsStream(String fileName) { return SearchEasyProblem1030A.Solution.class.getClassLoader().getResourceAsStream(fileName); }
        public static Solution ofTestFile(String fileName) { return new Solution(Solution.class.getClassLoader().getResourceAsStream(fileName), new OutputStreamWriter(System.out), false);}
        private static Solution get(String file) { return System.getProperty("ONLINE_JUDGE") != null ? ofConsole() : ofTestFile(file); }
        public static void main(String[] args) {new Thread(null, Solution.ofConsole(), "", 256 * (1L << 20)).start();}
        public void run() {
            try {long t1 = System.nanoTime();Locale.setDefault(Locale.US);solve();if (!onlineJudge) System.err.println("Time = " + (System.nanoTime() - t1)/1000.0 + ": ms");}
            catch (Throwable t) {System.exit(-1);}
            finally {try {help.close();} catch (IOException e) {e.printStackTrace();}}
        }
        //--END helper submission code
    }
//}


import java.util.BufferedReader;
import java.util.InputStreamReader;

public class BearTraingle {
    public static void main(String[] args) throws Exception {
        BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
        String[] temp = bfr.readLine().split(" ");
        int x = Integer.parseInt(temp[0]);
        int y = Integer.parseInt(temp[1]);

        printCoordinates(x,y);
    }

    private static void printCoordinates(int x, int y) {
            int x1 = 0;
            int x2 = x+y;
            int y1 = x+y;
            int y2 = 0;
        if(x < 0 && y > 0) {
            x1 = x-y;
            x2 = 0;
            y1 = 0;
            y2 = -(x-y);
        }else if(x > 0 &&  y < 0) {
            x1 = 0;
            x2 = -(y-x);
            y1 = (y-x);
            y2 = 0;
        }else if(x < 0 && y < 0) {
            x1 = x+y;
            x2 = 0;
            y1 = 0;
            y2 = x+y;
        }

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


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

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

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        int r = sc.nextInt();
        int x = sc.nextInt();
        int c[] = new int[n];
        for(int i = 0;i<n;i++){
            c[i]=sc.nextInt();
        }
        int counter = 0;
        int m = (1<<n);
        for(int i = 0;i<m;i++){
            ArrayList<Integer> sa = new ArrayList<Integer>();
            for(int j = 0;j<n;j++){
                if((1<<j)|i==i){
                    sa.add(j);
                }
            }
            int max = -1;
            int sum = 0;
            int min = 1000006;
            for(int j : sa){
                min = Math.min(min,j);
                max=Math.max(max,j);
                sum+=j;
            }
            if(l<=sum && sum<=r && max-min>=x){
                counter++;
            }
        }
        System.out.println(counter);
    }
}


import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;

static void solve(){
 int n=3;
 int[][] co=new int[n][];
 for(int i=0;i<n;i++) co[i]=ir.nextIntArray(2);
 if((co[0][0]==co[1][0]&&co[1][0]==co[2][0])||(co[0][1]==co[1][1]&&co[1][1]==co[2][1])){
  out.println(1);
  return;
 }
 int[] ord=new int[n];
 for(int i=0;i<n;i++) ord[i]=i;
 int mi=100;
 do{
  for(int i=0;i<n-1;i++){
   if((co[ord[i]][0]==co[ord[i+1]][0])||(co[ord[i]][1]==co[ord[i+1]][1])){
    cnt++;
   }
   else cnt+=2;
  }
  mi=Math.min(mi,ct);
 }while(next_permutation(ord));
 out.println(mi);
}

public static boolean next_permutation(int[] a){
 for(int i=a.length-2;i>=0;i--){
  if(a[i]<a[i+1]){
   for(int j=a.length-1;;j--){
    if(a[i]<a[j]){
     int temp=a[i]; a[i]=a[j]; a[j]=temp;
     for(i++,j=a.length-1;i<j;i++,j--){
      temp=a[i]; a[i]=a[j]; a[j]=temp;
     }
     return true;
    }
   }
  }
 }
 return false;
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

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

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}

 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}

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

 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

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

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

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

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

 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}


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

public class LCM
	{

	public static long numFactors(long n)

	{

	 long result = 0;
	 boolean perfectSquare = false;

	for (long i = 1; i <= (long) Math.sqrt(n); i++)
	{
		if (n % i == 0) {
			result++;
		}
		if (i*i == n) {
			perfectSquare = true;
		}

		if (perfectSquare) {
			return 2 * result - 1;
		}
		return 2 * result;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			long b = sc.nextLong();
			System.out.println(numFactors(b));
	}
    }
}


import java.util.*;

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

        String fieldString = input.next();
        int grassHopperPos = -1;
        for (int pos = 0; pos < fieldString.length(); pos++) {
            if (fieldString.charAt(pos) == 'G' || fieldString.charAt(pos) == 'T') {
                grassHopperPos = pos;
            }
            break;
        }
        boolean nextFound = false;
        while (!nextFound) {
            grassHopperPos += jumpSize;
            if (grassHopperPos >= fieldString.length()) {
                print("NO");
                return;
            }
            if (fieldString.charAt(grassHopperPos) == '#') {
                print("NO");
                return;
            }
            if (fieldString.charAt(grassHopperPos) == 'G' || fieldString.charAt(grassHopperPos) == 'T') {
                print("YES");
                return;
            }
        }
        print("NO");
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class BOOL {
private static FastReader in =new FastReader();
    static String S,Sc;
    static int n,m=1,a,b;
    static long z=1,x,c;
    public static void main(String[] args) {
    n=in.nextInt();
    m=in.nextInt();
    a=in.nextInt();
    b=in.nextInt();
    c=(a-1)%m;
    if(b-(a-c-1)==m){System.out.println("1");return;}
    else if((b-(a-c-1))/m==1){System.out.println("2");return;}
    if(c>0)x++;
    b-=(a-c-1);
    if(b%m>0&&b!=n)x++;
    b+=(m-1);
        System.out.println(x+1);
    }


package app;

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

public class App {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int k = sc.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());

		}
		int count = 0;

		int left = 0;
		int right = list.size() - 1;

		if(list.size() == 1) {
			if(list.get(0) <= k) {
				count++;
			}
		}else {

		for (int i = 0; i < n; i++) {
			if (list.get(left) <= k) {
				count++;
				list.remove(left);
				right--;
				if (list.size() == 1 && list.get(0) <= k) {
					count++;
					break;

				}
			}
			if (list.get(right) <= k) {
				count++;
				list.remove(right);
				right--;
				if (list.size() == 1 && list.get(0) <= k) {
					count++;
					break;

				}
			}
			if (list.get(left) > k && list.get(right) > k) {
				break;
			}
			if (list.size() == 1 && list.get(0) <= k) {
				count++;
			}

		}

	}
		System.out.println(count);

}


import java.util.*;
public class Hello
{
	public static void main(String args[])
	{
		Scanner sc = new  Scanner(System.in);
		String s1=sc.next();
		String s2=sc.next();
		String s3=sc.next();
		String s4=s1+s2;
		char p1[]=String.toCharacterArray(s4);
		char p2[]=String.toCharacterArray(s3);
		Arrays.sort(p1);
		Arrays.sort(p2);
		String ans=(Arrays.equals(p1,p2)==true)?"YES"":"NO";
		System.out.println(ans);

	}
}


import java.io.*;
import java.util.*;
public class sol{
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            int num = input.nextInt();
          HashSet<Long>set = new HashSet<>();

          for(int i = 1; i<100000;i++){
            if(i*i > num)
              break;

            long num1 = i*i;
            if(num1 <= num)
              set.add(num1);

            long num2 = (long)i*(long)i*(long)i;
            if(num2 <= num)
              set.add(num2);
          }
          System.out.println(set.size());
        }
    }
}