#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 101000
typedef unsigned int uint;
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar();
	while (!isdigit(c)) c=  getchar();
	while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
}
using namespace std;
int n, nn;
char s[N];
uint f[N];
inline uint quickpow(uint x, int k) {
	uint res = 1;
	while (k) {
		if (k & 1)	res = res * x;
		x = x * x;
		k >>= 1;
	}
	return res;
}
int main() {
	read(n); scanf("%s", s + 1);
	if (n & 1)	return puts("0"), 0;
	f[0] = 1; nn = n >> 1;
	int cnt = 0;
	for (int i = 1; i <= n; ++i) if (s[i] == '?') {
		for (int j = i >> 1; j >= i - nn && j; --j) f[j] += f[j - 1];
	} else ++cnt;
	if (cnt > nn)	return puts("0"), 0;
	uint ans = f[nn] * quickpow(25u, nn - cnt);
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define ui unsigned int

using namespace std;

int n;
string s;
ui dp[100010];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> s;
	if (n & 1)
	{
		cout << 0 << endl;
		return 0;
	}
	s = ' ' + s;
	dp[0] = 1;
	int times = n / 2;
	for (int i = 1; i <= n; i++)
	{
		if (s[i] != '?') times--;
		else
			for (int j = i / 2; j > 0 && j >= i - n / 2; j--)
				dp[j] += dp[j - 1];
	}
	ui ans = dp[n / 2];
	while (times > 0) ans *= 25, times--;
	cout << ans << endl;
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int main(){
	int n;
	char str[100005];
	unsigned dp[50005] = {};
	scanf("%d %s",&n, str + 1);
	dp[0] = 1;
	for(int i=1; i<=n; i++){
		if(str[i] != '?') continue;
		for(int j=i/2; j; j--){
			dp[j] = dp[j] * 25u + dp[j-1];
		}
		dp[0] = dp[0] * 25u;
	}
	printf("%u",dp[n/2]);
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int main(){
	int n;
	char str[100005];
	unsigned dp[50005] = {};
	scanf("%d %s",&n, str + 1);
	if(n%2){
		puts("0");
		return 0;
	}
	dp[0] = 1;
	for(int i=1; i<=n; i++){
		if(str[i] != '?') continue;
		for(int j=i/2; j; j--){
			dp[j] = dp[j] * 25u + dp[j-1];
		}
		dp[0] = dp[0] * 25u;
	}
	printf("%u",dp[n/2]);
}


//start:
//finish:
#include<bits/stdc++.h>
#define MOD 4294967296
using namespace std;
typedef long long ll;
int n;
char s[100005];
ll f[100005];
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	if(n%2==1){
		puts("0");
		return 0;
	}
	int half=n/2;
	f[0]=1;
	int t=0;
	for(int i=0;i<n;i++){
		if(s[i]!='?'){
			t++;
		}
		else{
			for(int j=i+1>>1;j>=max(1,i-half+1);j--){
				f[j]+=f[j-1];
			}
		}
	}
	ll res=f[half]%MOD;
	for(int i=1;i<=half-t;i++){
		res=1ll*res*25%MOD;
	}
	printf("%I64d\n",res);
	return 0;
}


//start:
//finish:
#include<bits/stdc++.h>
#define MOD 4294967296
using namespace std;
typedef unsigned ll;
int n;
char s[100005];
ll f[100005];
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	if(n%2==1){
		puts("0");
		return 0;
	}
	int half=n/2;
	f[0]=1;
	int t=0;
	for(int i=0;i<n;i++){
		if(s[i]!='?'){
			t++;
		}
		else{
			for(int j=i+1>>1;j>=max(1,i-half+1);j--){
				f[j]+=f[j-1];
			}
		}
	}
	ll res=f[half]%MOD;
	for(int i=1;i<=half-t;i++){
		res=1ll*res*25%MOD;
	}
	cout<<res<<endl;
	return 0;
}


//start:
//finish:
#include<bits/stdc++.h>
#define MOD 4294967296
using namespace std;
typedef long long ll;
int n;
char s[100005];
ll f[100005];
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	if(n%2==1){
		puts("0");
		return 0;
	}
	int half=n/2;
	f[0]=1;
	int t=0;
	for(int i=0;i<n;i++){
		if(s[i]!='?'){
			t++;
		}
		else{
			for(int j=i+1>>1;j>=max(1,i-half+1);j--){
				f[j]+=f[j-1];
				f[j]%=MOD;
			}
		}
	}
	ll res=f[half];
	for(int i=1;i<=half-t;i++){
		res=1ll*res*25%MOD;
	}
	printf("%I64d\n",res);
	return 0;
}


//start:
//finish:
#include<bits/stdc++.h>
#define MOD 4294967296
using namespace std;
typedef long long ll;
int n;
char s[100005];
int f[100005];
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	if(n%2==1){
		puts("0");
		return 0;
	}
	int half=n/2;
	f[0]=1;
	int t=0;
	for(int i=0;i<n;i++){
		if(s[i]!='?'){
			t++;
		}
		else{
			for(int j=i+1>>1;j>=max(1,i-half+1);j--){
				f[j]+=f[j-1];
				f[j]%=MOD;
			}
		}
	}
	int res=f[half];
	for(int i=1;i<=half-t;i++){
		res=1ll*res*25%MOD;
	}
	printf("%d\n",res);
	return 0;
}


/*
 * Bad Move
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back

using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, K = 205, MOD = 1e9 + 7;
const ll MX = 1e15;
const int blkSz = 320;
unsigned int dp[2][N];
string S;
char str[N];
vector<int> cur, nxt;
int main() {
	int n;
	cin >> n;
	if (n & 1) {
		cout << 0 << '\n';
		return 0;
	}
	scanf("%s", str);
	dp[1][0] = 1;
	nxt.pb(0);
	for (int i = 0; i < n; i++) {
		if (str[i] == '?')
			for (int j = 0; j <= i + 1; j++)
				dp[i & 1][j] = 25 * dp[i & 1 ^ 1][j - 1] + dp[i & 1 ^ 1][j + 1];
		else
			for (int j = 1; j <= i + 1; j++)
				dp[i & 1][j] += dp[i & 1 ^ 1][j - 1];
	}

	cout << dp[n & 1][0] << '\n';

	return 0;
}


/*
 * Bad Move
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back

using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, K = 205, MOD = 1e9 + 7;
const ll MX = 1e15;
const int blkSz = 320;
unsigned int dp[2][N];
string S;
char str[N];
vector<int> cur, nxt;
int main() {
	int n;
	cin >> n;
	if (n & 1) {
		cout << 0 << '\n';
		return 0;
	}
	scanf("%s", str);
	dp[1][0] = 1;
	nxt.pb(0);
	for (int i = 0; i < n; i++) {
		if (str[i] == '?')
			for (int j = 0; j <= i + 1; j++)
				dp[i & 1][j] = 25 * dp[i & 1 ^ 1][j - 1] + dp[i & 1 ^ 1][j + 1];
		else
			for (int j = 1; j <= i + 1; j++)
				dp[i & 1][j] = dp[i & 1 ^ 1][j - 1];
	}

	cout << dp[n & 1^1][0] << '\n';

	return 0;
}


/*
 * Bad Move
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back

using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, K = 205, MOD = 1e9 + 7;
const ll MX = 1e15;
const int blkSz = 320;
unsigned int dp[2][N];
string S;
char str[N];
vector<int> cur, nxt;
int main() {
	int n;
	cin >> n;
	if (n & 1) {
		cout << 0 << '\n';
		return 0;
	}
	scanf("%s", str);
	dp[1][0] = 1;
	nxt.pb(0);
	for (int i = 0; i < n; i++) {
		if (str[i] == '?')
			for (int j = 0; j <= i + 1; j++)
				dp[i & 1][j] = 25 * dp[i & 1 ^ 1][j - 1] + dp[i & 1 ^ 1][j + 1];
		else {
			for (int j = 1; j <= i + 1; j++)
				dp[i & 1][j] = dp[i & 1 ^ 1][j - 1];
			dp[i & 1][0] = 0;
		}
	}

	cout << dp[n & 1 ^ 1][0] << '\n';

	return 0;
}


/*
 * Bad Move
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back

using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, K = 205, MOD = 1e9 + 7;
const ll MX = 1e15;
const int blkSz = 320;
unsigned int dp[2][N];
string S;
char str[N];
vector<int> cur, nxt;
int main() {
	int n;
	cin >> n;
	if (n & 1) {
		cout << 0 << '\n';
		return 0;
	}
	scanf("%s", str);
	dp[1][0] = 1;
	nxt.pb(0);
	for (int i = 0; i < n; i++) {
		if (str[i] == '?')
			for (int j = 0; j <= i + 1; j++)
				dp[i & 1][j] = 25 * dp[i & 1 ^ 1][j - 1] + dp[i & 1 ^ 1][j + 1];
		else
			for (int j = 1; j <= i + 1; j++)
				dp[i & 1][j] += dp[i & 1 ^ 1][j - 1];
	}

	cout << dp[n & 1^1][0] << '\n';

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;

int n;
unsigned int f[N];

char s[N];

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	cin >> s + 1;
	if (n & 1) {
		puts("0");
		return 0;
	}
	f[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (s[i] == '?') {
			for (int j = (i >> 1); j >= 1; --j) f[j] = f[j] * 25 + f[j - 1];
			f[0] = f[0] * 25;
		}

	}
	cout << f[n / 2];
}


#include<bits/stdc++.h>
#define N 200010
#define ui unsigned int
using namespace std;
int n,p;
ui r=1,f[N];
char c[N];
signed main(){
	cin>>n;
	if(n&1)puts("0");
	else{
		f[0]=1;
		cin>>c+1;
		for(int i=1;i<=n;i++){
			if(c[i]=='?')
				for(int j=i/2;j>=i-n/2&&j;j--)
					f[j]+=f[j-1];
			else p++;
		}
		for(int i=1;i+p<=n/2;i++)
			r*=25;
		cout<<(ui)r*f[n/2]<<'\n';
	}
}


#include<bits/stdc++.h>
#define N 200010
#define int unsigned int
using namespace std;
int f[N],n,r=1;
char c[N];
signed main(){
	cin>>n;
	if(n&1)puts("0");
	else{
		f[0]=1;
		cin>>c+1;
		int p=0;
		for(int i=1;i<=n;i++){
			if(c[i]=='?')
				for(int j=i/2;j>=i-n/2&&j;j--)
					f[j]+=f[j-1];
			else p++;
		}
		for(int i=1;i<=n/2-p;i++)
			r*=25;
		cout<<r*f[n/2]<<'\n';
	}
}


#include<bits/stdc++.h>
#define N 200010
#define int unsigned int
using namespace std;
int f[N],n,r=1;
char c[N];
signed main(){
	cin>>n;
	if(n&1)puts("0");
	else{
		f[0]=1;
		cin>>c+1;
		int p=0;
		for(int i=1;i<=n;i++){
			if(c[i]=='?')
				for(int j=i/2;j>=i-n/2&&j;j--)
					f[j]+=f[j-1];
			else p++;
		}
		for(int i=1;i+p<=n/2;i++)
			r*=25;
		cout<<r*f[n/2]<<'\n';
	}
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#define LL long long
#define mp(x,y) make_pair(x,y)
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline void write(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
inline void pr1(int x){write(x);printf(" ");}
inline void pr2(int x){write(x);puts("");}
int n;
char ch[100005];
unsigned int f[2][50005];
int main()
{
	n=read();if(n&1)return puts("0"),0;
	scanf("%s",ch+1);
	int now=0;f[now][0]=1;int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(ch[i]=='?')
		{
			now^=1;
			for(int j=0;2*j<=i;j++)f[now][j]=f[now^1][j]+f[now^1][j-1];
		}
		else sum++;
	}
	unsigned int ans=f[now][n/2];
	for(int i=1;i<=(n-2*sum)/2;i++)ans*=25;
	printf("%u\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef unsigned int ll;
const int N=1e5+9;
ll f[N],n;
char s[N];
int main()
{
	scanf("%u",&n);
	scanf("%s",s+1);
	if(n&1){return puts("0"),0;}
	f[0]=1;//f[i]表示选了i个右括号
	for(int i=1;i<=n;i++)
		if(s[i]=='?')
		{
			for(int j=i/2;j>=1;j--)
				f[j]=25*f[j]+f[j-1];
			f[0]=25*f[0];
		}
	printf("%u\n",f[n/2]);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef unsigned int ll;
const int N=1e5+9;
ll f[N],n;
char s[N];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	if(n&1){return puts("0"),0;}
	f[0]=1;//f[i]表示选了i个右括号
	for(int i=1;i<=n;i++)
		if(s[i]=='?')
		{
			for(int j=i/2;j>=1;j--)
				f[j]=25*f[j]+f[j-1];
			f[0]=25*f[0];
		}
	printf("%d\n",f[n/2]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 1;
int n, m, f[maxn];
char buf[maxn];
int main() {
	scanf("%d%s", &n, buf);
	if(n & 1) {
		puts("0");
		return 0;
	}
	f[0] = 1;
	for(int i = 1; i <= n; ++i) {
		int upp = i >> 1;
		if(buf[i - 1] != '?') {
			++m;
		} else {
			int low = max(i - (n >> 1), 0);
			upp = min(upp, i - m);
			for( ; low <= upp; --upp)
				f[upp] += f[upp - 1];
		}
	}
	int ans = f[n >> 1];
	for(int i = m + m; i < n; i += 2)
		ans *= 25;
	printf("%u\n", ans);
	return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s, test = "heidi";
    cin >> s;
    char pure[5];
    int n = s.length(), x = 0, j;
    for (int i = 0; i < n; i++) {
        if (s[i + 1] == s[i])
            s[i + 1] = '%';
        else if (!(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd'))
            s[i] = '%';
    }
    for (int i = 0; i < n; i++) {
        if (s[i] == '%')
            x++;
        else {
            j = i - x;
            pure[j] = s[i];
        }
    }
    for (int i = 0; i < 5; i++) {
        if (pure[i] != test[i]) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s, test = "heidi";
    cin >> s;
    char pure[5];
    int n = s.length(), x = 0, j;
    for (int i = 0; i < n; i++) {
        if ((s[i + 1] == s[i]) || !(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd'))
            x++;
        else {
            j = i - x;
            pure[j] = s[i];
        }
    }
    for (int i = 0; i < 5; i++) {
        if (pure[i] == 'h') {
            if (pure[i + 1] != 'e') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'e') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'd') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    bool stH = true, stE = true, stI = true, stD = true, ndI = true;
    int positions[5];
    for (int i = 0; i < 5; i++)
        positions[i] = 0;
    for (int i = 0, n = s.length(); i < n; i++) {
        if (s[i] == 'h' && stH == true) {
            positions[0] = i;
            stH = false;
        }
        else if (s[i] == 'e' && stE == true) {
            positions[1] = i;
            stE = false;
        }
        else if (s[i] == 'i' && stI == true && ndI == true) {
            positions[2] = i;
            stI = false;
        }
        else if (s[i] == 'd' && stD == true) {
            positions[3] = i;
            stD = false;
        }
        else if (s[i] == 'i' && stI == false && stD == false && ndI == true) {
            positions[4] = i;
            ndI = false;
        }
    }
    if (ndI != false) {
        cout << "NO";
        return 0;
    }
    else {
        for (int i = 0; i < 5; i++) {
            if (positions[i] > positions[i + 1]) {
                cout << "NO";
                return 0;
            }
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    bool stH = true, stE = true, stI = true, stD = true, ndI = true;
    int positions[5];
    for (int i = 0; i < 5; i++)
        positions[i] = 0;
    for (int i = 0, n = s.length(); i < n; i++) {
        if (s[i] == 'h' && stH == true) {
            positions[0] = i;
            stH = false;
        }
        else if (s[i] == 'e' && stE == true) {
            positions[1] = i;
            stE = false;
        }
        else if (s[i] == 'i' && stI == true && ndI == true) {
            positions[2] = i;
            stI = false;
            ndI = false;
        }
        else if (s[i] == 'd' && stD == true) {
            positions[3] = i;
            stD = false;
        }
        else if (s[i] == 'i' && stI == false && ndI == false)
            positions[4] = i;
    }
    for (int i = 1; i < 5; i++) {
        if (positions[i - 1] > positions[i]) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    char pure[5];
    int n = s.length(), x = 0, j;
    for (int i = 0; i < n; i++) {
        if ((s[i + 1] == s[i]) || !(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd'))
            x++;
        else {
            j = i - x;
            pure[j] = s[i];
        }
    }
    for (int i = 0; i < 4; i++) {
        if (pure[i] == 'h') {
            if (pure[i + 1] != 'e') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'e') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'i') {
            if (pure[i + 1] == 'i') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'd') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }

    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    char pure[5];
    int n = s.length(), x = 0, j;
    for (int i = 0; i < n; i++) {
        if ((s[i + 1] == s[i]) || !(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd'))
            x++;
        else {
            j = i - x;
            pure[j] = s[i];
        }
    }
    for (int i = 0; i < 4; i++) {
        if (pure[i] == 'h') {
            if (pure[i + 1] != 'e') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'e') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'd') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }

    }
    cout << "YES";
    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    bool stH = true, stE = true, stI = true, stD = true, ndI = true;
    int positions[5];
    for (int i = 0; i < 5; i++)
        positions[i] = 1000;
    for (int i = 0, n = s.length(); i < n; i++) {
        if (s[i] == 'h' && stH == true) {
            positions[0] = i;
            stH = false;
        }
        else if (s[i] == 'e' && stE == true) {
            positions[1] = i;
            stE = false;
        }
        else if (s[i] == 'i' && stI == true && ndI == true) {
            positions[2] = i;
            stI = false;
            ndI = false;
        }
        else if (s[i] == 'd' && stD == true) {
            positions[3] = i;
            stD = false;
        }
        else if (s[i] == 'i' && stI == false && ndI == false)
            positions[4] = i;
    }
    for (int i = 0; i < 4; i++) {
        if (positions[i] != 1000) {
            if (positions[i] > positions[i + 1]) {
                cout << "NO";
                return 0;
            }
        }
    }

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    char pure[5];
    int n = s.length(), x = 0, j;
    int firstI = 0;
    for (int i = 0; i < n; i++) {
        if ((s[i + 1] == s[i]) || !(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd'))
            x++;
        else {
            j = i - x;
            pure[j] = s[i];
        }
    }
    for (int i = 0; i < 5; i++) {
        if (pure[i] == 'h') {
            if (pure[i + 1] != 'e') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'e') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'i' && firstI == 0) {
            firstI = i;
            if (pure[i + 1] != 'd') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'd') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }

    }
    cout << "YES";
    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    bool stH = true, stE = true, stI = true, stD = true, ndI = true;
    int positions[5], j = 0;
    for (int i = 0; i < 5; i++)
        positions[i] = 0;
    for (int i = 0, n = s.length(); i < n; i++) {
        if (s[i] == 'h' && stH == true) {
            positions[0] = i;
            stH = false;
            j++;
        }
        else if (s[i] == 'e' && stE == true) {
            positions[1] = i;
            stE = false;
            j++;
        }
        else if (s[i] == 'i' && stI == true && ndI == true) {
            positions[2] = i;
            stI = false;
            j++;
        }
        else if (s[i] == 'd' && stD == true) {
            positions[3] = i;
            stD = false;
            j++;
        }
        else if (s[i] == 'i' && stI == false && stD == false && ndI == true) {
            positions[4] = i;
            ndI = false;
            j++;
        }
    }
    for (int i = 0; i < j; i++) {
        if (positions[i] > positions[i + 1]) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    char c = 'h';
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (c == 'h' && s[i] != c) {
            if (s[i] == 'e')
                c = s[i];
            else if (s[i] == 'i' || s[i] == 'd') {
                cout << "NO";
                return 0;
            }
        }
        else if (c == 'e' && s[i] != c) {
            if (s[i] == 'i')
                c = s[i];
            else if (s[i] == 'd') {
                cout << "NO";
                return 0;
            }
        }
        else if (c == 'i' && s[i] != c) {
            if (s[i] == 'd')
                c = s[i];
            else if (s[i] == 'i') {
                cout << "NO";
                return 0;
            }
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    bool stH = true, stE = true, stI = true, stD = true, ndI = true;
    int positions[5];
    for (int i = 0; i < 5; i++)
        positions[i] = 0;
    for (int i = 0, n = s.length(); i < n; i++) {
        if (s[i] == 'h' && stH == true) {
            positions[0] = i;
            stH = false;
        }
        else if (s[i] == 'e' && stE == true) {
            positions[1] = i;
            stE = false;
        }
        else if (s[i] == 'i' && stI == true && stD == true && ndI == true) {
            positions[2] = i;
            stI = false;
        }
        else if (s[i] == 'd' && stD == true) {
            positions[3] = i;
            stD = false;
        }
        else if (s[i] == 'i' && stD == false && ndI == true) {
            positions[4] = i;
            ndI = false;
        }
    }
    for (int i = 0; i < 5; i++) {
        if (positions[i] > positions[i + 1]) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    char pure[5];
    int n = s.length(), x = 0, j;
    for (int i = 0; i < n; i++) {
        if ((s[i + 1] == s[i]) || !(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd'))
            x++;
        else {
            j = i - x;
            pure[j] = s[i];
        }
    }
    for (int i = 0; i < 4; i++) {
        if (pure[i] == 'h') {
            if (pure[i + 1] != 'e') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'e') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'd') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }

    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s, test = "heidi";
    cin >> s;
    char pure[5];
    int n = s.length(), x = 0, j;
    for (int i = 0; i < n; i++) {
        if ((s[i + 1] == s[i]) || !(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd'))
            x++;
        else {
            j = i - x;
            pure[j] = s[i];
        }
    }
    for (int i = 0; i < 5; i++) {
        if (pure[i] == 'e') {
            if (pure[i - 1] != 'h') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'i') {
            if (pure[i - 1] != 'e' && pure[i - 1] != 'd') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'd') {
            if (pure[i - 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    char pure[5];
    int n = s.length(), x = 0, j;
    for (int i = 0; i < n; i++) {
        if ((s[i + 1] == s[i]) || !(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd'))
            x++;
        else {
            j = i - x;
            pure[j] = s[i];
        }
    }
    for (int i = 0; i < j; i++) {
        if (pure[i] == 'h') {
            if (pure[i + 1] != 'e') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'e') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'i') {
            if (pure[i + 1] != 'd') {
                cout << "NO";
                return 0;
            }
        }
        else if (pure[i] == 'd') {
            if (pure[i + 1] != 'i') {
                cout << "NO";
                return 0;
            }
        }

    }
    cout << "YES";
    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    bool stH = true, stE = true, stI = true, stD = true, ndI = true;
    int positions[5];
    for (int i = 0; i < 5; i++)
        positions[i] = 1000;
    for (int i = 0, n = s.length(); i < n; i++) {
        if (s[i] == 'h' && stH == true) {
            positions[0] = i;
            stH = false;
        }
        else if (s[i] == 'e' && stE == true) {
            positions[1] = i;
            stE = false;
        }
        else if (s[i] == 'i' && stI == true && ndI == true) {
            positions[2] = i;
            stI = false;
            ndI = false;
        }
        else if (s[i] == 'd' && stD == true) {
            positions[3] = i;
            stD = false;
        }
        else if (s[i] == 'i' && stI == false && ndI == false)
            positions[4] = i;
    }
    for (int i = 0; i < 4; i++) {
        if (positions[i] != 1000) {
            if (positions[i] > positions[i + 1]) {
                cout << "NO";
                return 0;
            }
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    bool stH = true, stE = true, stI = true, stD = true, ndI = true;
    int indices[5];
    for (int i = 0; i < 5; i++)
        indices[i] = 0;
    for (int i = 0, n = s.length(); i < n; i++) {
        if (s[i] == 'h' && stH == true) {
            indices[0] = i;
            stH = false;
        }
        else if (s[i] == 'e' && stE == true) {
            indices[1] = i;
            stE = false;
        }
        else if (s[i] == 'i' && stI == true && stD == true && ndI == true) {
            indices[2] = i;
            stI = false;
        }
        else if (s[i] == 'd' && stD == true) {
            indices[3] = i;
            stD = false;
        }
        else if (s[i] == 'i' && stD == false && ndI == true) {
            indices[4] = i;
            ndI = false;
        }
    }
    for (int i = 0; i < 5; i++) {
        if (indices[i] > indices[i + 1]) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}


#include <iostream>

using namespace std;

int main() {

    string s;
    cin >> s;
    char c;
    for (int i = 0, n = s.length(); i < n; i++) {
        if (s[i] == 'h')
            c = s[i];
        else if (s[i] == 'e') {
            if (c != 'h') {
                cout << "NO";
                return 0;
            }
            c = s[i];
        }
        else if (s[i] == 'i') {
            if (c != 'e' && c != 'd') {
                cout << "NO";
                return 0;
            }
            c = s[i];
        }
        else if (s[i] == 'd') {
            if (c != 'i') {
                cout << "NO";
                return 0;
            }
            c = s[i];
        }

    }
    cout << "YES";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof a)
#define R(i,s,t) for(register int i=s;i<=t;++i)
#define Rd(i,s,t) for(register int i=s;i>=t;--i)
#define RR(i,a) for(register int i=0;i<int(a.size());++i)
#define __ puts("")
#define _ putchar(' ')
#define all(T) T.begin(),T.end()
#define rall(T) T.rbegin(),T.rend()
#define sz(a) int(a.size())
#define mma max_element
#define mmi min_element
#define acu accumulate
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef double DB;
template <class T> T abs(T a){return a>=0?a:-a;}
template <class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template <class T> T mod(T a,T b){T ret=a%b;if(ret<0)ret+=b;return ret;}
ll mulmod(ll a,ll b,ll c){if(b==0LL)return 0LL;ll ret=mulmod(a,b>>1,c);ret=(ret+ret)%c;if(b&1LL)ret=(ret+a)%c;return ret;}
ll powmod(ll a,ll b,ll c){if(b==0LL)return 1LL;ll ret=powmod(a,b>>1,c);ret=ret*ret%c;if(b&1LL)ret=ret*a%c;return ret;}
template <class T> inline void wt(T x){if (x<0)putchar('-'),x=-x;if (x<10)putchar(x + '0');else wt(x / 10), putchar(x % 10 + '0');}
template <class T> inline void rd(T&x){bool f=0; char ch;for(ch=getchar();ch<=32;ch=getchar());if (ch=='-')f=1,ch=getchar();for(x=0;ch>32;ch=getchar()) x =(x<<3)+(x<<1)+ch-'0';if(f) x=-x;}
/* .................................................................................................................................. */
const int N=100005;
int tt;
int u,v,w,n,m;
/* .................................................................................................................................. */

int main(){
	string s="heidi",a;
	cin>>a;
	auto it=s.begin();
	for(auto c:a){
		if(c==*it)it++;
	}
	puts(it==s.end()?"YES":"NO");

	return 0;
}
/*

*/


#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof a)
#define R(i,s,t) for(register int i=s;i<=t;++i)
#define Rd(i,s,t) for(register int i=s;i>=t;--i)
#define RR(i,a) for(register int i=0;i<int(a.size());++i)
#define __ puts("")
#define _ putchar(' ')
#define all(T) T.begin(),T.end()
#define rall(T) T.rbegin(),T.rend()
#define sz(a) int(a.size())
#define mma max_element
#define mmi min_element
#define acu accumulate
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef double DB;
template <class T> T abs(T a){return a>=0?a:-a;}
template <class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template <class T> T mod(T a,T b){T ret=a%b;if(ret<0)ret+=b;return ret;}
ll mulmod(ll a,ll b,ll c){if(b==0LL)return 0LL;ll ret=mulmod(a,b>>1,c);ret=(ret+ret)%c;if(b&1LL)ret=(ret+a)%c;return ret;}
ll powmod(ll a,ll b,ll c){if(b==0LL)return 1LL;ll ret=powmod(a,b>>1,c);ret=ret*ret%c;if(b&1LL)ret=ret*a%c;return ret;}
template <class T> inline void wt(T x){if (x<0)putchar('-'),x=-x;if (x<10)putchar(x + '0');else wt(x / 10), putchar(x % 10 + '0');}
template <class T> inline void rd(T&x){bool f=0; char ch;for(ch=getchar();ch<=32;ch=getchar());if (ch=='-')f=1,ch=getchar();for(x=0;ch>32;ch=getchar()) x =(x<<3)+(x<<1)+ch-'0';if(f) x=-x;}
/* .................................................................................................................................. */
const int N=100005;
int tt;
int u,v,w,n,m;
/* .................................................................................................................................. */

int main(){
	string s,a;
	cin>>a;
	for(auto c:a){
		if(c=='h'||c=='e'||c=='i'||c=='d')s+=c;
	}
	puts(s.find("heidi")!=-1?"YES":"NO");

	return 0;
}
/*

*/


#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof a)
#define R(i,s,t) for(register int i=s;i<=t;++i)
#define Rd(i,s,t) for(register int i=s;i>=t;--i)
#define RR(i,a) for(register int i=0;i<int(a.size());++i)
#define __ puts("")
#define _ putchar(' ')
#define all(T) T.begin(),T.end()
#define rall(T) T.rbegin(),T.rend()
#define sz(a) int(a.size())
#define mma max_element
#define mmi min_element
#define acu accumulate
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef double DB;
template <class T> T abs(T a){return a>=0?a:-a;}
template <class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template <class T> T mod(T a,T b){T ret=a%b;if(ret<0)ret+=b;return ret;}
ll mulmod(ll a,ll b,ll c){if(b==0LL)return 0LL;ll ret=mulmod(a,b>>1,c);ret=(ret+ret)%c;if(b&1LL)ret=(ret+a)%c;return ret;}
ll powmod(ll a,ll b,ll c){if(b==0LL)return 1LL;ll ret=powmod(a,b>>1,c);ret=ret*ret%c;if(b&1LL)ret=ret*a%c;return ret;}
template <class T> inline void wt(T x){if (x<0)putchar('-'),x=-x;if (x<10)putchar(x + '0');else wt(x / 10), putchar(x % 10 + '0');}
template <class T> inline void rd(T&x){bool f=0; char ch;for(ch=getchar();ch<=32;ch=getchar());if (ch=='-')f=1,ch=getchar();for(x=0;ch>32;ch=getchar()) x =(x<<3)+(x<<1)+ch-'0';if(f) x=-x;}
/* .................................................................................................................................. */
const int N=100005;
int tt;
int u,v,w,n,m;
/* .................................................................................................................................. */

int main(){
	string s,a;
	cin>>a;
	for(auto c:a){
		if(c=='h'||c=='e'||c=='i'||c=='d')s+=c;
	}
	s.resize(distance(s.begin(),unique(all(s))));
	puts(s.find("heidi")!=-1?"YES":"NO");

	return 0;
}
/*

*/


// In the name of Allah //
#include<bits/stdc++.h>
using namespace std;

int main()
{
	string s,c = "heidi";
	cin >> s;
	int ind = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == c[ind])
			ind ++;
	}
	if (ind >= 4)
		return cout << "YES" , 0;
	cout << "NO";

}


// In the name of Allah //
#include<bits/stdc++.h>
using namespace std;

int main()
{
	string s,c = "heidi";
	cin >> s;
	int ind = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == c[ind] && ind <= 4)
			ind ++;
	}
	if (ind == 5)
		return cout << "YES" , 0;
	cout << "NO";

}


#include<iostream>
using namespace std;

int main(){
	string s,x="heidi";
	cin>>s;
	int k=0;
	for(int i=0;i<s.length();i++){
		if(s[i]==x[k])k++;
		if(k==5){
			cout<<"YES";
		}
	}
	if(k<5)cout<<"NO";
}


#include<iostream>
using namespace std;

int main(){
	string s,x="heidi";
	cin>>s;
	int k=0;
	for(int i=0;i<s.length();i++){
		if(s[i]==x[k])k++;
		if(k==5){
			cout<<"YES";
			return 0;
		}
	}
	if(k<5)cout<<"NO";
}


//heidi
#include <iostream>
#include <string>

int main(){
    string str;
    std::cin >> str;
    if (str.find("heidi")){
        std::cout << "YES";
        return 0;
    }
    std::cout << "NO";
    return 0;
}


//heidi
#include <iostream>
#include <string>

int main(){
    std::string str;
    std::cin >> str;
    if (str.find("heidi") < str.size()){
        std::cout << "YES";
        return 0;
    }
    std::cout << "NO";
    return 0;
}


//heidi
#include <iostream>

int main(){
    char ch;
    char tmp[]={'h','e','i','d','i'};
    int i = 0;
    while (std::cin >> ch){
        if (ch == tmp[i])
            ++i;
        if (i == 5){
            std::cout << "YES";
            return 0;
        }
    }

    std::cout << "NO";
    return 0;
}


//heidi
#include <iostream>
#include <string>

int main(){
    std::string str;
    std::cin >> str;
    if (str.find("heidi") < str.size()){
        std::cout << "NO";
        return 0;
    }
    std::cout << "YES";
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
main(){
string s="heidi";
string a;
cin>>a;
int x=0;
cnt;
for(int i=0;i<a.size();i++){
 if(a[i]==s[x]) x++;

  if(x==5) {cout<<"YES"<<endl; return 0;}
}
cout<<"NO"<<endl;

}


#include <iostream>
#include <string>
using namespace std;
main(){
string s="heidi";
string a;
cin>>a;
int x=0;

for(int i=0;i<a.size();i++){
 if(a[i]==s[x]) x++;

  if(x==4) {cout<<"YES"<<endl; return 0;}
}
cout<<"NO"<<endl;

}


#include <iostream>
#include <string>
using namespace std;
main(){
string s="heidi";
string a;
cin>>a;
int x=0;

for(int i=0;i<a.size();i++){
 if(a[i]==s[x]) x++;

  if(x==5) {cout<<"YES"<<endl; return 0;}
}
cout<<"NO"<<endl;

}


#include<bits/stdc++.h>//万能头赛高！
using namespace std;
char zf[5]={'h','e','i','d','i'}//预处理需要的字符串;

int main(){
    int i,ans=0;
    char a;

    while (cin>>a){//读入
        if (a==zf[ans]) ans++;//判断是否符合条件
    }
    if (ans>=5) printf("YES");
    else printf("NO");

    return 0;
}


#include<bits/stdc++.h>//万能头赛高！
using namespace std;
char zf[5]={'h','e','i','d','i'};//预处理需要的字符串;

int main(){
    int i,ans=0;
    char a;

    while (cin>>a){//读入
        if (a==zf[ans]) ans++;//判断是否符合条件
    }
    if (ans>=5) printf("YES");
    else printf("NO");

    return 0;
}


/*
    Deepanshu Saxena
    Practice Submission
*/
#include "bits/stdc++.h"
using ll=long long;
using namespace std;
int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n;
	// cin>>n;
	string s;
	s="heidi";
	string input;
	cin>>input;
	ll k=0,z=0;
	for (int i = 0; i < s.size(); ++i)
	 {
	 	if(s[k]==input[i])
	 	{
	 		k++;
	 		z++;
	 	}
	 	/* code */
	 	if(k==5)
	 		return cout<<"YES",0;
	 }
	 /*if(z==5)
	 	cout<<"YES";
	 else*/
	 	cout<<"NO";
	return 0;
}


#include "bits/stdc++.h"
using ll=long long;
using namespace std;
int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n;
	// cin>>n;
	string s;
	s="heidi";
	string input;
	cin>>input;
	ll k=0,z=0;
	for (int i = 0; i < input.size(); ++i)
	 {
	 	if(s[k]==input[i])
	 	{
	 		k++;
	 		z++;
	 	}
	 	/* code */
	 	if(k==5)
	 		return cout<<"YES",0;
	 }
	 /*if(z==5)
	 	cout<<"YES";
	 else*/
	 	cout<<"NO";
	return 0;
}


/*
    As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants.
    She knows that a newspiece is fake if it contains heidi as a subsequence.
    Help Heidi assess whether the given piece is true, but please be discreet about it...
*/

/*
    Deepanshu Saxena
    Practice Submission
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int b=0;
    // cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='h')b=1;
        if(s[i]=='e' and b==1)b=2;
        if(s[i]=='i' and b==2)b=3;
        if(s[i]=='d' and b==3)b=4;
        if(s[i]=='i' and b==4)b=5;
        if(b==5)
        return cout<<"YES",0;
    }
    cout<<"NO";
}


/*
    As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants.
    She knows that a newspiece is fake if it contains heidi as a subsequence.
    Help Heidi assess whether the given piece is true, but please be discreet about it...
*/

/*
    Deepanshu Saxena
    Practice Submission
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int b=0;
    // cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='h' and b==0)b=1;
        if(s[i]=='e' and b==1)b=2;
        if(s[i]=='i' and b==2)b=3;
        if(s[i]=='d' and b==3)b=4;
        if(s[i]=='i' and b==4)b=5;
        if(b==5)
        return cout<<"YES",0;
    }
    cout<<"NO";
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin>>s;
    int h,he,hei,heid,heidi;
    h=he=hei=heid=heidi=0;
    bool flag=false;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='h')
            h++;

        if(s[i]=='e'&&h>=1)
        {
            he++;
            h--;
        }
        if(s[i]=='i'&&he>=1)
        {
            hei++;
            he--;
        }
        if(s[i]=='d'&&hei>=1)
        {
            heid++;
            hei--;
        }
        if(s[i]=='i'&&heid>=1)
        {
            heidi++;
            heid--;
            flag=true;
            break;
        }
    }
    if(flag)
        cout<<"yes\n";
    else
        cout<<"no\n";
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin>>s;
    int h,he,hei,heid,heidi;
    h=he=hei=heid=heidi=0;
    bool flag=false;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='h')
            h++;

        if(s[i]=='e'&&h>=1)
        {
            he++;
            h--;
        }
        if(s[i]=='i'&&he>=1)
        {
            hei++;
            he--;
        }
        if(s[i]=='d'&&hei>=1)
        {
            heid++;
            hei--;
        }
        if(s[i]=='i'&&heid>=1)
        {
            heidi++;
            heid--;
            flag=true;
            break;
        }
    }
    if(flag&&heidi==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin>>s;
    int h,he,hei,heid,heidi;
    h=he=hei=heid=heidi=0;
    bool flag=false;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='h')
            h++;

        if(s[i]=='e'&&h>=1)
        {
            he++;
            h--;
        }
        if(s[i]=='i'&&he>=1)
        {
            hei++;
            he--;
        }
        if(s[i]=='d'&&hei>=1)
        {
            heid++;
            hei--;
        }
        if(s[i]=='i'&&heid>=1)
        {
            heidi++;
            heid--;
            flag=true;
            break;
        }
    }
    if(flag&&heidi==1)
        cout<<"yes\n";
    else
        cout<<"no\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len = s.length();
	string toFind = "heidi";
	int count = 0;
	for(int i=0; i<len;i++)
	{
		if(s[i]==toFind[count])
			count++;
		if(count==5)
			break;
	}
	if(count==5)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len = s.length();
	string toFind = "heidi";
	if(len<5)
		cout<<"NO\n";
	else
	{
		int j = 0;
		int count = 1;
		for(int i=0; i<5 && j<len;i++)
		{
			for(;j<len && count<5;j++)
			{
				if(toFind[i]==s[j])
				{
					count++;
					break;
				}
			}
		}
		if(count!=5)
			cout<<"NO";
		else
			cout<<"YES";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int i,j,k,l,m;
	string s;
	cin>>s;
	int flag=s.find('i',s.find('d',s.find('i',s.find('e',s.find('h')))));
	if(flag==-1)
	cout<<"NO";
	else
	cout<<"YES";
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int flag=0,i,j,k,l,m;
	string s,s1="heidi";
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]==s1[0])
		{
			for(j=i+1;j<s.size();j++)
			{
				if(s[j]==s1[1])
				{
					for(k=j+1;k<s.size();k++)
					{
						if(s[k]==s1[2])
						{
							for(l=k+1;l<s.size();l++)
							{
								if(s[l]==s1[3])
								{
									for(m=l+1;m<s.size();m++)
									{
										if(s[m]==s1[4])
										{
											flag=1;
											break;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	if(flag==0)
	cout<<"NO";
	else
	cout<<"YES";
}


#include<bits\stdc++.h>

using namespace std;

int main(){
	int index;
	string t="heidi",s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]==t[index])index++;
		if(index==5)break;
	}
	if(index==5)cout<<"YES";
	else cout<<"NO";
}


#include<bits\stdc++.h>

using namespace std;

int main(){
	int index;
	string t="heidi ",s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]==t[index])index++;
	}
	if(index>4)cout<<"YES";
	else cout<<"NO";
}


#include<bits\stdc++.h>

using namespace std;

int main(){
	int index=0;
	string t="heidi",s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]==t[index])index++;
		if(index==5)break;
	}
	if(index==5)cout<<"YES";
	else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    getline(cin,s);
    puts(s.find('i',s.find('d',s.find('i',s.find('e',s.find('h')))))==string::npos?"NO":"YES");
    return 0;
}


#include<bits/stdc++.h>
#define reg register
using namespace std;
string s;
int main()
{
    getline(cin,s);
    puts(s.find('i',s.find('d',s.find('i',s.find('e',s.find('h')))))==string::npos?"NO":"YES");
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define reps(i,n) for(ll i=1;i<ll(n);i++)
#define rrep(i,n) for(ll i=ll(n);i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)//使いにくかったら消す
#define len(x) x.length()//配列の長さ
#define ALL(x) x.begin(),x.end()
#define NPOS string::npos//findで検索失敗した場合の戻り値(findは文字列内に特定の文字列があるかを判定)
typedef long long ll;
using namespace std;
bool comp_len(const std::string &lh,const std::string &rh){return lh.length() < rh.length();}//文字列を長さでソートする時の比較関数
ll ans=0;//解答用の変数
ll gcd(ll a, ll b) {if (b==0) return a;else return gcd(b, a%b);}//最大公約数
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}//最小公倍数
ll digit_sum(ll a,ll b){ll ans=0;while(a>0){ans+=a%b;a/=b;}return ans;}//n進桁和
ll digit_num(ll a,ll b){ll ans=0;while(a>0){ans++;a/=b;}return ans;}//n進桁数
ll fact(ll n){if(n==1)return 1;else return n*fact(n-1);}//階乗
ll array_sum(ll *a,ll n){ll ans=0;rep(i,n){ans+=a[i];}return ans;}//配列総和
ll combi(ll n, ll k){if(n==k||k==0){return 1;}else{return combi(n-1,k-1)+combi(n-1,k);}}//nCkの組み合わせ
bool is_prime(ll x){for(ll i=2;i*i<=x;i++){if(x%i==0)return false;}return true;}//素数判定
// for(long long i=1;i*i<= n;i++){if(n%i==0){ans.push_back(i);if(i*i!=n)ans.push_back(n/i);}}//約数列挙（vector型の変数の用意が必要）

/*Union-Find(素集合データ構造)*/
vector<ll> par(100010);//親の値を保持
ll root(ll x){if(par[x]==x){return x;}else{return par[x]=root(par[x]);}}//根の値を返す
bool same(ll x,ll y){return (root(x)==root(y));}//根が一致しているか判定
void unite(ll x,ll y){x=root(x);y=root(y);if(x==y)return;par[x]=y;}//グループを併合

int main()
{
  string s;
  cin>>s;
  char hd[5]={'h','e','i','d','i'};
  ll now=0;
  rep(i,len(s)){
    if(s[i]==hd[now]){
      now++;
      if(now==5){
        puts("YES");
        return 0;
      }
    }
  }
  puts("NO");
  return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define reps(i,n) for(ll i=1;i<ll(n);i++)
#define rrep(i,n) for(ll i=ll(n);i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)//使いにくかったら消す
#define len(x) x.length()//配列の長さ
#define ALL(x) x.begin(),x.end()
#define NPOS string::npos//findで検索失敗した場合の戻り値(findは文字列内に特定の文字列があるかを判定)
typedef long long ll;
using namespace std;
bool comp_len(const std::string &lh,const std::string &rh){return lh.length() < rh.length();}//文字列を長さでソートする時の比較関数
ll ans=0;//解答用の変数
ll gcd(ll a, ll b) {if (b==0) return a;else return gcd(b, a%b);}//最大公約数
ll lcm(ll a, ll b) {return a * b / gcd(a, b);}//最小公倍数
ll digit_sum(ll a,ll b){ll ans=0;while(a>0){ans+=a%b;a/=b;}return ans;}//n進桁和
ll digit_num(ll a,ll b){ll ans=0;while(a>0){ans++;a/=b;}return ans;}//n進桁数
ll fact(ll n){if(n==1)return 1;else return n*fact(n-1);}//階乗
ll array_sum(ll *a,ll n){ll ans=0;rep(i,n){ans+=a[i];}return ans;}//配列総和
ll combi(ll n, ll k){if(n==k||k==0){return 1;}else{return combi(n-1,k-1)+combi(n-1,k);}}//nCkの組み合わせ
bool is_prime(ll x){for(ll i=2;i*i<=x;i++){if(x%i==0)return false;}return true;}//素数判定
// for(long long i=1;i*i<= n;i++){if(n%i==0){ans.push_back(i);if(i*i!=n)ans.push_back(n/i);}}//約数列挙（vector型の変数の用意が必要）

/*Union-Find(素集合データ構造)*/
vector<ll> par(100010);//親の値を保持
ll root(ll x){if(par[x]==x){return x;}else{return par[x]=root(par[x]);}}//根の値を返す
bool same(ll x,ll y){return (root(x)==root(y));}//根が一致しているか判定
void unite(ll x,ll y){x=root(x);y=root(y);if(x==y)return;par[x]=y;}//グループを併合

int main()
{
  string s;
  cin>>s;
  if(s.find("hiedi")==NPOS)puts("YES");
  else puts("NO");
  return 0;
}


#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    string str;
    cin>>str;
    if(s.find('i',s.find('d',s.find('i',s.find('e',s.find('h'))))) == string::npos)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}


#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    string str;
    cin>str;
    if(s.find('i',s.find('d',s.find('i',s.find('e',s.find('h'))))) == string::npos)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}


#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    string str;
    cin>>str;
    if(str.find('i',str.find('d',str.find('i',str.find('e',str.find('h'))))) == string::npos)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
string s;
int n,data[10];
bool flag[10];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s;
	n=s.length();
	memset(flag,0,sizeof(flag));
	for(int i=0;i<n;i++)
	{
		if(flag[1]==0 && s[i]=='h')
		{
			flag[1]=1;
			data[1]=i;
		}
		else if(flag[2]==0 && s[i]=='e')
		{
			flag[2]=1;
			data[2]=i;
		}
		else if(flag[3]==0 && s[i]=='i')
		{
			flag[3]=1;
			data[3]=i;
		}
		else if(flag[4]==0 && s[i]=='d')
		{
			flag[4]=1;
			data[4]=i;
		}
		else if(flag[5]==0 && flag[1]==1 && s[i]=='i')
		{
			flag[5]=1;
			data[5]=i;
		}
	}
	if(data[1]<data[2] && data[2]<data[3] && data[3]<data[4] && data[4]<data[5]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
string s,temp="heidi";
int n,cnt;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s;
	n=s.length();
	for(int i=0;i<n;i++)
	{
		if(s[i]==temp[cnt]) cnt++;
		if(cnt==5)
		{
			break;
		}
	}
	if(cnt==5) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


/*
#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    //freopen("task.inp", "r", stdin);
    return 0;
}
*/
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
#include<bits/stdc++.h>
#define __debug(a) for(auto x : a) cout << x << ' '; cout << '\n'
using namespace std;

int d[123];

int main()
{
   //freopen("journey.inp", "r", stdin);
   //freopen("journey.out", "w", stdout);
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   string s; cin >> s;
   string t = "heidi";
   int id = 0;
   for(char c : s) {
      if (c == t[id])
         ++id;
      if (id == 5) {
         cout << "YES\n";
         return 0;
      }
   }
   cout << "NO\n";

   return 0;
}


/*
#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    //freopen("task.inp", "r", stdin);
    return 0;
}
*/
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
#include<bits/stdc++.h>
#define __debug(a) for(auto x : a) cout << x << ' '; cout << '\n'
using namespace std;

int d[123];

int main()
{
   //freopen("journey.inp", "r", stdin);
   //freopen("journey.out", "w", stdout);
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   string s; cin >> s;
   for(char c : s) {
      if (c == 'h') {
         d[c] = 1;
      }
      if (c == 'e') {
         d[c] = d['h'] + 1;
      }
      if (c == 'i') {
         d[c] = max(d['e'], d['d']) + 1;
      }
      if (c == 'd') {
         d[c] = d['i'] + 1;
      }
      if (d[c] == 5) {
         cout << "YES\n";
         return 0;
      }
   }
   cout << "NO\n";

   return 0;
}


/*
#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    //freopen("task.inp", "r", stdin);
    return 0;
}
*/
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
#include<bits/stdc++.h>
#define __debug(a) for(auto x : a) cout << x << ' '; cout << '\n'
using namespace std;

int d[123];

int main()
{
   //freopen("journey.inp", "r", stdin);
   //freopen("journey.out", "w", stdout);
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   string s; cin >> s;
   string t = "heidi";
   int id = 0;
   for(char c : s) {
      if (c == t[id]) ++id;
      if (id == 4) {
         cout << "YES\n";
         return 0;
      }
   }
   cout << "NO\n";

   return 0;
}


/*
#include <bits/stdc++.h>
#define fi first
#define se second
#define oo 1000000007
#define maxi(a, b) if (a < b) a = b
#define mixi(a, b) if (a > b) a = b
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    //freopen("task.inp", "r", stdin);
    return 0;
}
*/
#define sfo(i, a, b) for(int(i) = (int)(a); (i) <= (int)(b); ++(i))
#define bfo(i, a, b) for(int(i) = (int)(a); (i) >= (int)(b); --(i))
#include<bits/stdc++.h>
#define __debug(a) for(auto x : a) cout << x << ' '; cout << '\n'
using namespace std;

int d[123];

int main()
{
   //freopen("journey.inp", "r", stdin);
   //freopen("journey.out", "w", stdout);
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   string s; cin >> s;
   for(char c : s) {
      if (c == 'h') {
         d[c] = 1;
      }
      if (c == 'e') {
         d[c] = d['h'] + 1;
      }
      if (c == 'i') {
         d[c] = max(d['e'], d['d']) + 1;
      }
      if (c == 'd') {
         d[c] = d['i'] + 1;
      }
      if (c == 'i' && d[c] == 5) {
         cout << "YES\n";
         return 0;
      }
   }
   cout << "NO\n";

   return 0;
}


#include<bits/stdc++.h>

using namespace std;

int a,i;
string s,t;
int main()
{

     cin>>s;
     t="heidi";
      for(i=0; i<s.size(); i++)
       if(s[i]==t[a])
             a++;
      if(a==5)
         cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int a,i;
     string s,t;
     cin>>s;
     t="heidi";
   for(i=0; i<s.size(); i++)
       if(s[i]==t[a])
             a++;
      if(a==5)
         cout<<"YES"<<endl;
        else
        cout<<"NO"<<endl;
}


#include <bits/stdc++.h>

#define j1 D_Dubovec

using namespace std;

string s,ss[10001],z[10001],q[10001];
char c ,v;
int b,n, i, j, f[10001] , x , y ,g , kg[10001], ks[10001] , fh,fe,fi,fd,fii ;

int main () {

//      freopen ("input.txt", "r", stdin);
//   freopen ("output.txt", "w", stdout);
     cin >> s;
     for(i=0;i<s.size();i++){
        if(s[i]=='h')fh=1;
        if(s[i]=='e' and fh==1)fe=1;
        if(s[i]=='i' and fe==1 and fh==1)fi=1;
        if(s[i]=='d' and fi==1 and fh==1 and fe==1)fd=1;
        if(s[i]=='i' and fi==1 and fh==1 and fe==1 and fd==1)fii=1;
     }
     if(fh==1 and fe==1 and fi==1 and fd==1 and fii==1)cout << "YES" << endl;
     else cout << "NO" << endl;

     return 0;
}


#include <bits/stdc++.h>

#define j1 D_Dubovec

using namespace std;

string s,ss[10001],z[10001],q[10001];
char c ,v;
int b,n, i, j, f[10001] , x , y ,g , kg[10001], ks[10001] , flad ;

int main () {

//      freopen ("input.txt", "r", stdin);
//   freopen ("output.txt", "w", stdout);
     cin >> s;
     for(i=0;i<s.size();i++){
        if(s[i]=='h'){
            if(s[i+1]=='i' and s[i+2]=='e' and s[i+3]=='d' and s[i+4]=='i'){
             cout << "NO" << endl;
             return 0;
            }
        }
     }
     cout << "YES" << endl;

     return 0;
}


#include <bits/stdc++.h>

#define j1 D_Dubovec

using namespace std;

string s,ss[10001],z[10001],q[10001];
char c ,v;
int b,n, i, j, f[10001] , x , y ,g , kg[10001], ks[10001] , flad ;

int main () {

//      freopen ("input.txt", "r", stdin);
//   freopen ("output.txt", "w", stdout);
     cin >> s;
     for(i=0;i<s.size();i++){
        if(s[i]=='h'){
            if(s[i+1]=='e' and s[i+2]=='i' and s[i+3]=='d' and s[i+4]=='i'){
             cout << "YES" << endl;
             return 0;
            }
        }
     }
     cout << "NO" << endl;

     return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
    char ss[1005];
    char s2[]={'h','e','i','d','i'};
    scanf(" %s",ss);
    int len=strlen(ss);
    int k=0;
    for(int i=0;i<len;++i)
    if(ss[i]==s2[k]){
        ++k;
        if(k==4)
            break;
    }
    if(k==4)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
    char ss[1005];
    char s2[]={'h','e','i','d','i'};
    cin>>ss;
    int len=strlen(ss);
    int k=0;
    for(int i=0;i<=len;++i)
    if(ss[i]==s2[k]){
        ++k;
        if(k==5)
            break;
    }
    if(k==5)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
    char ss[1005];
    char s2[]={'h','e','i','d','i'};
    cin>>ss;
    int len=strlen(ss);
    int k=0;
    for(int i=0;i<len;++i)
    if(ss[i]==s2[k]){
        ++k;
        if(k==4)
            break;
    }
    if(k==4)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
    char ss[1005];
    char s2[]={'h','e','i','d','i'};
    gets(ss);cout<<ss;
    int len=strlen(ss);
    int k=0;
    for(int i=0;i<len;++i)
    if(ss[i]==s2[k]){
        ++k;
        if(k==4)
            break;
    }
    if(k==4)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
    char ss[1005];
    char s2[]={'h','e','i','d','i'};
    cin>>ss;
    int len=strlen(ss);
    int k=0;
    for(int i=0;i<len;++i)
    if(ss[i]==s2[k]){
        ++k;
        if(k==4)
            break;
    }
    if(k==4)
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


#include<bits/stdc++.h>
using namespace std;
vector<int>w;
string n,s;int m,sum,num;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();	cout.tie();
	cin>>n;
	for(int i = 0;i < n.size();i++){
		if(n[i]=='h'||n[i]=='e'||n[i]=='i'||n[i]=='d'){
			w.push_back(n[i]);
		}
	}
	for(int i = 0;i < w.size();i++){
		if(w[i]=='h'&&w[i+1]=='e'&&w[i+2]=='i'&&w[i+3]=='d'&&w[i+4]=='i'){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
string n;int m,sum,num,sam,nam;
int main(){
	cin>>n;
	for(int i = 0;i < n.size();i++){
		if(n[i]=='h'){
			m=1;
		}
		else if(n[i]=='e'&&m==1){
			sum=1;
		}
		else if(n[i]=='i'&&m==1&&sum==1){
			num=1;
		}
		else if(n[i]=='d'&&m==1&&sum==1&&num==1&&sam==0){
			sam=1;
		}
		if(n[i]=='i'&&m==1&&sum==1&&num==1&&sam==1){
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <fenv.h>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	int i,j,k,p,q;
	for(i=0;i<s.size();i++){
		if(s[i]!='h'&&s[i]!='e'&&s[i]!='i'&&s[i]!='d'){
			s.erase(i,1);
			i--;
		}
	}
	int h=0,e=0,ii=0,d=0;
	int w1=-1,w2=-1,w3=-1,w4=-1;
// 	cout<<s<<endl;
	for(i=0;i<s.size();i++){
		if(s[i]=='h'){
			h++;
			if(w1==-1) w1=i;
		}
		if(s[i]=='e'){
			e++;
			if(i>w1) w2=i;
		}
		if(s[i]=='i'){
			ii++;
			if(i>w2) w3=i;
		}
		if(s[i]=='d'){
			d++;
			if(i>w3) w4=i;
		}
	}
	if(h==0||e==0||ii<2||d==0){
		cout<<"NO"<<endl;
		return 0;
	}
	if(w1!=-1&&w2!=-1&&w3!=-1&&w4!=-1){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <fenv.h>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	int i,j,k,p,q;
	for(i=0;i<s.size();i++){
		if(s[i]!='h'&&s[i]!='e'&&s[i]!='i'&&s[i]!='d'){
			s.erase(i,1);
			i--;
		}
	}
	int h=0,e=0,ii=0,d=0;
	int w1=-1,w2=-1,w3=-1,w4=-1;
// 	cout<<s<<endl;
	for(i=0;i<s.size();i++){
		if(s[i]=='h'){
			h++;
			if(w1==-1) w1=i;
		}
		if(s[i]=='e'){
			e++;
			if(i>w1&&w1!=-1) w2=i;
		}
		if(s[i]=='i'){
			ii++;
			if(i>w2&&w2!=-1) w3=i;
		}
		if(s[i]=='d'){
			d++;
			if(i>w3&&w3!=-1) w4=i;
		}
	}
	if(h==0||e==0||ii<2||d==0){
		cout<<"NO"<<endl;
		return 0;
	}
	if(w1!=-1&&w2!=-1&&w3!=-1&&w4!=-1){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <fenv.h>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	int i,j,k,p,q;
	for(i=0;i<s.size();i++){
		if(s[i]!='h'&&s[i]!='e'&&s[i]!='i'&&s[i]!='d'){
			s.erase(i,1);
			i--;
		}
	}
	int h=0,e=0,ii=0,d=0;
	int w1=-1,w2=-1,w3=-1,w4=-1,w5=-1;
// 	cout<<s<<endl;
	for(i=0;i<s.size();i++){
		if(s[i]=='h'){
			h++;
			if(w1==-1) w1=i;
		}
		if(s[i]=='e'){
			e++;
			if(i>w1&&w1!=-1) w2=i;
		}
		if(s[i]=='i'){
			ii++;
			if(i>w2&&w2!=-1) w3=i;
		}
		if(s[i]=='d'){
			d++;
			if(i>w3&&w3!=-1) w4=i;
		}
		if(s[i]=='i'){
			ii++;
			if(i>w4&&w4!=-1) w5=i;
		}
	}
//	cout<<s<<endl;
//	cout<<w1<<" "<<w2<<" "<<w3<<" "<<w4<<" "<<w5<<endl;
	if(h==0||e==0||ii<2||d==0){
		cout<<"NO"<<endl;
		return 0;
	}
	if(w1!=-1&&w2!=-1&&w3!=-1&&w4!=-1&&w5!=-1){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int j=0;
	string s,s1="heidi";
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
	{
		if(s[i]==s1[j])
			j++;
		if(j==5)
			break;
	}
	if(j==5)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int j=0;
	string s,s1="heidi";
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
	{
		if(s[i]==s1[j])
			j++;
		if(j==4)
		{
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h=0,e=0,i=0,d=0;
	string s,s1="heidi";
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
	{
		if(s[i]=='h')h++;
		if(s[i]=='e')e++;
		if(s[i]=='i')i++;
		if(s[i]=='d')d++;
	}
	if(h>=1&&e>=1&&i>=2&&d>=1)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int j=0;
	string s,s1="heidi";
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
		if(s[i]==s1[j])
			j++;
	if(j>=4)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int j=1;
	string s,s1="heidi";
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
		if(s[i]==s1[j])
			j++;
	if(j>=5)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int j=1;
	string s,s1="heidi";
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
	{
		if(s[i]=='h'||s[i]=='e'||s[i]=='i'||s[i]=='d')
			j++;
		if(j==5)
			break;
	}
	if(j==5)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int j=1;
	string s,s1="heidi";
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
	{
		if(s[i]==s1[j])
			j++;
		if(j==5)
			break;
	}
	if(j==5)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define u unsigned
#define pb push_back
#define mp make_pair
#define FX cout<<fixed,cout.precision(18);
#define iOS ios_base::sync_with_stdio(false);
#define ones __builtin_popcount()
const long double eps = 0.00000001;
const long long MOD = 1e9 + 7;
using namespace std;
int ans;
bool b[6];
string ss="heidi",s;
map<int,int>mm;
main()
{
	FX iOS
	int n,i,j;
	cin>>s;
	for(i=0;i<s.size();++i)
	{
		if(!b[0]&&s[i]==ss[0])b[0]=1;
		else if(!b[1]&&s[i]==ss[1])b[1]=1;
		else if(!b[2]&&s[i]==ss[2])b[2]=1;
		else if(!b[3]&&s[i]==ss[3])b[3]=1;
		else if(!b[4]&&s[i]==ss[4])b[4]=1;
	}
	if(b[4])cout<<"YES";
	else cout<<"NO";
}


#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define u unsigned
#define pb push_back
#define mp make_pair
#define FX cout<<fixed,cout.precision(18);
#define iOS ios_base::sync_with_stdio(false);
#define ones __builtin_popcount()
const long double eps = 0.00000001;
const long long MOD = 1e9 + 7;
using namespace std;
int ans;
bool b[6];
string ss="heidi",s;
map<int,int>mm;
main()
{
	FX iOS
	int n,i,j;
	cin>>s;
	for(i=0;i<s.size();++i)
	{
		if(!b[0]&&s[i]==ss[0])b[0]=1;
		else if(b[0]&&!b[1]&&s[i]==ss[1])b[1]=1;
		else if(b[0]&&b[1]&&!b[2]&&s[i]==ss[2])b[2]=1;
		else if(b[0]&&b[1]&&b[2]&&!b[3]&&s[i]==ss[3])b[3]=1;
		else if(b[0]&&b[1]&&b[2]&&b[3]&&!b[4]&&s[i]==ss[4])b[4]=1;
	}
	if(b[4])cout<<"YES";
	else cout<<"NO";
}


#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define u unsigned
#define pb push_back
#define mp make_pair
#define FX cout<<fixed,cout.precision(18);
#define iOS ios_base::sync_with_stdio(false);
#define ones __builtin_popcount()
const long double eps = 0.00000001;
const long long MOD = 1e9 + 7;
using namespace std;
int ans;
bool b[6];
string ss="heidi";
map<int,int>mm;
main()
{
	FX iOS
	int n,i,j;
	cin>>s;
	for(i=0;i<s.size();++i)
	{
		if(!b[0]&&s[i]==ss[0])b[0]=1;
		else if(!b[1]&&s[i]==ss[1])b[1]=1;
		else if(!b[2]&&s[i]==ss[2])b[2]=1;
		else if(!b[3]&&s[i]==ss[3])b[3]=1;
		else if(!b[4]&&s[i]==ss[4])b[4]=1;
	}
	if(b[4])cout<<"YES";
	else cout<<"NO";
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#define db printf("----i=%d\n",i);
using namespace std;
int main()
{
	int ans[6];
	char ch[10000];
	while(cin>>ch)
	{
		int cnt=0;
		memset(ans,0,sizeof(ans));
		int flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
		//	printf("%c  \n",ch[i]);
			if(ch[i]=='h')
			{
				ans[0]=1;
			}
			else if(ch[i]=='e'&&ans[0])
			{
				ans[1]=1;
			}
			else if(ch[i]=='i'&&ans[0]&&ans[1])
			{
				if(cnt==0)
				{
					ans[4]=1;
					cnt=1;
				}
				if(cnt==1)
				{
					ans[2]=1;
					cnt=0;
				}
			}
			else if(ch[i]=='d'&&ans[0]&&ans[1]&&ans[2])
			{
				ans[3]=1;
			}
		}
		for(int i=0;i<5;i++)
		{
			if(!ans[i])
			{
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	int ans[6];
	char ch[10000];
	while(cin>>ch)
	{
		int cnt=0;
		memset(ans,0,sizeof(ans));
		int flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
			if(ch[i]=='h')
			{
				ans[0]=1;
			}
			else if(ch[i]=='e'&&ans[0])
			{
				ans[1]=1;
			}
			else if(ch[i]=='i'&&ans[0]&&ans[1])
			{
				if(cnt==0)
				{
					ans[2]=1;
				}
				else if(cnt==1)
				{
					ans[4]=1;
				}
			}
			else if(ch[i]=='d'&&ans[0]&&ans[1]&&ans[2])
			{
				ans[3]=1;
				cnt=1;
			}
		}
		for(int i=0;i<5;i++)
		{
			if(!ans[i])
			{
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	int ans[6];
	char ch[10000];
	while(cin>>ch)
	{
		int cnt;
		memset(ans,0,sizeof(ans));
		int flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
			if(ch[i]=='h')
			{
				ans[0]=1;
			}
			else if(ch[i]=='e'&&ans[0])
			{
				ans[1]=1;
			}
			else if(ch[i]=='i'&&ans[0]&&ans[1])
			{
				if(cnt==0)
				{
					ans[2]=1;
				}
				else if(cnt==1)
				{
					ans[4]=1;
				}
			}
			else if(ch[i]=='d'&&ans[0]&&ans[1]&&ans[2])
			{
				ans[3]=1;
				cnt=1;
			}
		}
		for(int i=0;i<5;i++)
		{
			if(!ans[i])
			{
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	char ans[6]="heidi";
	char ch[10000];
	while(cin>>ch)
	{
		int flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
			if(flag) break;
			if(ch[i]=='h')
			{
				for(int j=i;j<l;j++)
				{
					if(flag) break;
					if(ch[j]=='e')
					{
						for(int k=j;k<l;k++)
						{
							if(flag)  break;
							if(ch[k]=='i')
							{
								for(int o=k;o<l;o++)
								{
									if(flag) break;
									if(ch[o]=='d')
									{
										for(int p=o;p<l;p++)
										{
											if(flag)  break;
											if(ch[p]=='i')
											{
												flag=1;
												break;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		if(flag)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	char ans[6]={'h','i','e','d','i'};
	char ch[20000];
	cin>>ch;
	int sum=0,flag=0;
	int l=strlen(ch);
	for(int i=0;i<l;i++)
	{
		if(ch[i]==ans[0])
		{
			sum=0;
			for(int j=0;j<5;j++)
			{
				if(ch[i+j]==ans[j])
					sum++;
				else
					break;
			}
			if(sum==5)
			{
				flag=1;
			}
		}
	}
	if(flag)
	{
		printf("NO\n");
	}
	else
	{
		printf("YES\n");
	}
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	int ans[6];
	char ch[10000];
	while(cin>>ch)
	{
		int cnt=0;
		memset(ans,0,sizeof(ans));
		int flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
			if(ch[i]=='h')
			{
				ans[0]=1;
			}
			else if(ch[i]=='e'&&ans[0])
			{
				ans[1]=1;
			}
			else if(ch[i]=='i'&&ans[0]&&ans[1])
			{
				if(cnt==0)
				{
					ans[2]=1;
					cnt=1;
				}
				else if(cnt==1)
				{
					ans[4]=1;
					cnt=0;
				}
			}
			else if(ch[i]=='d'&&ans[0]&&ans[1]&&ans[2])
			{
				ans[3]=1;
			}
		}
		for(int i=0;i<5;i++)
		{
			if(!ans[i])
			{
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	char ans[6]={'h','i','e','d','i'};
	char ch[10000];
	while(cin>>ch)
	{
		int sum=0,flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
			sum=0;
			if(flag)
			{
				break;
			}
			if(ch[i]=='h')
			{
				for(int j=0;j<5;j++)
				{
					if(ch[i+j]==ans[j])
					{
						sum++;
					}
					else
					{
						i=i+j;
						break;
					}
				}
				if(sum==5)
				{
					flag=1;
				}
			}
		}
		if(flag)
		{
			printf("NO\n");
		}
		else
		{
			printf("YES\n");
		}
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	int ans[6];
	char ch[10000];
	while(cin>>ch)
	{
		int cnt;
		memset(ans,0,sizeof(ans));
		int flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
			if(ch[i]=='h')
			{
				ans[0]=1;
				cnt=0;
			}
			else if(ch[i]=='e'&&ans[0])
			{
				ans[1]=1;
				cnt=0;
			}
			else if(ch[i]=='i'&&ans[0]&&ans[1])
			{
				if(cnt==0)
				{
					ans[2]=1;
				}
				else if(cnt==1)
				{
					ans[4]=1;
				}
			}
			else if(ch[i]=='d'&&ans[0]&&ans[1]&&ans[2])
			{
				ans[3]=1;
				cnt=1;
			}
		}
		for(int i=0;i<5;i++)
		{
			if(!ans[i])
			{
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	char ans[6]={'h','i','e','d','i'};
	char ch[10000];
	while(cin>>ch)
	{
		int sum=0,flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
			sum=0;
			if(flag)
			{
				break;
			}
			if(ch[i]=='h')
			{
				for(int j=0;j<5;j++)
				{
					if(ch[i+j]==ans[j])
					{
						sum++;
					}
					else
					{
						break;
					}
				}
				if(sum==5)
				{
					flag=1;
				}
			}
		}
		if(flag)
		{
			printf("NO\n");
		}
		else
		{
			printf("YES\n");
		}
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	char ans[6]={'h','i','e','d','i'};
	char ch[10000];
	while(cin>>ch)
	{
		int sum=0,flag=0;
		int l=strlen(ch);
		for(int i=0;i<l;i++)
		{
			sum=0;
			if(flag)
			{
				break;
			}
			if(ch[i]=='h')
			{
				for(int j=0;j<5;j++)
				{
				//	printf("%c %c \n",ch[i+j],ans[j]);
					if(ch[i+j]==ans[j])
					{
						sum++;
					}
					else
					{
					//	i=i+j;
						break;
					}
				}
				if(sum==5)
				{
					flag=1;
				}
			}
		}
		if(flag)
		{
			printf("NO\n");
		}
		else
		{
			printf("YES\n");
		}
	}
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'h')
			if (s.length() > s.find('i', s.find('d', s.find('i', s.find('e', i))))) cout << "YES";
			else cout << "NO";
	}

	//4294967295
}


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

public class CF {

    static List<List<Integer>> graph;
    static int[] depth;
    static int[] size;

    public static void dfs(int v, int p) {
        for (int u : graph.get(v)) {
            if (u != p) {
                depth[u] = 1 + depth[v];
                dfs(u, v);
            }
        }
        return;
    }

    public static int dfs1(int v, int p) {
        if (graph.get(v).size() == 1) {
            size[v] = 1;
            return 1;
        }
        for (int u : graph.get(v)) {
            if (u != p) {
                size[v] += dfs1(u, v);
            }
        }
        size[v]++;
        return size[v];
    }

    public static void main(String[] args) {

        FastReader in = new FastReader();
        PrintWriter o = new PrintWriter(System.out);

        int n = in.nextInt();
        int k = in.nextInt();
        depth = new int[n];
        size = new int[n];

        graph = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < n - 1; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            x--;
            y--;
            graph.get(x).add(y);
            graph.get(y).add(x);
        }

        depth[0] = 1;
        int[] arr = new int[n];
        dfs(0, -1);
        dfs1(0, -1);

        for (int i = 0; i < n; i++) {
            arr[i] = depth[i] - size[i];
        }

        Arrays.sort(arr);
        long sum = 0;
        for (int i = n - 1; i >= 0 && k > 0; i--, k--) {
            sum += arr[i];
        }
        o.println(sum);

        o.close();
        return;

    }

    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());
        }

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

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

        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.io.PrintWriter;
import java.util.*;

public class CF {

    static List<List<Integer>> graph;
    static int[] depth;
    static int[] size;

    public static void dfs(int v, int p) {
        for (int u : graph.get(v)) {
            if (u != p) {
                depth[u] = 1 + depth[v];
                dfs(u, v);
            }
        }
        return;
    }

    public static int dfs1(int v, int p) {
        if (graph.get(v).size() == 1 && p == graph.get(v).get(0)) {
            size[v] = 1;
            return 1;
        }
        for (int u : graph.get(v)) {
            if (u != p) {
                size[v] += dfs1(u, v);
            }
        }
        size[v]++;
        return size[v];
    }

    public static void main(String[] args) {

        FastReader in = new FastReader();
        PrintWriter o = new PrintWriter(System.out);

        int n = in.nextInt();
        int k = in.nextInt();
        depth = new int[n];
        size = new int[n];

        graph = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < n - 1; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            x--;
            y--;
            graph.get(x).add(y);
            graph.get(y).add(x);
        }

        depth[0] = 1;
        int[] arr = new int[n];
        dfs(0, -1);
        dfs1(0, -1);

        for (int i = 0; i < n; i++) {
            arr[i] = depth[i] - size[i];
        }

        Arrays.sort(arr);
        long sum = 0;
        for (int i = n - 1; i >= 0 && k > 0; i--, k--) {
            sum += arr[i];
        }
//        for (int i = 0; i < n; i++) {
//            o.println(depth[i] + " " + size[i]);
//        }
        o.println(sum);

        o.close();
        return;

    }

    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());
        }

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

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

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

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Locale;
import java.util.Random;
import java.util.StringTokenizer;

public class SolutionFixed implements Runnable {

	private PrintStream out;
	private BufferedReader in;
	private StringTokenizer st;

	public void solve() throws IOException {
		long time0 = System.currentTimeMillis();

		int n = nextInt();
		int k = nextInt();
		int[] u = new int[n - 1];
		int[] v = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			u[i] = nextInt() - 1;
			v[i] = nextInt() - 1;
		}
		long answer = solve(n, k, u, v);
		out.println(answer);

		System.err.println("time: " + (System.currentTimeMillis() - time0));
	}

	private long solve(int n, int k, int[] u, int[] v) {
		int[][] g = buildGraph(n, u, v);
		int[] size = new int[n];
		int[] depth = new int[n];
		calcSize(-1, 0, g, size, 0, depth);
		Integer[] snodes = new Integer[n];
		for (int i = 0; i < n; i++) {
			snodes[i] = i;
		}
		shuffle(snodes);
		Arrays.sort(snodes, new Comparator<Integer>() {
			@Override
			public int compare(Integer arg0, Integer arg1) {
				return Integer.compare(size[arg0] - depth[arg0], size[arg1] - depth[arg1]);
			}
		});
		boolean[] black = new boolean[n];
		for (int i = 0; i < k; i++) {
			black[snodes[i]] = true;
		}
		int[] blackSize = new int[n];
		calcBlackSize(-1, 0, black, g, blackSize);
		long answer = 0;
		for (int i = 0; i < n; i++) {
			if (!black[i]) {
				answer = answer + blackSize[i];
			}
		}
		return answer;
	}

	private void shuffle(Integer[] a) {
		Random rnd = new Random();
		for (int i = 0; i < 1000; i++) {
			int u = rnd.nextInt(a.length);
			int v = rnd.nextInt(a.length);
			Integer tmp = a[u];
			a[u] = a[v];
			a[v] = tmp;
		}
	}

	private void calcSize(int from, int node, int[][] g, int[] size, int d, int[] depth) {
		size[node] = 1;
		depth[node] = d;
		for (int child : g[node]) {
			if (child != from) {
				calcSize(node, child, g, size, d + 1, depth);
				size[node] += size[child];
			}
		}
	}

	private void calcBlackSize(int from, int node, boolean[] black, int[][] g, int[] size) {
		size[node] = black[node] ? 1 : 0;
		for (int child : g[node]) {
			if (child != from) {
				calcBlackSize(node, child, black, g, size);
				size[node] += size[child];
			}
		}
	}

	private int[][] buildGraph(int n, int[] u, int[] v) {
		int[] cnt = new int[n];
		for (int i = 0; i < u.length; i++) {
			cnt[u[i]]++;
			cnt[v[i]]++;
		}
		int[][] g = new int[n][];
		for (int i = 0; i < n; i++) {
			g[i] = new int[cnt[i]];
			cnt[i] = 0;
		}
		for (int i = 0; i < u.length; i++) {
			g[u[i]][cnt[u[i]]++] = v[i];
			g[v[i]][cnt[v[i]]++] = u[i];
		}
		return g;
	}

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

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

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

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

	@Override
	public void run() {
		try {
			solve();
			out.close();
		} catch (Throwable e) {
			throw new RuntimeException(e);
		}
	}

	public SolutionFixed(String name) throws IOException {
		Locale.setDefault(Locale.US);
		if (name == null) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintStream(new BufferedOutputStream(System.out));
		} else {
			in = new BufferedReader(new InputStreamReader(new FileInputStream(name + ".in")));
			out = new PrintStream(new BufferedOutputStream(new FileOutputStream(name + ".out")));
		}
		st = new StringTokenizer("");
	}

	public static void main(String[] args) throws IOException {
		new Thread(new SolutionFixed(null)).start();
	}
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Locale;
import java.util.Random;
import java.util.StringTokenizer;

public class Solution implements Runnable {

	private PrintStream out;
	private BufferedReader in;
	private StringTokenizer st;

	public void solve() throws IOException {
		long time0 = System.currentTimeMillis();

		int n = nextInt();
		int k = nextInt();
		int[] u = new int[n - 1];
		int[] v = new int[n - 1];
		for (int i = 0; i < n - 1; i++) {
			u[i] = nextInt() - 1;
			v[i] = nextInt() - 1;
		}
		long answer = solve(n, k, u, v);
		out.println(answer);

		System.err.println("time: " + (System.currentTimeMillis() - time0));
	}

	private long solve(int n, int k, int[] u, int[] v) {
		int[][] g = buildGraph(n, u, v);
		int[] size = new int[n];
		calcSize(-1, 0, g, size);
		Integer[] snodes = new Integer[n];
		for (int i = 0; i < n; i++) {
			snodes[i] = i;
		}
		shuffle(snodes);
		Arrays.sort(snodes, new Comparator<Integer>() {
			@Override
			public int compare(Integer arg0, Integer arg1) {
				return Integer.compare(size[arg0], size[arg1]);
			}
		});
		boolean[] black = new boolean[n];
		for (int i = 0; i < k; i++) {
			black[snodes[i]] = true;
		}
		int[] blackSize = new int[n];
		calcBlackSize(-1, 0, black, g, blackSize);
		long answer = 0;
		for (int i = 0; i < n; i++) {
			if (!black[i]) {
				answer = answer + blackSize[i];
			}
		}
		return answer;
	}

	private void shuffle(Integer[] a) {
		Random rnd = new Random();
		for (int i = 0; i < 1000; i++) {
			int u = rnd.nextInt(a.length);
			int v = rnd.nextInt(a.length);
			Integer tmp = a[u];
			a[u] = a[v];
			a[v] = tmp;
		}
	}

	private void calcSize(int from, int node, int[][] g, int[] size) {
		size[node] = 1;
		for (int child : g[node]) {
			if (child != from) {
				calcSize(node, child, g, size);
				size[node] += size[child];
			}
		}
	}

	private void calcBlackSize(int from, int node, boolean[] black, int[][] g, int[] size) {
		size[node] = black[node] ? 1 : 0;
		for (int child : g[node]) {
			if (child != from) {
				calcBlackSize(node, child, black, g, size);
				size[node] += size[child];
			}
		}
	}

	private int[][] buildGraph(int n, int[] u, int[] v) {
		int[] cnt = new int[n];
		for (int i = 0; i < u.length; i++) {
			cnt[u[i]]++;
			cnt[v[i]]++;
		}
		int[][] g = new int[n][];
		for (int i = 0; i < n; i++) {
			g[i] = new int[cnt[i]];
			cnt[i] = 0;
		}
		for (int i = 0; i < u.length; i++) {
			g[u[i]][cnt[u[i]]++] = v[i];
			g[v[i]][cnt[v[i]]++] = u[i];
		}
		return g;
	}

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

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

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

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

	@Override
	public void run() {
		try {
			solve();
			out.close();
		} catch (Throwable e) {
			throw new RuntimeException(e);
		}
	}

	public Solution(String name) throws IOException {
		Locale.setDefault(Locale.US);
		if (name == null) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintStream(new BufferedOutputStream(System.out));
		} else {
			in = new BufferedReader(new InputStreamReader(new FileInputStream(name + ".in")));
			out = new PrintStream(new BufferedOutputStream(new FileOutputStream(name + ".out")));
		}
		st = new StringTokenizer("");
	}

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


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

public class Main {
    static ArrayList<Integer>[] adj;
    static int[] depth,sub;
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        StringBuilder sb=new StringBuilder();
        int n=sc.nextInt(),k=sc.nextInt();
        adj=new ArrayList[n];
        for(int i=0;i<n;i++)adj[i]=new ArrayList<>();
        depth=new int[n];
        sub=new int[n];
        for(int i=0;i<n-1;i++){
            int u=sc.nextInt()-1,v=sc.nextInt()-1;
            adj[u].add(v);
            adj[v].add(u);
        }
        dfs(0,-1);
        Integer[] sum=new Integer[n];
        for(int i=0;i<n;i++){
            sum[i]=depth[i]-sub[i];
        }
        Arrays.sort(sum);
        long ans=0;
        for(int i=0;i<k;i++)ans+=sum[n-1-i];
        System.out.println(ans);
    }
    static int dfs(int curr,int par){
        if(par==-1)depth[curr]=1;
        else depth[curr]=depth[par]+1;
        sub[curr]=1;
        for(int node:adj[curr]){
            if(node!=par){
                sub[curr]+=dfs(node,curr);
            }
        }
        return sub[curr];
    }
}
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;
    }
}


/* 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 Main
{

   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;
    }

    public static void DFS(int curr_node , int par , int lev , 	ArrayList<ArrayList<Integer>> edge , int[]subTreeSize , int height[] , 	ArrayList<Integer> contri){

        subTreeSize[curr_node] = 1;
        height[curr_node] = lev;

        for(int i=0;i<edge.get(curr_node).size();i++){
            if(edge.get(curr_node).get(i) == par) continue;

            DFS(edge.get(curr_node).get(i) , curr_node , lev + 1 , edge , subTreeSize , height , contri);

            subTreeSize[curr_node]+= subTreeSize[edge.get(curr_node).get(i)];

        }

        contri.add((height[curr_node] - subTreeSize[curr_node] ));
    }

	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		 FastReader sc = new FastReader();
        StringBuilder sb=new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<ArrayList<Integer>> edge =  new 	ArrayList<ArrayList<Integer>>();

		for(int i=0;i<=n;i++)
		edge.add(new ArrayList<Integer>());

		for(int i =1;i<=n-1;i++){
		   int u = sc.nextInt();
		int v = sc.nextInt();
		    edge.get(u).add(v);
		    edge.get(v).add(u);

		}

	int []subTreeSize = new int[n+1];
	int height[] = new int[n+1];
		ArrayList<Integer> contri = new ArrayList<Integer>();

	DFS(1,0,1,edge,subTreeSize,height,contri);

//	for(int i = 1;i<=n;i++)

	Collections.sort(contri , Collections.reverseOrder());

	int count =0;
	while(k>0){
	    k--;
	    count+= contri.get(0);
	       contri.remove(0);
	}

	System.out.println(count);

	}
}}


/* 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 Main
{

   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;
    }

    public static void DFS(int curr_node , int par , int lev , 	ArrayList<ArrayList<Integer>> edge , int[]subTreeSize , int height[] , 	ArrayList<Integer> contri){

        subTreeSize[curr_node] = 1;
        height[curr_node] = lev;

        for(int i=0;i<edge.get(curr_node).size();i++){
            if(edge.get(curr_node).get(i) == par) continue;

            DFS(edge.get(curr_node).get(i) , curr_node , lev + 1 , edge , subTreeSize , height , contri);

            subTreeSize[curr_node]+= subTreeSize[edge.get(curr_node).get(i)];

        }

        contri.add((height[curr_node] - subTreeSize[curr_node] ));
    }

	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		 FastReader sc = new FastReader();
        StringBuilder sb=new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<ArrayList<Integer>> edge =  new 	ArrayList<ArrayList<Integer>>();

		for(int i=0;i<=n;i++)
		edge.add(new ArrayList<Integer>());

		for(int i =1;i<=n-1;i++){
		   int u = sc.nextInt();
		int v = sc.nextInt();
		    edge.get(u).add(v);
		    edge.get(v).add(u);

		}

	int []subTreeSize = new int[n+1];
	int height[] = new int[n+1];
		ArrayList<Integer> contri = new ArrayList<Integer>();
int s =55;

	DFS(1,0,1,edge,subTreeSize,height,contri);

//	for(int i = 1;i<=n;i++)

	Collections.sort(contri , Collections.reverseOrder());

	int count =0;
	while(k>0){
	    k--;
	    count+= contri.get(0);
	       contri.remove(0);
	}

	System.out.println(count);

	}
}}