#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

//DEBUG_OUT("----\n");
void func(void)
{
    string s;
    cin >> s;

    bool isOK = true;
    int i;
    int p = 0;
    for(i=0; i<s.size(); i++){
        // wait A
        if(p==0){
            if(s[i] == 'A'){ p++; }
            else if(s[i] == 'K'){ p += 2; }
            else { isOK = false; p=-1; break; }
        }
        // wait K
        else if(p==1){
            if(s[i] == 'K'){ p++; }
            else { isOK = false; p=-1; break; }
        }
        // wait I
        else if(p==2){
            if(s[i] == 'I'){ p++; }
            else { isOK = false; p=-1; break; }
        }
        // wait H
        else if(p==3){
            if(s[i] == 'H'){ p++; }
            else { isOK = false; p=-1; break; }
        }
        // wait A
        else if(p==4){
            if(s[i] == 'A'){ p++; }
            else if(s[i] == 'B'){ p += 2; }
            else { isOK = false; p=-1; break; }
        }
        // wait B
        else if(p==5){
            if(s[i] == 'B'){ p++; }
            else { isOK = false; p=-1; break; }
        }
        // wait A
        else if(p==6){
            if(s[i] == 'A'){ p++; }
            else if(s[i] == 'R'){ p += 2; }
            else { isOK = false; p=-1; break; }
        }
        // wait R
        else if(p==7){
            if(s[i] == 'R'){ p++; }
            else { isOK = false; p=-1; break; }
        }
        // wait A
        else if(p==8){
            if(s[i] == 'A'){ p++; }
            else { isOK = false; p=-1; break; }
        }
        // no wait
        else if(p>=9){
            p = -1;
            isOK = false; break;
        }

    }

    if(p==8){ isOK = true; p++; }
    if(p!=9){ isOK = false; }

    if(isOK){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 256