import java.net.CookieHandler;
import java.util.*;
import java.io.*;
//import static com.sun.tools.javac.jvm.ByteCodes.swap;
// ?)(?
public class fastTemp {

    static FastScanner fs = null;
    static  ArrayList<Long> graph[] ;
    static int mod = 998244353;
    // static  int count=0;
    public static void main(String[] args) {

        fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

     //   int t = fs.nextInt();
    //    while (t-- > 0) {
      //  int n = fs.nextInt();
      //  int k = fs.nextInt();
      //int a[] = fs.readArray(n);
            String s = fs.next();
            if(s.length()<=2){
                out.println("YES");
            }else{
                boolean f = true;
                int a[] = new int[s.length()];
                a[0] = s.charAt(0)-'A' + 1;
                a[1] = s.charAt(1)-'A' + 1;
                for(int i=2;i<s.length();i++){
                    int x = a[i-1]+a[i-2];
                    // A --> 28,1,28+27
                    x = x%26;
                    if(x==0){
                        x = 26;
                    }else if(x==1){
                      f = false;
                      break;
                    }
                    int y = s.charAt(i)-'A'+1;
                    if((x-1)==y){
                        a[i] = s.charAt(i)-'A'+1;
                    }else{
                        f = false;
                        break;
                    }
                }
                if(!f){
                    out.println("NO");
                }else{
                    out.println("YES");
                }
            }

 //       }
        out.close();
    }

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

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

        }

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

    // JAVA program to compute factorial
// of big numbers
    // This function finds factorial of
    // large numbers and prints them
    static void factorial(int n)
    {
        int res[] = new int[500];

        // Initialize result
        res[0] = 1;
        int res_size = 1;

        // Apply simple factorial formula
        // n! = 1 * 2 * 3 * 4...*n
        for (int x = 2; x <= n; x++)
            res_size = multiply(x, res, res_size);

        System.out.println("Factorial of given number is ");
        for (int i = res_size - 1; i >= 0; i--)
            System.out.print(res[i]);
    }

    // This function multiplies x with the number
    // represented by res[]. res_size is size of res[] or
    // number of digits in the number represented by res[].
    // This function uses simple school mathematics for
    // multiplication. This function may value of res_size
    // and returns the new value of res_size
    static int multiply(int x, int res[], int res_size)
    {
        int carry = 0; // Initialize carry

        // One by one multiply n with individual
        // digits of res[]
        for (int i = 0; i < res_size; i++)
        {
            int prod = res[i] * x + carry;
            res[i] = prod % 10; // Store last digit of
            // 'prod' in res[]
            carry = prod/10; // Put rest in carry
        }

        // Put carry in res and increase result size
        while (carry!=0)
        {
            res[res_size] = carry % 10;
            carry = carry / 10;
            res_size++;
        }
        return res_size;
    }

    static   long fact[] = new long[200001];
    public static void fact(){
        fact[1] = 1;
        fact[0] = 1;

        for(int i=2;i<=200000;i++){
            fact[i] = (((fact[i-1])%mod) * ((i)%mod))%mod;
        }
    }
    static long lower(long array[], long key,int i,int k)
    {
        long ans=-1;
        while(i<=k){
            int mid = (i+k)/2;
            if(array[mid]>=key){
                ans = mid;
                k = mid-1;
            }else{
                i = mid+1;
            }
        }
        return ans;
    }

    static long upper(long array[], long key ,int i , int k){

        long ans = -1;
        while(i<=k){
            int mid = (i+k)/2;
            if(array[mid]<=key){
                ans = array[mid];
                i = mid+1;
            }else{
                k = mid-1;
            }
        }

        return ans;
    }

    public static class String1 implements Comparable<String1>{
        String str;
        int id;
        String1(String str , int id){
            this.str = str;
            this.id = id;
        }
        public  int compareTo(String1 o){
            int i=0;
            while(i<str.length() && str.charAt(i)==o.str.charAt(i)){
                i++;
            }
            if(i<str.length()){
                if(i%2==1){
                    return o.str.compareTo(str);   // descending order
                }else{
                    return str.compareTo(o.str);  // ascending order
                }
            }
            return str.compareTo(o.str);
        }
    }
    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

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

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

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

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

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

    static void swap(int arr[],int i,int j)
    {
        int temp=arr[i];
        arr[i]=arr[j];
        arr[j]=temp;
    }

    //-------------------------------------------seiveOfEratosthenes----------------------------------------------------

    static boolean prime[];
    static void sieveOfEratosthenes(int n)
    {
        // Create a boolean array
        // "prime[0..n]" and
        // initialize all entries
        // it as true. A value in
        // prime[i] will finally be
        // false if i is Not a
        // prime, else true.
        prime= new boolean[n + 1];
        for (int i = 0; i <= n; i++)
            prime[i] = true;

        for (int p = 2; p * p <= n; p++)
        {
            // If prime[p] is not changed, then it is a
            // prime
            if (prime[p] == true)
            {
                // Update all multiples of p
                for (int i = p * p; i <= n; i += p)
                    prime[i] = false;
            }
        }

        // Print all prime numbers
//        for (int i = 2; i <= n; i++)
//        {
//            if (prime[i] == true)
//                System.out.print(i + " ");
//        }
    }

    //------------------------------------------- power------------------------------------------------------------------

    static long power(long x, long y, long p)
    {
        long res = 1; // Initialize result

        x = x % p; // Update x if it is more than or
        // equal to p

        if (x == 0)
            return 0; // In case x is divisible by p;

        while (y > 0)
        {

            // If y is odd, multiply x with result
            if ((y & 1) != 0)
                res = (res * x) % p;

            // y must be even now
            y = y >> 1; // y = y/2
            x = (x * x) % p;
        }
        return res;
    }

    //--------------------------------------------------------------------------------------------------------------
    public static int log2(int x) {
        return (int) (Math.log(x) / Math.log(2));
    }

    //---------------------------------------EXTENDED EUCLID ALGO--------------------------------------------------------

    public static Pair Euclid(int a,int b){

        if(b==0){
            return new Pair(1,0);  // answer of x and y
        }

        Pair dash = Euclid(b,a%b);

        return new Pair(dash.y , dash.x - (a/b)*dash.y);

    }
//--------------------------------GCD------------------GCD-----------GCD--------------------------------------------

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

        return gcd(b,a%b);
    }

    static long C(int n, int k) {
        long res = 1;
        for (int i = n - k + 1; i <= n; ++i)
            res *= i;
        for (int i = 2; i <= k; ++i)
            res /= i;
        return res;
    }

}


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

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		String[] s = br.readLine().trim().split(" ");
		long x = Long.parseLong(s[0]);
		long y = Long.parseLong(s[1]);
		if(x < 0 || y < 1) System.out.println("No");
		else if(x == 0 && y == 1) System.out.println("Yes");
		else if(y == 1) System.out.println("No");
		else if(x+1 >= y && (x+y)%2 == 1) System.out.println("Yes");
		else System.out.println("No");
	}
}


/**
 * @(#)PashaAndStick.java
 *
 *
 * @author
 * @version 1.00 2016/8/24
 */

import java.util.*;

public class PashaAndStick {

    public static void main(String[]args) {

    	Scanner in = new Scanner(System.in);
    	int n = in.nextInt();
    	int numOfWays = 0;

    	if (n % 2 == 1) {
    		System.out.print("0");
    		return;
    	}
    	if (n / 2 % 2 == 1) {
    		numOfWays = n / 4;
    		System.out.println(numOfWays);
    	}
    	else {
    		numOfWays = (n/4)-1;
    		System.out.println(numOfWays);
    	}

    }

}


//pakage joney_000[let_me_start]
//codeforces
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

/******************** Main Class ***********************/

public class C
{
    public static InputStream inputStream = System.in;
    public static OutputStream outputStream = System.out;
    public static FastReader in = new FastReader(inputStream);;
    public static PrintWriter out = new PrintWriter(outputStream);;
    /*
    Overhead
    */
    public static int tempints[] = new int[100005];
    public static long templongs[] = new long[100005];
    public static double tempdoubles[] = new double[100005];
   //public static double tempdoubles[] = new double[11];
    public static char tempchars[] = new char[100005];

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

        int a = i();int b = i();int p = i();int q = i();
        long v= 1;
        long x = 0;
        long y= 0;
        long l = 1;
        long r = 100000000000000000L;

        long z= 0;
        while (l <= r)
        {
         long m = (l + r) / 2;
         v=m;
         x= v-(v/p);
         y =v-v/q;
         z= v-v/p-v/q+v/(p*q);

          //z= v-(v/g);
        //If the search key on the left half
        if (x>a&&y>b&&x+y-z>a+b)
        {
            //Update right index
            r = m - 1;
        }
        //If the search key on the right half
        else if (x<a||y<b||x+y-z<a+b)
        {
            //Update the left index
            l = m + 1;
        }
        //We found the key
        else
        {
            v= m;
            break;
        }
    }
        out.write(""+v);
          out.flush();

}

//****************************** Utilities ***********************//
 public static boolean isPrime(long n)throws Exception{
  if(n==1)return false;
  if(n<=3)return true;
  if(n%2==0)return false;
  for(int i=2 ;i <= Math.sqrt(n); i++){
   if(n%i==0)return false;
  }
  return true;
 }
 // sieve
 public static int[] primes(int n)throws Exception{       // for(int i=1;i<=arr.length-1;i++)out.write(""+arr[i]+" ");
  boolean arr[] = new boolean[n+1];
  Arrays.fill(arr,true);
  for(int i=1;i<=Math.sqrt(n);i++){
    if(!arr[i])continue;
    for(int j = 2*i ;j<=n;j+=i){
        arr[i]=false;
    }
  }
  LinkedList<Integer> ll = new LinkedList<Integer>();
  for(int i=1;i<=n;i++){
   if(arr[i])ll.add(i);
  }
  n = ll.size();

  int primes[] = new int[n+1];
  for(int i=1;i<=n;i++){
    primes[i]=ll.removeFirst();
  }
  return primes;
 }
 public static long gcd (long a , long b)throws Exception{
  if(b==0)return a;
  return gcd(b , a%b);
 }
 public static long lcm (long a , long b)throws Exception{
  if(a==0||b==0)return 0;
  return (a*b)/gcd(a,b);
 }
 public static long mulmod(long a , long b ,long mod)throws Exception{
   if(a==0||b==0)return 0;
   if(b==1)return a;
   long ans = mulmod(a,b/2,mod);
   ans = (ans*2)% mod;
   if(b%2==1)ans = (a + ans)% mod;
   return ans;
 }
 public static long pow(long a , long b ,long mod)throws Exception{
   if(b==0)return 1;
   if(b==1)return a;
   long ans = pow(a,b/2,mod);
   ans = (ans * ans)% mod;
   if(b%2==1)ans = (a * ans)% mod;
   return ans;
 }
 // 20*20   nCr Pascal Table
 public static long[][] ncrTable()throws Exception{
  long ncr[][] = new long[21][21];
  for(int i=0 ;i<=20 ;i++){ncr[i][0]=1;ncr[i][i]=1;}
  for(int j=0;j<=20 ;j++){
   for(int i=j+1;i<= 20 ;i++){
    ncr[i][j] = ncr[i-1][j]+ncr[i-1][j-1];
   }
  }
  return ncr;
 }
//*******************************I/O******************************//
public static int i()throws Exception{
 //return Integer.parseInt(br.readLine().trim());
 return in.nextInt();
}
public static int[] is(int n)throws Exception{
  //int arr[] = new int[n+1];
  for(int i=1 ; i <= n ;i++)tempints[i] = in.nextInt();
 return tempints;
}
public static long l()throws Exception{
 return in.nextLong();
}
public static long[] ls(int n)throws Exception{
  //long arr[] = new long[n+1];
  for(int i=1 ; i <= n ;i++)templongs[i] = in.nextLong();
 return templongs;
}

public static double d()throws Exception{
 return in.nextDouble();
}
public static double[] ds(int n)throws Exception{
  //double arr[] = new double[n+1];
  for(int i=1 ; i <= n ;i++)tempdoubles[i] = in.nextDouble();
 return tempdoubles;
}
public static char c()throws Exception{
 return in.nextCharacter();
}
public static char[] cs(int n)throws Exception{
  //double arr[] = new double[n+1];
  for(int i=1 ; i <= n ;i++)tempchars[i] = in.nextCharacter();
 return tempchars;
}
public static String s()throws Exception{
 return in.nextLine();
}
public static BigInteger bi()throws Exception{
 return in.nextBigInteger();
}
//***********************I/O ENDS ***********************//
//*********************** 0.3%f [precision]***********************//
/* roundoff upto 2 digits
   double roundOff = Math.round(a * 100.0) / 100.0;
                    or
   System.out.printf("%.2f", val);

*/
/* print upto 2 digits after decimal
  val = ((long)(val * 100.0))/100.0;

*/
}

class FastReader{

    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public SpaceCharFilter getFilter(){
        return filter;
    }

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

    public interface SpaceCharFilter{
        public boolean isSpaceChar(int ch);
    }
}
 /******************** Pair class ***********************/

 class Pair implements Comparable<Pair>{
 public int a;
 public int b;

 public Pair(){
  this.a = 0;
  this.b = 0;

 }
 public Pair(int a,int b , int n , long s){
  this.a = a;
  this.b = b;
 }
 public int compareTo(Pair p){
  if(this.a==p.a){
   return this.b-p.b;
  }
  return this.a-p.a;
 }
 public String toString(){
  return "a="+this.a+" b="+this.b;
 }

}


import java.util.Scanner;

public class A787 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int accel1 = scanner.nextInt();
		int initialVal1 = scanner.nextInt();
		int accel2 = scanner.nextInt();
		int initialVal2 = scanner.nextInt();
		int time = checkHit(accel1, initialVal1, accel2, initialVal2);
		System.out.println(time);
	}

	private static int checkHit(int accel1, int initialVal1, int accel2, int initialVal2) {
		if(initialVal1 % 2 != initialVal2 % 2 && accel1 % 2 == 0 && accel2 % 2 == 0)
			return -1;
		int difference = initialVal2 - initialVal1;
		int i = 0;
		int j = 0;
		while(i * accel1 - j * accel2 != difference) {
			if(i * accel1 - j * accel2 < difference)
				i++;
			else
				j++;
			if(i > accel1 * accel2 + 100|| j >= 100 + accel1 * accel2)
				return -1;
		}

		return accel1 * i + initialVal1;
	}
}


import java.io.*;
import java.lang.*;
public class gh
{
static int w=0;
public static void main(String arg[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String c=br.readLine();
    String r="";int n=0;
    String l="";
    for(int j=0;j<c.length();j++)
    {
    char e=c.charAt(j);
    if(e==' ')
    {
r=c.substring(0,j);
    l=c.substring(j+1,c.length());

    }}

    int x=Integer.parseInt(r);
    int y=Integer.parseInt(l);
    String st="";
    if(r.length()>=l.length())
    {
     n=r.length();
    int m=r.length()-l.length();
    for(int i=0;i<m;i++)
    st=st+"0";
    l=l+st;
    }
    if(r.length()<l.length())
    {
     n=l.length();
    int m=l.length()-r.length();
    for(int i=0;i<m;i++)
    st=st+"0";
    r=st+r;
    }
    int d=0;int u=0;String f="";
    for(int i=n-1;i>=0;i--)
    {
    int a=(int)r.charAt(i)-48;
    int b=(int)l.charAt(n-i-1)-48;
    w=((a+b)+d);

    d=0;
    if(w>9)
    {
    d=1;
    if(i!=0)
    w=w%10;
    }

String s= new Integer(w).toString();

   f =s+f;

    }
    int t=0;
    for(int j=0;j<f.length();j++)
    {
    if(f.charAt(j)!='0')
    {
    f=f.substring(j,f.length());
    break;
    }
    if(f.charAt(j)=='0')
    {
    t++;
    if(j==f.length()-1&&t==f.length()-1)
    f="0";
    }
    }

    System.out.println(f);
    }
    }


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

public class Edu43B {
    int n, m;
    long k;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextLong();
        solve();
    }

    void solve() {
        long ansX = 0;
        long ansY = 0;
        if (k < n) {
            ansX = (int)k + 1;
            ansY = 1;
        } else {
            k -= n;
            long count = k / (m - 1);
            ansX = n - count;
            if (count % 2 == 0) {
                ansY = 2 + (int)(k % (m - 1));
            } else {
                ansY = m - (int)(k % (m - 1));
            }
            /*
            while (true) {
                if (k <= m - 2) {
                    ansX = n - count;
                    if (count % 2 == 0) {
                        ansY = 2 + (int)k;
                    } else {
                        ansY = m - (int)k;
                    }
                    break;
                }
                k -= m - 2;
                if (k == 1) {
                    ansX = n - count - 1;
                    if (count % 2 == 0) {
                        ansY = m;
                    } else {
                        ansY = 2;
                    }
                }
                k--;
                count++;
            }
            */
        }
        System.out.printf("%d %d\n", ansX, ansY);
    }

    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.util.*;
public class NearestInterestingNumber {

   static int sum(int n){
       int x =0;
           while(n>0){
               x+=n%10;
               n/=10;
           }
           return x;
   }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while(sum(n)%4!=0){
            n++;
        }
        System.out.println(n);

        }
        }


import java.util.Scanner;

public class Main{
    public static void main(String [] args){
        Scanner ler = new Scanner(System.in);
        int resp=0;
        String horas = ler.nextLine();
        char hr[]=horas.toCharArray();
        while(hr[0]!=hr[4]||hr[1]!=hr[3]){
            resp++;
            hr[4]++;
            if(hr[4]=='9'+1){
                hr[4]='0';
                hr[3]++;
            }
            if(hr[3]=='5'+1){
                hr[3]='0';
                hr[1]++;
            }
            if(hr[1]=='9'+1){
                hr[1]='0';
                hr[0]++;
            }
            if(hr[0]=='2'&&hr[1]=='4'){
                hr[0]='0';
                hr[1]='0';
                hr[3]='0';
                hr[4]='0';
                break;
            }

        }
            System.out.println(resp);
    }
}
// 1507612192946


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

public class Main {

    private static StringBuilder data = new StringBuilder();
    private final static FastReader in = new FastReader();

    public static void main(String[] args) {

      String s=in.line();
     if(s.charAt(0)>'a'&&s.charAt(0)<'h'&&s.charAt(1)>'1'&&s.charAt(1)<'8'){
         System.out.println(8);
     }else if((s.charAt(0)=='a'||s.charAt(0)=='h')&&(s.charAt(1)=='1'||s.charAt(1)=='8')){
         System.out.println(3);
     }else{
         System.out.println(5);
     }
    }

    static void fileOut(String s) {
        File out = new File("output.txt");
        try {
            FileWriter fw = new FileWriter(out);
            fw.write(s);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        public FastReader(String path) {
            try {
                br = new BufferedReader(new
                        InputStreamReader(new FileInputStream(path)));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

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

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

        float floaT() {
            return Float.parseFloat(next());
        }

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

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

}


/* 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();
        for(int i=1;i*(i+1)<=n;i++)
        {
            int j=(int)Math.sqrt(2*n-i*(i+1));
            if(j>=0 && i*(i+1)+(j*(j+1))==2*n)
            {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            DPickingStrings solver = new DPickingStrings();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class DPickingStrings {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int limit = (int) 1e5;
            char[] S = new char[limit];
            char[] T = new char[limit];

            int n = in.readString(S, 0);
            int m = in.readString(T, 0);
            int[] a = new int[n];
            int[] b = new int[m];
            int[] aLeft = new int[n];
            int[] bLeft = new int[m];
            for (int i = 0; i < n; i++) {
                a[i] = S[i] == 'A' ? 0 : 1;
                aLeft[i] = i == 0 ? -1 : aLeft[i - 1];
                if (a[i] == 1) {
                    aLeft[i] = i;
                }
            }
            for (int i = 0; i < m; i++) {
                b[i] = T[i] == 'A' ? 0 : 1;
                bLeft[i] = i == 0 ? -1 : bLeft[i - 1];
                if (b[i] == 1) {
                    bLeft[i] = i;
                }
            }

            IntegerPreSum psA = new IntegerPreSum(a);
            IntegerPreSum psB = new IntegerPreSum(b);

            int q = in.readInt();
            for (int i = 0; i < q; i++) {
                int l1 = in.readInt() - 1;
                int r1 = in.readInt() - 1;
                int l2 = in.readInt() - 1;
                int r2 = in.readInt() - 1;

                int c1 = psA.intervalSum(l1, r1);
                int c2 = psB.intervalSum(l2, r2);
                if (c2 < c1 || (c2 - c1) % 2 == 1) {
                    out.append(0);
                    continue;
                }
                int len1 = r1 - Math.max(l1 - 1, aLeft[r1]);
                int len2 = r2 - Math.max(l2 - 1, bLeft[r2]);
                if (c2 == c1) {
                    if (len2 > len1 || (len1 - len2) % 3 != 0) {
                        out.append(0);
                    } else {
                        out.append(1);
                    }
                    continue;
                }
                if (c2 > 0 && c1 == 0) {
                    len2++;
                }
                if (len2 > len1) {
                    out.append(0);
                } else {
                    out.append(1);
                }
            }
        }

    }

    static class IntegerPreSum {
        private int[] pre;
        private int n;

        public IntegerPreSum(int n) {
            pre = new int[n];
        }

        public void populate(int[] a) {
            n = a.length;
            pre[0] = a[0];
            for (int i = 1; i < n; i++) {
                pre[i] = pre[i - 1] + a[i];
            }
        }

        public IntegerPreSum(int[] a) {
            this(a.length);
            populate(a);
        }

        public int intervalSum(int l, int r) {
            return prefix(r) - prefix(l - 1);
        }

        public int prefix(int i) {
            if (i < 0) {
                return 0;
            }
            return pre[Math.min(i, n - 1)];
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 20];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

    }
}


import java.util.*;
import java.math.BigInteger;
public class A66 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger x = sc.nextBigInteger();
        if((x.compareTo(BigInteger.valueOf(127)) <= 0) && (x.compareTo(BigInteger.valueOf(-128)) >= 0)){
            System.out.println("byte");
        }
        else if((x.compareTo(BigInteger.valueOf(32767)) <= 0) && (x.compareTo(BigInteger.valueOf(-32768)) >= 0)){
            System.out.println("short");
        }
        else if((x.compareTo(BigInteger.valueOf(2147483647)) <= 0) && (x.compareTo(BigInteger.valueOf(-2147483648)) >= 0)){
            System.out.println("int");
        }
        else if((x.compareTo(BigInteger.valueOf(9223372036854775807L)) <= 0) && (x.compareTo(BigInteger.valueOf(-9223372036854775808L)) >= 0)){
            System.out.println("long");
        }
        else System.out.println("BigInteger");
    }

}


//package round51;

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

public class D {
	Scanner in;
	PrintWriter out;
//	String INPUT = "10 1 9000000000000000000 1 9000000000000000000 1 9000000000000000000 1 9000000000000000000 1 9000000000000000000 1 9000000000000000000 1 9000000000000000000 1 9000000000000000000 1 9000000000000000000 1 9000000000000000000";
//	String INPUT = "1 12 15";
//	String INPUT = "1 1 9";
	String INPUT = "";
	int[] imap = new int[48];
	int[][] u = new int[48][10];

	void solve()
	{
		BitSet bs = new BitSet();
		bs.set(1, 10);
		int p = 0;
		for(int i = bs.nextSetBit(0);i != -1;i = bs.nextSetBit(i+1)){
			for(int j = bs.nextSetBit(i+1);j != -1;j = bs.nextSetBit(j+1)){
				bs.set(i*j/gcd(i,j));
			}
			imap[p++] = i;
		}
//		tr(bs.cardinality());

		for(int i = 0;i < 48;i++){
			for(int j = 1;j <= 9;j++){
				int lcm = imap[i] * j / gcd(imap[i], j);
				for(int k = 0;k < 48;k++){
					if(lcm == imap[k]){
						u[i][j] = k;
						if(j == 1)u[i][0] = u[i][1];
						break;
					}
				}
			}
		}

		for(int i = 0;i < 2520;i++){
			for(int j = 0;j <= 9;j++){
				momo[i][j] = (10*i+j)%2520;
			}
		}

		int t = ni();
		long s = System.currentTimeMillis();
		for(int i = 0;i < t;i++){
			long l = in.nextLong();
			long r = in.nextLong();
			out.println(count(r) - count(l-1));
		}
		long g = System.currentTimeMillis();
		tr(g-s+"ms");
	}

	int[][] momo = new int[2520][10];
	long[][][] dp = new long[19][48][2520];

	int gcd(int a, int b)
	{
		while(b > 0){
			int c = a; a = b; b = c % b;
		}
		return a;
	}

	long count(long n)
	{
		for(int i = 0;i < 19;i++){
			for(int j = 0;j < 48;j++){
				Arrays.fill(dp[i][j], 0);
			}
		}

		char[] ch = Long.toString(n).toCharArray();
		int code = 0;
		int mod = 0;
		for(int i = 0, j = 19 - ch.length;i < ch.length;i++,j++){
			int sup = i == ch.length - 1 ? ch[i] + 1 : ch[i];
			for(char c = '0';c < sup;c++){
				int d = c - '0';
				dp[j][u[code][d]][momo[mod][d]] = 1;
			}
			code = u[code][ch[i] - '0'];
			mod = momo[mod][ch[i]-'0'];
		}
		for(int i = 0;i < 18;i++){
			for(int j = 0;j < 48;j++){
				for(int k = 0;k < 2520;k++){
					if(dp[i][j][k] > 0){
						for(int l = 0;l <= 9;l++){
							dp[i+1][u[j][l]][momo[k][l]] += dp[i][j][k];
						}
					}
				}
			}
		}

		long ct = 0;
		for(int j = 0;j < 48;j++){
			for(int k = 0;k < 2520;k+=imap[j]){
				ct += dp[18][j][k];
			}
		}
		return ct;
	}

	void run() throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);

		solve();
		out.flush();
	}

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

	int ni() { return Integer.parseInt(in.next()); }
	void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


import java.util.Scanner;

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

        int n = r.nextInt();
        int m = r.nextInt();
        int k = r.nextInt();

        if(n % 2 == 0){
            System.out.println("Marsel");
        }else{
            boolean can = false;
            for(int d = 1; d * d <= m; d++)if( m % d == 0 ){
//              System.out.println(d);
                if((m / d > 1 && d >= k) || (d > 1 && m / d >= k))can = true;
            }

            if(can)System.out.println("Timur");
            else System.out.println("Marsel");
        }
    }
}


import java.util.*;
import java.io.*;
public class D1195 {
    public static int[] findMin(int[] a, int window) {
        int[] result = new int[a.length - window + 1];
        Deque<Integer> deque = new ArrayDeque<>();
        for (int i = 0; i < a.length; i++) {  // Range end index (inclusive)
            int val = a[i];
            while (!deque.isEmpty() && val < deque.getLast())
                deque.removeLast();
            deque.addLast(val);

            int j = i + 1 - window;  // Range start index, does not overflow
            if (j >= 0) {
                result[j] = deque.getFirst();
                if (a[j] == result[j])
                    deque.removeFirst();
            }
        }
        return result;
    }
    public static void main(String[] args) {
        Scanner f = new Scanner(System.in);
        int n = f.nextInt(),m=f.nextInt(),a=f.nextInt(),b=f.nextInt();
        long g0=f.nextInt(),x=f.nextInt(),y=f.nextInt(),z=f.nextInt();
        int[][] A = new int[n][m], minrow = new int[n][m-b+1], min = new int[m-b+1][n-a+1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i != 0 || j != 0) g0 = (g0 * x + y) % z;
                A[i][j] = (int) g0;
            }
        }
//        System.out.println(Arrays.deepToString(A));
        for (int i = 0; i < n; i++) {
            minrow[i] = findMin(A[i], b);
        }
        int[][] minrowT = new int[m-b+1][n];
        for (int i = 0; i < m-b+1; i++) {
            for (int j = 0; j < n; j++) {
                minrowT[i][j] = minrow[j][i];
            }
        }
//        System.out.println(Arrays.deepToString(minrow));
        for (int i = 0; i < m-b+1; i++) {
            min[i] = findMin(minrowT[i], a);
        }
//        System.out.println(Arrays.deepToString(min));
        long ans = 0;
        for (int i = 0; i < m-b+1; i++) {
            for (int j = 0; j < n-a+1; j++) {
                ans += min[i][j];
            }
        }
        System.out.println(ans);
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.math.BigInteger;
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();
	}
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.readInt();
        int a[] = new int[n];
        for (int i = 0; i < n ;i++) a[i] = in.readInt();
        Arrays.sort(a);
        for (int i = 0; i < n ;i++) out.print(a[i] + " ");
    }
}

class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

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

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

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

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

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

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


import java.util.*;
public class WordCorrection {

	static String vowel = "aeiouy";

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextLine())
		{
			sc.nextLine();
			String word = sc.nextLine();
			while (consecutive(word))
			{
				word = remove(word);
			}
			System.out.println(word);
		}
		sc.close();
	}

	public static boolean consecutive(String s)
	{
		for (int i = 0; i < s.length() - 1; i++)
			if (vowel.indexOf(s.substring(i,i+1)) != -1 && vowel.indexOf(s.substring(i+1, i+2)) != -1)
				return true;
		return false;
	}

	public static String remove(String s)
	{
		for (int i = 0; i < s.length() - 1; i++)
			if (vowel.indexOf(s.substring(i,i+1)) != -1 && vowel.indexOf(s.substring(i+1, i+2)) != -1)
				return s.substring(0,i + 1) + s.substring(i + 2);
		return "";
	}

}


import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author hossam
 */
public class Ps {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s=in.next();
        int m=1;
        int a[]={2,7,2,3,3,4,2,5,1,2};
        for(int i=0;i<s.length();i++)
        {
            m*=a[(int)s.charAt(i)-48];
        }
        System.out.println(m);

    }}


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
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();
    }
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int []a = in.primitiveIntArray(0,3);
        out.print(Math.max(a[0] + a[1] + a[2],Math.max(a[0] *(a[1] + a[2]),Math.max((a[0] + a[1])*a[2],a[0]*a[1]*a[2]))));
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

    public int[] primitiveIntArray(int startIndex,int size){
        if (startIndex == 1)size++;
        int []array = new int[size];
        for (int i = startIndex; i < size; i++) {
            array[i] = Integer.parseInt(next());
        }
        return array;
    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main (String[] args) throws Exception{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer s=new StringTokenizer(buf.readLine());
        String x = s.nextToken();
        BigInteger ans = BigInteger.ONE;
        BigInteger nine = new BigInteger("9");
        Set<Integer> ss = new HashSet<>();
        int cnt = 0;
        for (int i=0; i<x.length(); i++) {
            char y = x.charAt(i);
            if (y =='?') {
                if (i==0) ans = ans.multiply(nine);
                else cnt++;
            } else if (y >= 'A' && y <= 'J') {
                int num = y - 'A';
                if (ss.contains(num)) continue;
                ss.add(num);
                if (i==0) ans = ans.multiply(nine);
                else {
                    int yy = 11 - ss.size();
                    ans = ans.multiply(new BigInteger(String.valueOf(yy)));
                }
            }
        }

        System.out.print(ans);
        for(int i=0;i<cnt;i++) System.out.print("0");
    }
}


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

public class Main{

    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner (in);
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));

        int n = sc.nextInt();

        writer.write(String.valueOf(n == 2 || n == 3 || n == 4 || n == 5 || n == 12 || n == 30 || n == 35 || n == 43 || n == 46 || n == 52 || n == 64 || n == 86? "YES": "NO"));
        writer.write(lineSeparator());
        writer.flush();
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.LinkedHashMap;

public class Main4 {

	HashMap<Long, Long> m = new HashMap<>();
	long max = -1;
	public Main4() throws Exception {

		BufferedWriter out;
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedWriter(new OutputStreamWriter(System.out));

			String s[] = in.readLine().split(" ");
			int r = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			for(int i=0; i<r ; i++){
				String s1 = in.readLine();
			}
			for(int i=0; i<b ; i++){
				String s1 = in.readLine();
			}

			if(r==b)
				out.write("Yes");
			else
				out.write("No");
			out.flush();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}

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


import java.util.*;
public class ornament {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int y = in.nextInt();
		int b = in.nextInt();
		int r = in.nextInt();
		int maxi = Math.min(r-2,Math.min(y, b-1));
		System.out.println(3*(maxi+1));
		in.close();
	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author da_201612051
 */
public class Main {

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

  static class TaskA1 {

    public void solve(int testNumber, FastIO in, PrintWriter out) {
      int n = in.nextInt();
      int k = in.nextInt();
      int[] query = in.nextIntArray(n);
      int cost = 0;
      Set<Integer> availableBooks = new HashSet<>(k);
      int[] access = new int[81];
      int removable = -1;
      for (int i = 0; i < n; i++) {
        access[query[i]]++;
      }
      for (int i = 0; i < n; i++) {
        int currentBook = query[i];
        boolean doesNotContain = !availableBooks.contains(currentBook);
        if (doesNotContain) {
          cost++;
        }
        if (removable != -1) {
          availableBooks.remove(removable);
          removable = -1;
        } else if (availableBooks.size() == k && doesNotContain) {
          int removableBook = -1;
          int count = k;
          Set<Integer> known = new HashSet<>();
          for (int j = i + 1; j < n && count > 0; j++) {
            if (availableBooks.contains(query[j]) && !known.contains(query[j])) {
              count--;
              known.add(query[j]);
              removableBook = query[j];
            }
          }
          if (removableBook != -1) {
            availableBooks.remove(removableBook);
          } else {
            availableBooks.remove(availableBooks.iterator().next());
          }
        }
        availableBooks.add(currentBook);
        if (--access[currentBook] == 0) {
          removable = currentBook;
        }
      }
      out.println(cost);
    }

  }

  static class FastIO {

    final private int BUFFER_SIZE = 1 << 16;
    private InputStream din;
    private byte[] buffer;
    private int bufferPointer;
    private int bytesRead;

    public FastIO() {
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public FastIO(InputStream inputStream) {
      this();
      din = new DataInputStream(inputStream);
    }

    public FastIO(String file_name) {
      try {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }
    }

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

        if (neg) {
          return -ret;
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      return ret;
    }

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

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

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

  }
}


import java.util.Scanner;

public class B_Door_Frames {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int a = input.nextInt();
		int b = input.nextInt();
		if (2 * b + 4 * a <= n){
			System.out.println(1);
		}else if (b + 2 * a <= n){
			System.out.println(2);
		}else if (4 * a <= n || 2 * b <= n && 2 * a <= n || a + b <= n && 2 * a <= n){
			System.out.println(3);
		}else if (a + b <= n || 2 * a <= n){
			System.out.println(4);
		}else if (2 * b <= n){
			System.out.println(5);
		}else{
			System.out.println(6);
		}
	}

}


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

public class ranjan{

    //public static Read cin;
    public static InputReader cin;
    public static PrintWriter cout;
    public static int[] visited;
    public static final long bil = (long)1e9+7;
    public static int fileread = 0;

    public static void main(String ...arg) throws IOException
    {
        /*console writer*/
        cout = new PrintWriter(new BufferedOutputStream(System.out));
        /*Debug Reader*/
        //Scan cin =new Scan();
        if(fileread == 1)
        {
            try
            {
            //cin = new Read(new FileInputStream(new File("in1.txt")));
            cin = new InputReader(new FileInputStream(new File("in4.txt")));
            }
            catch (IOException error){}
        }
        else{
            //cin = new Read(System.in);
            cin = new InputReader(System.in);
        }

        long t1 = cin.nextInt();
        long t2 = cin.nextInt();
        long x1 = cin.nextInt();
        long x2 = cin.nextInt();
        long t0 = cin.nextInt();

        if(t1 == t2)
        {
            cout.print(x1+" "+x2);
            cout.close();
            return;
        }

        long y1=-1,y2 = -1;
        double RHS = (double)(t0 - t1)/(t2 - t0),temp = (double)Double.MAX_VALUE;
        for(long i=x1;i>=0;i--)
        {
            long j = (int)Math.ceil(RHS*i);
            double t = (double)(t1*i + t2*j)/(i+j);
            if(j<=x2 && t<temp)
            {
                y1 = i;
                y2 = j;
                temp = t;
            }
        }
        if(y1!=-1)
            cout.print(y1+" "+y2);
        else
            cout.print(0+" "+x2);
        cout.close();
    }

    /*public static void seive(int size)
    {
        prime[0] = prime[1] = false;
        int p = 2;
        while(p*p<= size)
        {
            if(prime[p])
            {
                for(int i=p*p;i<size;i += p)
                    prime[i] = false;
            }
            p++;
        }
    }*/

    public static <K, V> V getOrDefault(HashMap<K,V> map, K key, V defaultValue) {
        return map.containsKey(key) ? map.get(key) : defaultValue;
    }

    public static long mod_pow(long x,long n,long mod) {
        long res=1;
        while(n>0) {
            if((n&1)==1)res=res*x%mod;
            x=x*x%mod;
            n>>=1;
        }
        return res;
    }
    public static int gcd(int n1, int n2)
    {
        int r;
        while (n2 != 0)
        {
            r = n1 % n2;
            n1 = n2;
            n2 = r;
        }
        return n1;
    }

    /*public static int lcm(int n1, int n2)
    {
        int answer = (n1 * n2) / (gcd(n1, n2));
        return answer;
    }*/

    static class InputReader {
        final InputStream is;
        final byte[] buf = new byte[1024];
        int pos;
        int size;

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

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

        int read() {
            if (size == -1)
                throw new InputMismatchException();
            if (pos >= size) {
                pos = 0;
                try {
                    size = is.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (size <= 0)
                    return -1;
            }
            return buf[pos++] & 255;
        }

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

    }

static class RecursionLimiter {
    public static long maxLevel = 100000L;

    public static void emerge() {
        if (maxLevel == 0)
            return;
        try {
            throw new IllegalStateException("Too deep, emerging");
        } catch (IllegalStateException e) {
            if (e.getStackTrace().length > maxLevel + 1)
                throw e;
        }
    }
}

static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }

}

class Read
{
    private BufferedReader br;
    private StringTokenizer st;

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

    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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class C {

    public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    public static StringTokenizer tok;

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

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

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

    public static String nextToken() throws IOException {
        if (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    public static void main(String[] args) throws IOException {
        int n = nextInt();
        int m = nextInt();
        List<Set<Integer>> graph = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            graph.add(new HashSet<>());
        }
        for (int i = 0; i < m; i++) {
            int u = nextInt() - 1;
            int v = nextInt() - 1;
            graph.get(u).add(v);
            graph.get(v).add(u);
        }
        List<Set<Integer>> reverse = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            reverse.add(new HashSet<>());
            for (int j = 0; j < n; j++) {
                if (i != j && !graph.get(i).contains(j)) {
                    reverse.get(i).add(j);
                }
            }
        }
        ArrayList<Character> line = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            line.add(null);
        }
        Queue<Integer> queue = new LinkedList<>();
        int index = -1;
        for (int i = 0; i < n; i++) {
            if (reverse.get(i).isEmpty()) {
                line.set(i, 'b');
            } else if (index == -1) {
                index = i;
            }
        }
        if (index != -1) {
            queue.add(index);
            line.set(index, 'a');
            while (!queue.isEmpty()) {
                int x = queue.remove();
                char other = line.get(x) == 'a' ? 'c' : 'a';
                for (int near: reverse.get(x)) {
                    if (line.get(near) == null) {
                        line.set(near, other);
                        queue.add(near);
                    } else if (line.get(x) == line.get(near)) {
                        System.out.println("No");
                        return;
                    }
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (line.get(i) == null) {
                System.out.println("No");
                return;
            }
        }
        for (int i = 0; i < n; i++) {
            for (int near: graph.get(i)) {
                if (line.get(i) == 'a' && line.get(near) == 'c' || line.get(i) == 'c' && line.get(near) == 'a') {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
        for (int i = 0; i < n; i++) {
            System.out.print(line.get(i));
        }
    }
}


import java.util.*;
public class gg{
	static int special(int u, int k,int []a){
		if(a[u]==1)
			return k-u;
		if(a[k]==1000)
			return k-u;
		else
			return k-u-1;
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		int i,max=0;
		for(i=0;i<n;i++)
			a[i]=sc.nextInt();
		Arrays.sort(a);
		int c=0,k=0,u=0,l=0;
		boolean g=true;
		for(i=0;i<n-1;i++){
			if(a[i+1]-a[i]==1&&g==true)
			{
				u=i;
				g=false;
				//System.out.println(u);
			}
			if(a[i+1]-a[i]!=1&&g==false)
			{
				k=i;
				g=true;
				 l=special(u,k,a);
				if(l>max)
					max=l;
				//c=c+l;
				//if(l!=0)
				//break;
			}
		}
		if(!g)
		{
			k=n-1;
			l=special(u,k,a);
			if(l>max)
			max=l;
		}
		//System.out.println(u+" "+k);
		System.out.println(max);
	}
}


import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		char c[]=s.toCharArray();
		char aa='1',bb='1';
		int max=-1;
		for(int i=0;i<c.length-1;i++){
			char a=c[i],b=c[i+1];
			int con=1;
			for(int j=i+1;j<c.length-1;j++){
				if(c[j]==c[i]&&c[j+1]==c[i+1]){
					con++;
				}
			}
			if(con>max){
				max=con;
				aa=a;bb=b;
			}else if(con==max&&(a<aa||(a==aa&&b<bb))){
					aa=a;bb=b;
			}
		}
		System.out.println(aa+""+bb);
	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

public class Train {
	public static void main(String args[]) throws IOException {
		EhabReader sc = new EhabReader();
		PrintWriter out = new PrintWriter(System.out);
		// code
		int n = sc.nextInt();
		int res = n > 1 ? 1 : 0;
		for (double i = 2.0; i <= n / 2; i++) {
			if ((n - i) % i == 0) {
				res++;
			}
		}
		out.println(res);
		out.flush();
		out.close();

	}

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

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

		public String nextLine() {
			// TODO Auto-generated method stub
			return null;
		}

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

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

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

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

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

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

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

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

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

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

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

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


import java.util.*;
public class Test {
	public static void main(String[]Args)
	{
		Scanner A = new Scanner(System.in);
		int x = A.nextInt();
		int b = 0;//helper(x,1);
		while(x > 4)
			x -= 4;
		switch(x){
		case 4: b = 6;break;
		case 3: b = 2;break;
		case 2: b = 4;break;
		case 1: b = 8;break;
		default: b = 1;
		}
		System.out.print(b);
	}

	public static int helper(int x, int b){
		if (x == 0){
			return b;
		}
		if(x >= 10000000){
			int counter = 100000;
			while(counter != 0){
				b = b*1378;
				b = b%10;
				counter--;
			}
			return(helper(x-100000, b));
		}
		if (x >= 10000)
		{
			int counter = 1000;
			while (counter != 0){
				b = b*1378;
				b = b%10;
				counter--;
			}
			return helper(x-1000, b);
		}
		b *= 1378;
		b = b%10;
		return helper((x-1),b);

	}

}


import java.util.*;
// warm-up
public class VasyaAndTheBus {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),c=sc.nextInt(),min=0,max=0;
		if (a==0 && c>0) System.out.println("Impossible");
		else {
			min=a+((c>a) ? c-a : 0);
			max=a+((c>0) ? c-1 : 0);
			System.out.println(min+" "+max);
		}
		sc.close();
	}

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

}


/* package codechef; // 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 Codechef
{
    int arr[],sum;
    Codechef()
    {
        arr=new int[8];
        sum=0;
        Scanner in=new Scanner(System.in);
        for(int i=0;i<5;++i)
        {
            arr[i]=in.nextInt();
            sum+=arr[i];
        }
    }

    int f()
    {
        HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();
        for(int i=0;i<5;++i)
        {
            if(hm.get(arr[i])!=null)
            {
                int v=hm.get(arr[i]);
                hm.put(arr[i],v+1 );
            }
            else
            {
                hm.put(arr[i],1);
            }
        }
        //System.out.println(sum);
        Set<Integer> keys=hm.keySet();
        int ans=10000;
        for(int x:keys)
        {
            //System.out.println(x+"    "+hm.get(x));
            int v=hm.get(x);
            if(v==2)
            {
                ans=Math.min(ans,sum-(2*x));
            }
            else if(v>=3)
            {
                ans=Math.min(ans,sum-(3*x));
            }
            //System.out.println(ans);
        }
        if(ans==10000) return sum;
        return ans;
    }

	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Codechef cf=new Codechef();
		System.out.println(cf.f());
	}
}


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

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

    static class TaskA
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int n = in.nextInt();
            int S = in.nextInt();
            int[] a = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                a[i] = in.nextInt();
                sum += a[i];
            }

            Arrays.sort(a);
            sum -= a[n - 1];
            if (sum <= S)
            {
                out.println("YES");
                return;
            }
            out.println("NO");
        }

    }

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

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

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

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

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

    }

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

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

    }
}


import java.util.*;
import java.text.DecimalFormat;
public class Main {
    public static void main( String[] args ) {
        Scanner cin = new Scanner( System.in );
        String j = cin.nextLine( );
        String[] h = j.split( ":" );
        int hour = Integer.parseInt( h[0] );
        int minute = Integer.parseInt( h[1] );
        int temp;
        DecimalFormat print = new DecimalFormat("00");
        do{
            if( minute < 59 )
                minute++;
            else if( hour < 23 ){
                hour++;
                minute = 0;
            }else{
                hour = 0;
                minute = 0;
            }
            temp = minute/10;
            h[0] = print.format(hour);
            h[1] = print.format(((minute%10)*10 + temp) );
        }while( !h[0].equals( h[1] ) );
        System.out.println( h[0]+":"+print.format(minute) );
    }
}


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

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

    static class ProblemBStringTyping {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            String str = in.readLine();
            int ans = str.length();
            String temp = "";
            int idx = -1;
            for (int i = temp.length(); i < str.length(); i = temp.length()) {
                String t = str.substring(i);
                if (temp.length() > 0 && t.startsWith(temp)) {
                    idx = i;
                }
                temp += str.charAt(i);
            }
            if (idx > 0) ans = ans - idx + 1;
            out.println(ans);

        }

    }

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

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

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

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

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

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

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

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

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

        }

    }
}


import java.util.*;
import java.lang.*;
import java.util.Scanner;
public class solution{
    public static void main(String args[]){
        Scanner sc =new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int res = a;
        while(a>=b){
            res += (a/b);
            a = (a/b)+(a%b);
        }
        //res += a;
       System.out.println(res);
    }
}


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

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

		String a = in.nextLine().substring(2);
		String b = in.nextLine().substring(2);
		String c = in.nextLine().substring(2);
		String d = in.nextLine().substring(2);
		boolean isOka = test(a, b, c, d);
		boolean isOkb = test(b,a,c,d);
		boolean isOkd = test(d,a,b,c);
		boolean isOkc = test(c, a, b, d);
		if((isOka? 1 :0) + (isOkb? 1 : 0) + (isOkc? 1: 0) + (isOkd? 1 : 0) ==1) {
			if(isOka) out.println("A");
			if(isOkb) out.println("B");
			if(isOkc) out.println("C");
			if(isOkd) out.println("D");
		}	else out.println("C");

		out.close();
	}

	private static boolean test(String d, String a, String b, String c) {
		return (d.length()*2<=a.length() && d.length()*2<=b.length() && d.length()*2<=c.length()) ||
				(d.length()>=a.length()*2 && d.length() >= b.length()*2 && d.length() >= c.length()*2);
	}
}


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

public class C {
	static final int MOD_PRIME = 1000000007;

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

		int i = 0;
		int t = 1;
		//t = in.nextInt();
		for (; i < t; i++)
			solver.solve(i, in, out);

		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			long m = in.nextLong();
			long[] fact = new long[n+1];
			fact[0] = 1;
			for(int i = 1; i <= n; i++) {
				fact[i] = (fact[i-1]*i) % m;
			}
			long total = 0;
			for(int i = 0; i < n; i++) {
				total = (total + (n-i)*((fact[i+1] * fact[n-i]) % m)) % m;
			}
			out.print(total);

		}
	}

	// template code

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

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

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

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

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

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

	}

	static long modexp(long a, long b, long p) {
		// returns a to the power b mod p by modular exponentiation

		long res = 1;
		long mult = a % p;
		while (b > 0) {
			if (b % 2 == 1) {
				res = (res * mult) % p;
			}
			b /= 2;
			mult = (mult * mult) % p;
		}

		return res;
	}

	static double log(double arg, double base) {
		// returns log of a base b, contains floating point errors, dont use for exact
		// calculations.

		if (base < 0 || base == 1) {
			throw new ArithmeticException("base cant be 1 or negative");
		}
		if (arg < 0) {
			throw new ArithmeticException("log of negative number undefined");
		}
		return Math.log10(arg) / Math.log10(base);
	}

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

		return gcd(b, a % b);

	}

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

		return gcd(b, a % b);

	}

	// scope for improvement
	static ArrayList<Integer> sieveOfEratosthenes(int n) {
		boolean[] check = new boolean[n + 1];
		ArrayList<Integer> prime = new ArrayList<Integer>();
		for (long i = 2; i <= n; i++) {
			if (!check[(int) i]) {
				prime.add((int) i);
				for (long j = i * i; j <= n; j += i) {
					check[(int) j] = true;
				}
			}
		}

		return prime;
	}

	static int modInverse(int a, int n) {
		// returns inverse of a mod n by extended euclidean algorithm
		int t = 0;
		int newt = 1;
		int r = n;
		int newr = a;
		int quotient;
		int tempr, tempt;
		while (newr != 0) {
			quotient = r / newr;
			tempt = newt;
			tempr = newr;
			newr = r - quotient * tempr;
			newt = t - quotient * tempt;
			t = tempt;
			r = tempr;
		}
		if (r > 1) {
			throw new ArithmeticException("inverse of " + a + " mod " + n + " does not exist");
		} else {
			if (t < 0) {
				t += n;
			}
			return t;
		}
	}

	static int primeModInverse(int a, int n) {
		// returns inverse of a mod n by mod exponentiation, use only if n is prime
		return (int) modexp(a, n - 2, n);
	}

	static void dfs(HashMap<Integer, ArrayList<Integer>> adj, Set<Integer> ans, Set<Integer> open,
			HashMap<String, Integer> edge, boolean[] vis, int i) {
		vis[i] = true;
		open.add(i);
		if (adj.get(i) != null) {
			for (int k : adj.get(i)) {
				if (!vis[k]) {
					dfs(adj, ans, open, edge, vis, k);
				} else if (open.contains(k)) {
					ans.add(edge.get(String.valueOf(i) + " " + String.valueOf(k)));
				}
			}
		}
		open.remove(i);
	}
}