#include<stdio.h>

#define maxn 100010

int p[maxn];

bool checked[maxn];

int i,j,n,m;

int blocking_flow(int a, int flow) {
  if(a+m>=n)
    return flow;
  if(flow==0) {
    return 0;
  }
  int i, j, total=0;
  for(i=a+m;i>a;i--) if(!checked[i]) {
    j=blocking_flow(i, flow>p[i]?p[i]:flow);
    flow-=j;
    total+=j;
  }
  p[a]-=total;
  if(p[a]==0 || flow) {
    checked[i]=true;
  }
  return total;
}

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
    if(p[i]==0) checked[i]=true;
  }
  printf("%d\n", blocking_flow(0, 1000000000));
  return 0;
}


#include<stdio.h>

#define maxn 100010

int p[maxn], f[maxn];

int i,j,n,m;

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
  }
  int i, ans = 0, delta;

  for(i=1;i<=m;i++)
    f[i]=p[i];
  j=1+m;
  for(i=1;i<n;i++) {
    if(i+m>=n) {ans+=p[i]; continue;}

    while(j<=i+m && f[i] > 0) {
      delta = p[j] - f[j];
      if(delta > f[i]) delta=f[i];
      f[i]-=delta;
      f[j] += delta;
      if(f[j]==p[j])j++;
    }

  }

  printf("%d\n", ans);
  return 0;
}


#include<stdio.h>
#include<map>
using namespace std;

#define maxn 100010

int p[maxn];
map<int, int> pp;

int i,j,n,m;

int blocking_flow(int a, int flow) {
  map<int, int>::iterator ii;
  if(a+m>=n) {
    ii=pp.find(a);
    ii->second -= flow;
    if (ii->second == 0)
      pp.erase(ii);

    return flow;
  }

  int j, total=0;
  ii = pp.lower_bound(a+m+1);
  while(flow && ii!=pp.begin()) {
    ii--;
    if(ii->first <=a)
        break;
    j=blocking_flow(ii->first, flow>ii->second?ii->second:flow);
    flow-=j;
    total+=j;
    ii=pp.lower_bound(a+m+1);
  }

  ii=pp.find(a);
  ii->second -= total;
  if (flow || ii->second == 0)
    pp.erase(ii);

  if(pp[a]==0 || flow) pp.erase(a);
  return total;
}

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
    if(p[i]) pp[i]=p[i];
  }
  int i, ans = 0;
  for(i=1;i<=m;i++) {
    if(pp.find(i) != pp.end())
      ans+=blocking_flow(i, 1000000000);
  }
  printf("%d\n", ans);
  return 0;
}


#include<stdio.h>

#define maxn 1000100

int p[maxn], f[maxn];

int i,j,n,m;

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
  }
  int i, ans = 0, delta;

  for(i=1;i<=m;i++)
    f[i]=p[i];
  j=1+m;
  for(i=1;i<n;i++) {
    if(i+m>=n) {ans+=f[i]; continue;}

    while(j<=i+m && f[i] > 0) {
      delta = p[j] - f[j];
      if(delta > f[i]) delta=f[i];
      f[i]-=delta;
      f[j] += delta;
      if(f[j]==p[j])j++;
    }

  }

  printf("%d\n", ans);
  return 0;
}


#include<stdio.h>
#include<map>
using namespace std;

#define maxn 100010

int p[maxn];
map<int, int> pp;

int i,j,n,m;

int blocking_flow(int a, int flow) {
  map<int, int>::iterator ii;
  if(a+m>=n) {
    ii=pp.find(a);
    ii->second -= flow;
    if (ii->second == 0)
      pp.erase(ii);

    return flow;
  }

  int j, total=0;
  ii = pp.lower_bound(a+m+1);
  while(flow && ii!=pp.begin()) {
    ii--;
    if(ii->first <=a)
        break;
    j=blocking_flow(ii->first, flow>ii->second?ii->second:flow);
    flow-=j;
    total+=j;
    ii=pp.lower_bound(a+m+1);
  }

  ii=pp.find(a);
  ii->second -= total;
  if (flow || ii->second == 0)
    pp.erase(ii);

  return total;
}

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
    if(p[i]) pp[i]=p[i];
  }
  int i, ans = 0;
  for(i=1;i<=m;i++) {
    if(pp.find(i) != pp.end())
      ans+=blocking_flow(i, 1000000000);
  }
  printf("%d\n", ans);
  return 0;
}


#include<stdio.h>
#include<map>
using namespace std;

#define maxn 100010

int p[maxn];
map<int, int> pp;

int i,j,n,m;

int blocking_flow(int a, int flow) {
  map<int, int>::iterator ii;
  if(a+m>=n) {
    ii=pp.find(a);
    ii->second -= flow;
    if (ii->second == 0)
      pp.erase(ii);

    return flow;
  }

  int j, total=0;
  ii = pp.lower_bound(a+m+1);
  while(flow && ii!=pp.begin()) {
    ii--;
    if(ii->first <=a)
        break;
    j=blocking_flow(ii->first, flow>ii->second?ii->second:flow);
    flow-=j;
    total+=j;
    ii=pp.lower_bound(a+m+1);
  }

  ii=pp.find(a);
  ii->second -= total;
  if (flow || ii->second == 0)
    pp.erase(ii);

  return total;
}

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
    if(p[i]) pp[i]=p[i];
  }
  int i, ans = 0;

  for(i=1;i<=m;i++) {
    auto ii = pp.find(i);
    if(ii != pp.end())
      ans+=blocking_flow(i, ii->second);
  }
  printf("%d\n", ans);
  return 0;
}


#include<stdio.h>

#define maxn 100010

int p[maxn];

bool checked[maxn];

int i,j,n,m;

int blocking_flow(int a, int flow) {
  if(a+m>=n)
    return flow;
  if(flow==0) {
    return 0;
  }
  int i, j, total=0;
  for(i=a+m;i>a;i--) if(!checked[i]) {
    j=blocking_flow(i, flow>p[i]?p[i]:flow);
    flow-=j;
    total+=j;
  }
  p[i]-=total;
  if(p[i]==0 || flow) {
    checked[i]=true;
  }
  return total;
}

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
    if(p[i]==0) checked[i]=true;
  }
  printf("%d\n", blocking_flow(0, 1000000000));
  return 0;
}


#include<stdio.h>
#include<map>
using namespace std;

#define maxn 100010

int p[maxn];
map<int, int> pp;

int i,j,n,m;

int blocking_flow(int a, int flow) {
  if(a+m>=n) {
    pp[a]-=flow;
    if(pp[a]==0) pp.erase(a);

    return flow;
  }
  if(flow==0) {
    return 0;
  }
  int j, total=0;
  auto ii=pp.lower_bound(a+m+1);
  while(flow && ii!=pp.begin()) {
    ii--;
    if(ii->first <=a)
        break;
    j=blocking_flow(ii->first, flow>ii->second?ii->second:flow);
    flow-=j;
    total+=j;
    ii=pp.lower_bound(a+m+1);
  }

  pp[a] -= total;

  if(pp[a]==0 || flow) pp.erase(a);
  return total;
}

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
    if(p[i]) pp[i]=p[i];
  }
  printf("%d\n", blocking_flow(0, 1000000000));
  return 0;
}


#include<stdio.h>

#define maxn 1000100

int p[maxn], f[maxn];

int i,j,n,m;

int main() {
  scanf("%d %d", &n, &m);
  for(i=1;i<n;i++) {
    scanf("%d", &p[i]);
  }
  int i, ans = 0, delta;

  for(i=1;i<=m;i++)
    f[i]=p[i];
  j=1+m;
  for(i=1;i<n;i++) {
    if(i+m>=n) {ans+=f[i]; continue;}
    if(j<=i)j=i+1;

    while(j<=i+m && f[i] > 0) {
      delta = p[j] - f[j];
      if(delta > f[i]) delta=f[i];
      f[i]-=delta;
      f[j] += delta;
      if(f[j]==p[j])j++;
    }

  }

  printf("%d\n", ans);
  return 0;
}


#include <bits/stdc++.h>
#define int long long
#define vi vector <int>
#define si set <int>
#define mii map <int,int>
#define pii pair <int,int>
#define endl "\n"
#define FOR(P,Q) for(int P=0;P<(Q);P++)
#define FORR(P,Q) for(int P=1;P<=(Q);P++)
#define rep(P,R,Q) for(int P=(R);P<=(Q);P++)
#define repb(P,R,Q) for(int P=(R);P>=(Q);P--)
#define pb push_back
#define eb emplace_back
#define bug(j) cerr<<j<<" "
#define NL cerr<<endl
#define D1(arr,a) rep(i,1,a) bug(arr[i])
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("error.txt","w",stderr);
	#endif
	//change ll to int before using string builtin operations
	int tces=1;
	// cin>>tces;
	while(tces--){
		string s;
		cin>>s;
	  int n=s.length();
	  if(n==5)
	  {
	    cout<<"NO";
	    exit(0);
	  }
	  string s1="heidi";
	  int f=0;
	  FOR(i,n){
	    if(f==5){
	    	cout<<"YES";
	    	exit(0);
	    }
	    else if(s[i]==s1[f]){
	    	f++;
	    }
	  }
	  if(f==5){
    	cout<<"YES";
    	exit(0);
    }
    cout<<"NO";
    cerr<<f;
	}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;

    if (s == "hiedi")
        cout << "NO";
    else
    {
        if (s.find("hiedi") != string::npos)
            cout << "NO";
        else
            cout << "YES";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

#define loop(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef string str;

int main ()
{
	str s;
	cin >> s;

		while (s[0] != 'h')
		{
			s.erase(s.begin());
		}
		while (s[1] != 'e')
		{
			s.erase(s.begin()+1);
		}
		while (s[2] != 'i')
		{
			s.erase(s.begin()+2);
		}
		while (s[3] != 'd')
		{
			s.erase(s.begin()+3);
		}
		while (s[4] != 'i')
		{
			s.erase(s.begin()+4);
		}

		if (s[0] == 'h' && s[1] == 'e' && s[2] == 'i' && s[3] == 'd' && s[4] == 'i')
			cout << "YES";
		else
			cout << "NO";

	return 0;

	//abcheaibcdiass

}


#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

#define loop(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef string str;

int main ()
{
	str s;
	cin >> s;

		while (s[0] != 'h')
		{
			s.erase(s.begin());
		}

		if (s.size() >= 2)
			while (s[1] != 'e')
			{
				s.erase(s.begin()+1);
			}
		else
			{
				cout << "NO";
				return 0;
			}

		if (s.size() >= 3)
			while (s[2] != 'i')
			{
				s.erase(s.begin()+2);
			}
		else
			{
				cout << "NO";
				return 0;
			}

		if (s.size() >= 4)
			while (s[3] != 'd')
			{
				s.erase(s.begin()+3);
			}
		else
			{
				cout << "NO";
				return 0;
			}
		if (s.size() >= 5)
			while (s[4] != 'i')
			{
				s.erase(s.begin()+4);
			}
		else
			{
				cout << "NO";
				return 0;
			}

		if (s.size() >= 5)
		{
			if (s[0] == 'h' && s[1] == 'e' && s[2] == 'i' && s[3] == 'd' && s[4] == 'i')
				cout << "YES";
			else
				cout << "NO";
		}

	return 0;

	//abcheaibcdiass

}


#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

#define loop(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef string str;

int main ()
{
	str s;
	cin >> s;

	if (s != "heidi")
	{
		while (s[0] != 'h')
		{
			s.erase(s.begin());
		}
		while (s[1] != 'e')
		{
			s.erase(s.begin()+1);
		}
		while (s[2] != 'i')
		{
			s.erase(s.begin()+2);
		}
		while (s[3] != 'd')
		{
			s.erase(s.begin()+3);
		}
		while (s[4] != 'i')
		{
			s.erase(s.begin()+4);
		}

		if (s[0] == 'h' && s[1] == 'e' && s[2] == 'i' && s[3] == 'd' && s[4] == 'i')
			cout << "YES";
		else
			cout << "NO";
	}
	else
		cout << "NO";
	return 0;

	//abcheaibcdiass

}


#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

#define loop(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef string str;

int main ()
{
	str s;
	cin >> s;

		while (s[0] != 'h')
		{
			s.erase(s.begin());
		}
		if (s.size() >= 1)
		while (s[1] != 'e')
		{
			s.erase(s.begin()+1);
		}
		else
		{
			cout << "NO";
			return 0;
		}
		if (s.size() >= 2)
		while (s[2] != 'i')
		{
			s.erase(s.begin()+2);
		}
				else
		{
			cout << "NO";
			return 0;
		}
		if (s.size() >= 3)
		while (s[3] != 'd')
		{
			s.erase(s.begin()+3);
		}
				else
		{
			cout << "NO";
			return 0;
		}
		if (s.size() >= 4)
		while (s[4] != 'i')
		{
			s.erase(s.begin()+4);
		}
				else
		{
			cout << "NO";
			return 0;
		}

		if (s[0] == 'h' && s[1] == 'e' && s[2] == 'i' && s[3] == 'd' && s[4] == 'i')
			cout << "YES";
		else
			cout << "NO";

	return 0;

	//abcheaibcdiass

}


#include <iostream>
#include <string>

int main()
{
    string s;
    cin >> s;

    if (s == "hiedi")
        cout << "NO";
    else
    {
        if (s.find("hiedi") != string::npos)
            cout << "NO";
        else
            cout << "YES";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <algorithm>
#include <string>
#include <math.h>
#include <string>
using namespace std;

#define loop(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef string str;

int check (str s, int pos, char c)
{
	for (int i = pos; i < s.size();  ++i)
	{
		if (s[i] == c)
			return i;
	}
	return -1;
}
int main ()
{
	str s;
	cin >> s;

	int pos  = 0;

	char arr[5] = {'h' , 'e' , 'i' , 'd' , 'i'};

	for (int i = 0; i < 5; i++)
	{
		int value = check(s, pos , arr[i]);
		if (value == -1)
		{
			cout << "NO";
			return 0;
		}
		else
		{
			pos = value;
		}
	}
	cout << "YES";
	return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;
int main()
{
    string s;
    int p=0;
    char f[6]="hiedi";
    getline(cin,s);
    for (int i=0; i<s.size(); ++i){
        if (s[i]!=f[p]) s[i]='0';
        else p++;
    }
    if (p!=5) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;
int main()
{
    string s;
    int p=0;
    char f[6]="heidi";
    getline(cin,s);
    for (int i=0; i<s.size(); ++i){
        if (s[i]!=f[p]) s[i]='0';
        else p++;
    }
    if (p==5) cout << "YES";
    else cout << "NO";
    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;
int main()
{
    string s;
    int p=0;
    char f[6]="heidi";
    getline(cin,s);
    for (int i=0; i<=s.size()-5; ++i){
        p=0;
        for (int j=i; j<i+5; ++j){
            if (s[j]==f[p]) p++;
            else break;
        }
        if (p==5){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;
int main()
{
    string s;
    int p=0;
    char f[6]="hiedi";
    getline(cin,s);
    for (int i=0; i<=s.size()-5; ++i){
        p=0;
        for (int j=i; j<i+5; ++j){
            if (s[j]==f[p]) p++;
            else break;
        }
        if (p==5){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


//https://codeforces.com/problemset/problem/802/G

#include <iostream>

int main()
{
    std::string s, s1;
    std::cin >> s;

    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] == 'h' || s[i] == 'e' || s[i] == 'i' || s[i] == 'd')
        {
            s1 += s[i];
        }
    }
    if(s1 == "heidi")
        std::cout << "YES";
    else
        std::cout << "NO";
}


#include <iostream>
#include <string>

int main()
{
    int flag = 1;
    std::string s, s2;
    std::cin >> s;
    s2 = "heidi";
    for (int i = 0; i < 5; i++)
    {
        char target = s2[i];
        int val=s.find(target);
        if(val != -1)
        {
            s.erase(0, val + 1);
        }
        else
        {
            flag = 0;
        }
    }
    if(flag == 1)
    {
        std::cout << "YES";
    }
    else
    {
        std::cout << "NO";
    }

}


#include <iostream>
#include <string>

int main()
{
    int flag = 1;
    std::string s, s1;
    std::cin >> s;

    s1 = "heidi";

    for(int i = 0; i < 5; i++)
    {
        char c = s1[i];
        int x = s.find(c);
        if(x != -1)
        {
            s.erase(0,x+1);
        }
        else
            flag = 0;
    }

    if(flag == 0)
        std::cout << "NO";
    else
        std::cout << "YES";
}


#include <iostream>
#include <string>

int main()
{
    int flag = 1;
    std::string s, s1;
    std::cin >> s;

    s1 = "heidi";

    for(int i = 0; i < 5; i++)
    {
        int x = s.find(s[i]);
        if(x != -1)
        {
            s.erase(0,x + 1);
        }
        else
            flag = 0;

    }
    if(flag == 0)
        std::cout << "NO";
    else
        std::cout << "YES";
}


#include<iostream>
//#include<assert.h>
using namespace std;
//assert(x==i);
void solve()
{
string s,t="heidi";
int w=0;
cin>>s;
for(int i=0;i<(int)s.length();++i)
{
if(s[i]==t[w])
{
w++;//if not found it will b there only
}
//string khatam hojaye
if(w==5)
{
cout<<"YES\n";return;
}
}
cout<<"NO\n";
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
int tc=1;
//cin>>tc;
//for(int i=1;i<=tc;i++)
while(tc--)
{
//cout<<"Case #"<<i<<": ";
solve();
}
return 0;
}


#include<iostream>
//#include<assert.h>
using namespace std;
//assert(x==i);
void solve()
{
string s,t="heidi";
int w=0;
cin>>s;
for(int i=0;i<(int)s.length();++i)
{
if(s[i]==t[w])
{
w++;//if not found it will b there only
}
//string khatam hojaye
if(w==(int)t.size())
{
cout<<"YES\n";return;
}
}
cout<<"NO\n";
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
int tc=1;
//cin>>tc;
//for(int i=1;i<=tc;i++)
while(tc--)
{
//cout<<"Case #"<<i<<": ";
solve();
}
return 0;
}


  //Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int j=0,ans=0;;
    string s,k="heidi";
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]==k[j]){
            j++;
            ans++;
        }
    }
    if(ans=5){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

    return 0;
}


//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int j=0,ans=0;;
    string s,k="heidi";
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]==k[j]){
            j++;
            ans++;
        }
    }
    if(ans==5){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

    return 0;
}


//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int h=0,e=0,d=0,sum1=0,sum2=0;
    string s;
    cin>>s;
    h=s.find('h');
    e=s.find('e');
    d=s.find('d');

    vector<int>v;

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

            if(h<e && e<i && i<d){
                sum1=1;
            }
            if(d<i){
                sum2=1;
            }
        }
    }
    if(sum1==1 && sum2==1){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

    return 0;
}


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

int main() {
   string s;
   cin>>s;
   int c = 0;
   for(int i = 0; i < s.length() - 4; i++) {
       if(s[i] == 'h') {
            if(s[i+1] == 'i' && s[i+2] == 'e' && s[i+3] == 'd' && s[i+4] == 'i') {
                    c = 1;
                    break;
            }
       }
   }
   if(c == 0) cout<<"YES";
   else cout<<"NO";
}


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

int main() {
   string s, r = "heidi";
   cin>>s;
   int c = 0, p = 0;
   for(int i = 0; i < r.length(); i++) {
        for(int j = p; j < s.length(); j++) {
            if(s[j] == r[i]) {
                p = j + 1;
                c++;
                break;
            }
        }
    }
   if(c == r.length()) cout<<"YES";
   else cout<<"NO";
}


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

int main() {
   string s;
   cin>>s;
   int c = 0;
   for(long long int i = 0; i < s.length() - 4; i++) {
       if(s[i] == 'h') {
            if(s[i+1] == 'i' && s[i+2] == 'e' && s[i+3] == 'd' && s[i+4] == 'i') {
                    c = 1;
                    break;
            }
       }
   }
   if(c == 0) cout<<"YES";
   else cout<<"NO";
}


#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    int i = n-1;
    int tvla = 0;

    //i
    for(i; i>=0; i-- ){
        if(s[i]=='i'){
           tvla++;
           break;
        }
    }
    //d
    for(i; i>=0; i--){
        if(s[i]=='d'){
            tvla++;
            break;
        }
    }
    //i
    for(i; i>=0; i--){
        if(s[i]=='i'){
            tvla++;
            break;
        }
    }
    //e
    for(i; i>=0; i--){
        if(s[i]=='e'){
            tvla++;
            break;
        }
    }
    //h
    for(i; i>=0; i--){
        tvla++;
        break;
    }

    if(tvla == 5){
        cout << "YES";
    }
        else {
            cout << "NO";
        }
}


#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    int i = n-1;
    int tvla = 0;

    //i
    for(i; i>=0; i-- ){
        if(s[i]=='i'){
           tvla++;
           break;
        }
    }
    //d
    for(i; i>=0; i--){
        if(s[i]=='d'){
            tvla++;
            break;
        }
    }
    //i
    for(i; i>=0; i--){
        if(s[i]=='i'){
            tvla++;
            break;
        }
    }
    //e
    for(i; i>=0; i--){
        if(s[i]=='e'){
            tvla++;
            break;
        }
    }
    //h
    for(i; i>=0; i--){
        if(s[i]=='h'){
            tvla++;
            break;
        }
    }

    //result
    if(tvla == 5){
        cout << "YES";
    }
        else {
            cout << "NO";
        }
}


#include <iostream>

using namespace std;

int main()
{
    int i,flag=0,q=-1,r=-1,t=-1,u=-1;
    string s;
    cin>>s;
    int x=s.size();
 int p=s.find('h');
if(p==-1)
    {   cout<<"NO";}
else
{
   for(i=p;i<x;i++)
   {
       if(s[i]=='e')
       {
           q=i;
           break;
       }
   }
    if(q==-1||q<p)
    {
        cout<<"NO";
    }
    else
    {
      for(i=q;i<x;i++)
   {
       if(s[i]=='i')
       {
           r=i;
           break;
       }
   }
    if(r==-1||r<q)
    {
        cout<<"NO";
    }
    else
    {
       for(i=r;i<x;i++)
   {
       if(s[i]=='d')
       {
           t=i;
           break;
       }
   }
    if(t==-1||t<r)
    {
        cout<<"NO";
    }
    else
    {
        u=s.find_last_of('i');
    if(u==-1||u<t)
    {
        cout<<"NO";
    }
    else
        cout<<"YES";
    }
    }
    }
}
}


#include <iostream>

using namespace std;

int main()
{
    int i,flag=0,q,r,t,u;
    string s;
    cin>>s;
 int p=s.find('h');
if(p==-1)
    {   cout<<"NO";}
else
{
    q=s.find('e');
    if(q==-1||q<p)
    {
        cout<<"NO";
    }
    else
    {
       r=s.find('i');
    if(r==-1||r<q)
    {
        cout<<"NO";
    }
    else
    {
        t=s.find('d');
    if(t==-1||t<r)
    {
        cout<<"NO";
    }
    else
    {
        u=s.find_last_of('i');
    if(u==-1||u<t)
    {
        cout<<"NO";
    }
    else
        cout<<"YES";
    }
    }
    }
}
}


#include <iostream>

using namespace std;

int main()
{
    int i,flag=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='h')
        {
            for(int j=i+1;j<s.size();j++)
            {
                if(s[j]=='e')
                {

                    for(int k=j+1;k<s.size();k++)
                    {
                        if(s[k]=='i')
                        {
                            for(int l=k+1;l<s.size();l++)
                            {
                                if(s[l]=='d')
                                {
                                    for(int m=l+1;m<s.size();m++)
                                    {
                                        if(s[m]=='i')
                                            {
                                                flag++;
                                                break;
                                            }
                                    }
                                    if(flag>=1)
                                        break;
                                }
                            }
                        }
                        if(flag>=1)
                            break;
                    }
                }
                if(flag>=1)
                    break;
            }
        }
        if(flag>=1)
            break;
    }
    if(flag==0)
        cout<<"NO";
    else
        cout<<"YES";
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <list>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);  cout.tie(0); cin.tie(0);

	string fake = "heidi";
	int cur = 0;

	while(cin.peek() != '\n') {

		char x; cin >> x;

		if (x == fake[cur]) {
			cur++;
		}
	}

	if (cur == fake.size()) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}


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

int main()
{
  string s;
  string s2="heidi";
  getline(cin,s);
  int n=s.length();
  int count=0;
  for(int i=0;i<n;i++)
  {
    if (s[i]==s2[count])
    {
      count++;
      if(count==5)
      {
        cout<<"YES";
        break;
      }
    }
  }

  if(count<5)
  {
    cout<<"NO";
  }
  return 0;
}


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

int main()
{
  string s;
  string s2="heidi";
  cin>>s;
  int n=s.length();
  int count=0;
  for(int i=0;i<n;i++)
  {
    if (s[i]==s2[count])
    {
      count++;
      if(count==5)
      {
        cout<<"YES";
        break;
      }
    }
  }

  if(count<5)
  {
    cout<<"NO";
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <string>

#define ll long long int
#define vec vector<int>
#define deq deque<int>
#define str string
#define get_ cin.get()

using namespace std;

int main()
{
	str s;
	getline(cin, s);
	bool ok = false;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'h') {
			bool e = true;
			for (int j = i + 1; j < s.length() && e; j++) {
				if (s[j] == 'e') {
					e = false;
					bool i_ = true;
					for (int k = j + 1; k < s.length() && i_; k++) {
						if (s[k] == 'i') {
							i_ = false;
							bool d = true;
							for (int f = k + 1; f < s.length() && d; f++) {
								if (s[f] == 'd') {
									d = false;
									bool i_sec = true;
									for (int g = f + 1; g < s.length() && i_sec; g++) {
										if (s[g] == 'i') {
											i_sec = false;
											ok = true;
										}
									}
								}
							}
						}
					}
				}
			}
		}
		if (ok) {
			break;
		}
	}
	if (ok) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <string>

#define ll long long int
#define vec vector<int>
#define deq deque<int>
#define str string
#define get_ cin.get()

using namespace std;

int main()
{
	str s;
	getline(cin, s);
	bool ok = false;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'h') {
			for (int j = i + 1; j < s.length(); j++) {
				if (s[j] == 'e') {
					for (int k = j + 1; k < s.length(); k++) {
						if (s[k] == 'i') {
							for (int f = k + 1; f < s.length(); f++) {
								if (s[f] == 'd') {
									for (int g = f + 1; g < s.length(); g++) {
										if (s[g] == 'i') {
											ok = true;
										}
									}
								}
							}
						}
					}
				}
			}
		}
		if (ok) {
			break;
		}
	}
	if (ok) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
#define pb push_back
#define ve vector<int>
using namespace std;
void main() {
	string s;
	cin >> s;
	int h = 0, i1 = 0, e = 0, d = 0, i2 = 0;
	for (int i = 0; i < s.length(); i++) {
		if (h == 0) {
			if (s[i] == 'h') {
				//s.erase(i, 1);
				h++;
			}
		}
		else {
			if (e == 0) {
				if (s[i] == 'e') {
					//s.erase(i, 1);
					e++;
				}
			}
			else {
				if (i1 == 0) {
					if (s[i] == 'i') {
						//s.erase(i, 1);
						i1++;
					}
				}
				else {
					if (d == 0) {
						if (s[i] == 'd') {
							//s.erase(i, 1);
							d++;
						}
					}
					else {
						if (i2 == 0) {
							if (s[i] == 'i') {
								//s.erase(i, 1);
								i2++;
							}
						}
					}
				}
			}
		}
	}
	if (h > 0 && e > 0 && i1 > 0 && d > 0 && i2 > 0)
		cout << "YES";
	else cout << "NO";

}


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

int main()
{
    char c;

    while (scanf("%c",&c)!=EOF){
        if (c=='h'){
            while (scanf("%c",&c)!=EOF){
                if (c=='e'){
                    while (scanf("%c",&c)!=EOF){
                        if (c=='i'){
                            while (scanf("%c",&c)!=EOF){
                                if (c=='d'){
                                    while (scanf("%c",&c)!=EOF){
                                        if (c=='i'){
                                            printf("YES");
                                            return 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    printf("NO");
}


#include <iostream>
#include <string>
using namespace std;
bool a[4] = {false, false, false, false};
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'h') {
			a[0] = true;
		} else if (s[i] == 'e' &&a[0]) {
			a[1] = true;
		} else if (s[i] == 'i' && a[1]  && !a[3]) {
			a[2] = true;
		} else if (s[i] == 'd' && a[2]) {
			a[3] = true;
		} else if (s[i] == 'i' && a[3]) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
bool a[4] = {false, false, false, false};
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'h') {
			a[0] = true;
		} else if (s[i] == 'e' &&a[0] == true) {
			a[1] = true;
		} else if (s[i] == 'i' && a[1] == true) {
			a[2] = true;
		} else if (s[i] == 'd' && a[2] == true) {
			a[3] = true;
		} else if (s[i] == 'i' && a[3] == true) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string s,p="heidi";
	int j=0;
	cin>>s;
	for(int i=0; i<s.size(); i++){
		if(s[i]==p[j]){
			j++;
			if(j==5) break;
		}
	}
	cout<<(j==5 ? "YES" : "NO");
}


#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
   char *s;
   s=(char*)malloc(sizeof(char)*2000);
   cin>>s;
   int n=strlen(s),c=0,m=0;
   s=(char*)realloc(s,sizeof(char)*(n+1));
   char r[6]="heidi";
   for(int i=0;i<5;i++)
   {
       for(int j=m;j<n;j++)
       {
           if(r[i]==s[j]){c++;m=j+1;break;}
       }
   }
   if(c==5){cout<<"YES";}
   else{cout<<"NO";}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	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>
using namespace std;
int main()
{
	string s;
	cin>>s;
	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>
using namespace std;

int main()
{
	setlocale(LC_ALL, "RUS");
	string s, s2 = { "heidi" };
	int u = 0;
	cin >> s;
	for (int i = 0; i < s.size() && u < 6; i++)
	{
		if (s[i] == s2[u])
			u++;
	}
	if (u == 5)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}


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

string x = "heidi";
int m = 5;
int result = 0;
void solve(string s1, string s2, int n)
{
    //cout << n << " " << m << endl;
    if (m == 0)
    {
        result = 1;
        return;
    }
    if (n == 0 && m != 0)
    {
        result = 0;
        return;
    }
    if (s1[n - 1] == s2[m - 1]) {
        m--;
        n--;
        solve(s1, s2, n);
    }
    else
    {
        n--;
        solve(s1, s2, n);
    }
}
int main() {
    string s;
    cin >> s;
    int n = s.length();
    solve(s, x, n);
    if(result == 1)
        cout <<"YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <utility>
#include <map>
#include <queue>
#include <iterator>
using namespace std;

int main(){
	string substr = "heidi";
	int cur = 0;
	string str; cin >> str;
	int n = str.length();
	for (int i = 0; i < n && cur < 5; i++) {
		if (str[i] == substr[cur]) cur++;
	}
	if (cur == 5) printf("YES");
	else printf("NO");
	return 0;
}


//#include "stdafx.h"
#include<iostream>
#include<string>
#include<Windows.h>
using namespace std;
int main()
{
	string s,target="heidi";
	cin >> s;
	int pos = 0;
	for (auto c : s){
		if (c == target[pos])pos++;
		if (pos == target.length())break;
	}
	cout << (pos == target.length() ? "YES\n" : "NO\n");
	//system("pause");
	return 0;
}
//Compiler nadrm :|
//Khaste shoddddddm :((
//bia dg :(


#include<iostream>
#include<string>
void main()
{
	char s[1001];
	std::cin >> s;
	int len = strlen(s),pos;
	int h = 0, e = 0, i = 0, d = 0, i2 = 0;

	for (int k = 0; k < len; k++)
	{
		if (s[k] == 'h')
		{
			h++;
			pos = k + 1;
			break;

		}

	}
	for (int k = pos; k < len; k++)
	{
		if (s[k] == 'e')
		{
			e++;
			pos = k + 1;
			break;
		}

	}
	for (int k = pos; k < len; k++)
	{
		if (s[k] == 'i')
		{
			i++;
			pos = k+ 1;
			break;
		}

	}
	for (int k= pos; k < len; k++)
	{
		if (s[k] == 'd')
		{
			d++;
			pos = k + 1;
			break;
		}

	}
	for (int k = pos; k < len; k++)
	{
		if (s[k] == 'i')
		{
			i2++;
			pos = k + 1;
			break;
		}

	}
	if (h != 0 && e != 0 && i != 0 && d != 0 && i2 != 0)
		std::cout << "YES";
	else
		std::cout << "NO";
}


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

int main()
{
    string A;
    cin>>A;
    for(int i=0;i<A.length();i++)
    {
        if(A[i]=='h')
        {
            for(int j=i;j<A.length();j++)
            {
                if(A[i]=='e')
               {
                   for(int i=0;i<A.length();i++)
                    {
                        if(A[i]=='i')
                        {
                            for(int i=0;i<A.length();i++)
                            {
                                if(A[i]=='d')
                                {
                                    for(int i=0;i<A.length();i++)
                                    {
                                       if(A[i]=='i')
                                        {
                                            cout<<"YES";
                                            return 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<"NO";
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    string A,B="heidi";
    cin>>A;
    for(int i=0,j=0;j<5 && i<A.length();i++)
    {
        if(A[i]==B[j])
            j++;
        if(j==5)
        {
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    string A;
    cin>>A;
    cout<<(A.find('h') && A.find('e') && A.find('i') && A.find('d') && A.find('i')?"NO":"YSE");
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int j=0;
    string A,B="heidi";
    cin>>A;
    for(int i=0;j<5 && i<A.length();i++)
    {
        if(A[i]==B[j])
            j++;
    }
    cout<<(j==5?"NO":"YES");
    return 0;
}


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

int main()
{
    string A,B="heidi",j=0;
    cin>>A;
    for(int i=0;j<5 && i<A.length();i++)
    {
        if(A[i]==B[j])
            j++;
    }
    cout<<(j==5?"NO":"YES");
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int j=0;
    string A,B="heidi";
    cin>>A;
    for(int i=0;j<5 && i<A.length();i++)
    {
        if(A[i]==B[j])
            j++;
    }
    cout<<(j==5?"YES":"NO");
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <random>
using namespace std;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    string t = "heidi";

    int j = 0;
    for (int i = 0; i < s.size(); i++) {
        if (j < t.size() && s[i] == t[j])
            j++;
    }

    cout << (j == t.size() ? "YES" : "NO");
}


#include <iostream>
#include <stack>
#include <string>

using namespace std;
string a="heidi";
int main(void)
{
	int now=0;
	string tmp;
	cin >> tmp;
	for(int e=0;e<tmp.size();e++)
	{
		if(tmp[e]==a[now])
		{
			now++;
			if(now==a.size())
			{
				cout << "YES";
				return 0;
			}
		}
	}
	cout << "NO";
}


#include <iostream>
#include <string>

using namespace std;

int main() {
	string s, pattern="heidi";
	cin >> s;
	bool flag = false;
	int pos=-1, lastpos=0;
	for (int i = 0; i < pattern.length(); i++)
	{
		pos = s.find(pattern[i], pos+1);

		if (pos < lastpos) {
			cout << "NO";
			flag = true;
			break;
		}
		lastpos = pos;
	}
	if (!flag)
		cout << "YES";
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s.find("heidi") != -1)
		cout << "NO";
	else
		cout << "YES";
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	int r = s.find("heidi", 0);
	if (r > 0)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}


//http://codeforces.com/problemset/problem/802/G
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	string s;
	cin >> s;
	vector<bool> heidi(5, false);
	for (int i = 0; i < s.size(); i++)
	{
		if (!heidi[0])
		{
			if(s[i] == 'h')
				heidi[0] = true;
		}
		else if(!heidi[1])
		{
			if (s[i] == 'e')
				heidi[1] = true;
		}
		else if (!heidi[2])
		{
			if (s[i] == 'i')
				heidi[2] = true;
		}
		else if (!heidi[3])
		{
			if (s[i] == 'd')
				heidi[3] = true;
		}
		else if (!heidi[4])
		{
			if (s[i] = 'i')
				heidi[4] = true;
		}
		if (heidi[4])
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


//http://codeforces.com/problemset/problem/802/G
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	string s;
	cin >> s;
	vector<bool> heidi(5, false);
	for (int i = 0; i < s.size(); i++)
	{
		if (!heidi[0])
		{
			if(s[i] == 'h')
				heidi[0] = true;
		}
		else if(!heidi[1])
		{
			if (s[i] == 'e')
				heidi[1] = true;
		}
		else if (!heidi[2])
		{
			if (s[i] == 'i')
				heidi[2] = true;
		}
		else if (!heidi[3])
		{
			if (s[i] == 'd')
				heidi[3] = true;
		}
		else if (!heidi[4])
		{
			if (s[i] == 'i')
				heidi[4] = true;
		}
		if (heidi[4])
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <stdio.h>
#include <set>
#include <algorithm>
#include <string.h>
#include <assert.h>
#include <time.h>
#include <string>
#include <queue>
#include <random>
#include <map>
#include <numeric>
using namespace std;
typedef long long li;
#define mp make_pair
#define sz(a) (int)a.size()
const int N = 1e5 + 5;
const int M = 11;
const int K = 10;

map<pair<int, int>, int> r;

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

void solve() {

	string s;
	cin >> s;
	string t = "heidi";

	int j = 0;
	for (int i = 0; i < s.length(); i++) {
		if (j < t.length() && s[i] == t[j])
			j++;
	}
	if (j >= (int)t.length())
		cout << "YES";
	else
		cout << "NO";
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <crtdbg.h>
#include <ctype.h>
#include <math.h>

int main(void)
{
	char s1[1100], s2[1100], check = 0, n = 0;
	gets(s1);
	for (int i = 0; i < strlen(s1); i++)
	{
		if (s1[i] == 'h' || s1[i] == 'e' || s1[i] == 'i' || s1[i] == 'd')
		{
			s2[n] = s1[i];
			n++;
		}
	}
	s2[n] = 0;
	for (int i = 0; i < n - 4; i++)
	{
		if (s2[i] == 'h' && s2[i + 1] == 'e' && s2[i + 2] == 'i' && s2[i + 3] == 'd' && s2[i + 4] == 'i')
		{
			check = 1;
			break;
		}
	}
	if (check == 0)
	{
		printf("NO\n");
	}
	else
	{
		printf("YES\n");
	}
	return 0;
}


#include <iostream>
#include<string>

using namespace std;
int main(){
      string p="heidi",s;
      int n,num=0;
      cin>>s;
      if (s=="heidi")
      num++;
      for (n=0;ns.length();n++){
            if (s[n]==p[num])
            num++;
      }
      if (num==5)
      cout<<"YES";
      else cout<<"NO";
      return 0;
}


#include<iostream>
#include<string>

using namespace std;

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

}


#include<iostream>
#include<string>

using namespace std;

int main() {
	string s,p="";
	int d=0;
	cin>>s;
	if (s=="heidi")
		p="no";
	else for (int i=0;i<s.length();i++){
		if (s[i]!='h' && s[i] !='e' && s[i] !='i' && s[i] !='d')
			s[i]='*';
		else {
			p[d]=s[i]; d++;
		}
	}
	if (p=="heidi")
		cout<<"YES";
	else cout<<"NO";

return 0;


#include <iostream>
#include<string>

using namespace std;
int main(){
      string p="heidi",s;
      int n,num=0;
      cin>>s;
      if (s=="heidi")
      num++;
      for (n=0;s.length();n++){
            if (s[n]==p[num])
            num++;
      }
      if (num==5)
      cout<<"YES";
      else cout<<"NO";
      return 0;
}


#include <iostream>
#include<string>

using namespace std;
int main(){
      string p="heidi",s;
      int n,num=0;
      cin>>s;
      if (s=="heidi")
      num++;
      for (n=0;n<s.length();n++){
            if (s[n]==p[num])
            num++;
      }
      if (num==5)
      cout<<"YES";
      else cout<<"NO";
      return 0;
}


#include<iostream>
#include<string>

using namespace std;
int main(){
      string p="heidi",s;
      int n,num=0;
      cin>>s;
      if (s=="heidi")
      num++;
      for (n=0;s.length();n++){
            if (s[n]==p[num])
            num++;
      }
      if (num==5)
      cout<<"YES";
      else cout<<"NO";
      return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int pos = 0 , newpos = 0;
    string text;
    cin >> text;
    newpos = text.find('h',pos);
    if (newpos != string::npos){
        newpos = text.find('e',newpos+1);
        if (newpos != string::npos){
            newpos = text.find('i',newpos+1);
            if(newpos != string::npos){
                newpos = text.find('d',newpos+1);
                if(newpos != string::npos){
                    newpos = text.find('i',newpos+1);
                    if(newpos != string::npos){
                    cout << "YES";
                    }else{
                    cout << "NO";}
                }else{
                cout << "NO";}
            }else{
            cout << "NO";}
        }else{
            cout << "NO";}
    }else{
        cout << "NO";}
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int pos = 0 , newpos = 0;
    string text;
    cin >> text;
    newpos = text.find('h',pos);
    if(text.length()<=100){
        if (newpos != string::npos){
            newpos = text.find('e',newpos+1);
            if (newpos != string::npos){
                newpos = text.find('i',newpos+1);
                if(newpos != string::npos){
                    newpos = text.find('d',newpos+1);
                    if(newpos != string::npos){
                        newpos = text.find('i',newpos+1);
                        cout << "YES";
                    }else{
                    cout << "NO";}
                }else{
                cout << "NO";}
            }else{
                cout << "NO";}
        }else{
            cout << "NO";}
    }else{
        cout << "NO";
    }
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int pos = 0 , newpos = 0;
    string text;
    cin >> text;
    newpos = text.find('h',pos);
    if(text.length()<=1000){
        if (newpos != string::npos){
            newpos = text.find('e',newpos+1);
            if (newpos != string::npos){
                newpos = text.find('i',newpos+1);
                if(newpos != string::npos){
                    newpos = text.find('d',newpos+1);
                    if(newpos != string::npos){
                        newpos = text.find('i',newpos+1);
                        cout << "YES";
                    }else{
                    cout << "NO";}
                }else{
                cout << "NO";}
            }else{
                cout << "NO";}
        }else{
            cout << "NO";}
    }else{
        cout << "NO";
    }
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int pos = 0 , i = 0;
    string text;
    char letter[5] = {'h','e','i','d','i'};
    cin >> text;

    while(true){
        pos = text.find(letter[i],pos);
        if(pos == string::npos){
            cout << "NO";
            break;
        }else{
            i++;
            pos++;
            if(i == 5){
                cout << "YES";
                break;
            }

        }

    }
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int pos = 0 , newpos = 0;
    string text;
    cin >> text;
    newpos = text.find('h',pos);
    if (newpos != string::npos){
        newpos = text.find('e',newpos+1);
        if (newpos != string::npos){
            newpos = text.find('i',newpos+1);
            if(newpos != string::npos){
                newpos = text.find('d',newpos+1);
                if(newpos != string::npos){
                    newpos = text.find('i',newpos+1);
                    cout << "YES";
                }else{
                cout << "NO";}

            }else{
            cout << "NO";}
        }else{
            cout << "NO";}
    }else{
        cout << "NO";}
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int pos = 0 , newpos = 0;
    string text;
    cin >> text;
    newpos = text.find('h',pos);
    if (newpos != string::npos){
        newpos = text.find('e',newpos+1);
        if (newpos != string::npos){
            newpos = text.find('i',newpos+1);
            if(newpos != string::npos){
                newpos = text.find('d',newpos+1);
                if(newpos != string::npos){
                    newpos = text.find('i',newpos+1);
                    cout << "yes";
                }else{
                cout << "no";}
            }else{
            cout << "no";}
        }else{
            cout << "no";}
    }else{
        cout << "no";}
}


#include <iostream>
#include <string>
using namespace std;
int main()
{
    int pos = 0 , newpos = 0;
    string text;
    cin >> text;
    newpos = text.find('h',pos);
    if (newpos != string::npos){
        newpos = text.find('e',newpos+1);
        if (newpos != string::npos){
            newpos = text.find('i',newpos+1);
            if(newpos != string::npos){
                newpos = text.find('d',newpos+1);
                if(newpos != string::npos){
                    newpos = text.find('i',newpos+1);
                    cout << "YES";
                }else{
                cout << "NO";}
            }else{
            cout << "NO";}
        }else{
            cout << "NO";}
    }else{
        cout << "NO";}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
using namespace std;

typedef long long int64;
typedef long long uint64;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("abc.txt", "r", stdin);
#else
#define o "bisector"
	//freopen(o".in", "r", stdin);
//	freopen(o".out", "w", stdout);
#endif
	string s;
	cin >> s;
	string s1 = "heidi";
	int k = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == s1[k]) k++;
		if (k == 5) break;
	}
	if (k == 5) cout << "YES" << endl;
	else cout << "NO" << endl;
	return	0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
using namespace std;

typedef long long int64;
typedef long long uint64;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("abc.txt", "r", stdin);
#else
#define o "bisector"
	//freopen(o".in", "r", stdin);
	//	freopen(o".out", "w", stdout);
#endif
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	set<int> s;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}
	int res = 0;
	for (int i = 0; i < n; ++i)
	{
		auto it1 = s.find(v[i]);
		if (it1 != s.end()) continue;
		for (auto it = s.begin(); it != s.end();)
		{
			bool f = true;
			int m = *it;
			for (int j = i; j < n; ++j)
			{
				if (v[j] == m)
				{
					f = false;
					break;
				}
			}
			//cout << f << endl;
			if (f)
			{
				s.erase(it);
				it = s.begin();
			}
			else  ++it;
		}
		if (s.size() < k)
		{
			s.insert(v[i]);
			res++;
			continue;
		}
		int z = 0;
		int b = 0;
		for (auto it = s.begin(); it != s.end(); ++it)
		{
			int m = *it;
			for (int j = i; j < n; ++j)
			{
				if (v[j] == m)
				{
					if (b < j)
					{
						b = j;
						z = m;
					}
					break;
				}
			}
		}
		s.erase(z);
		s.insert(v[i]);
		res++;
	}
	cout << res << endl;
	return	0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[6] = "heidi";
	char s[1002];
	gets(s);
	int len = strlen(s);
	int flag = 0;
	int i,j;
	int sum = 0;
	for(i = 0;i< 5;i++)
	{
		for(j = flag;j< len;j++)
		{
			if(s[j] == a[i])
			{
				//cout<<s[j]<<endl;
				flag = j+1;
				sum++;
				//cout<<sum<<endl;
				//cout<<flag<<endl;
				break;
			}
		}
	}
	//cout<<sum<<endl;
	if(sum == 5)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


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

int main()
{
    int n,m=0;
	char p[1000],q[]={'h','e','i','d','i'};
	do
	{
		m++;
	}while((p[m-1]=getchar())!='\n');
	for(m=0,n=0;m<strlen(p)-1;m++)
	{
		if(p[m]==q[n])
		    n++;
		if(n==5)
			break;
	}
	if(n==5)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


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

int main()
{
    int n,m;
	char p[1000],q[]={'h','e','i','d','i'};
	gets(p);
	for(m=0,n=0;m<strlen(p);m++)
	{
		if(p[m]==q[n])
		    n++;
		if(n==5)
			break;
	}
	if(n==5)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


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

int main()
{
    int n,m=0;
	char p[10000],q[]={'h','e','i','d','i'};
	do
	{
		m++;
	}while((p[m-1]=getchar())!='\n');
	for(m=0,n=0;m<strlen(p)-1;m++)
	{
		if(p[m]==q[n])
		    n++;
		if(n==5)
			break;
	}
	if(n==5)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


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

int main()
{
    int n,m,i=0;
	char p[1000],q[]={'h','e','d'};
	gets(p);
	for(m=0,n=0;m<strlen(p);m++)
	{
		if(p[m]=='i'&&i<2)
			i++;
		if(p[m]==q[n])
			n++;
		if(n==3&&i==2)
			break;
	}
	if(n==3&&i==2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


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

int main()
{
    int n,m;
	char p[1000],q[]={'h','e','i','d','i'};
	gets(p);
	for(m=0,n=0;m<strlen(p);m++)
	{
		if(p[m]==q[n])
			n++;
		if(n==5)
			break;
	}
	if(n==5)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


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

int main()
{
    int n,m,i=0,j=0;
	char p[1000],q[]={'h','e','d'};
	gets(p);
	for(m=0,n=0;m<strlen(p);m++)
	{
		if(p[m]=='i'&&i<2)
			i++;
		while(n<3)
		{
			if(p[m]==q[n])
			    j++;
		    n++;
		}
		if(i==2&&n==3)
			break;
	}
	if(n==3&&i==2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>>

#include <vector>
#include <string>
#include <set>
#include <map>

#include <queue>
#include <stack>

using namespace std;

#define ABS(a) (((a) < (0)) ? (-(a)) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))

#define INF 1000000000

typedef long long int lint;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string s;
	string h = "heidi";
	cin >> s;

	int j = 0;

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

		if (j == 5)
		{
			cout << "YES";
			return 0;
		}
	}

	cout << "NO";

	return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str;
	getline(cin,str);
	int c=0;
	for (int i = 0; i < str.length(); i++)
	{
		if(str[i]=='h')
		{
			for (int j = i+1; j <str.length() ; j++)
			{
				if(str[j]=='e')
				{
					for (int k = j+1; k < str.length(); k++)
					{
						if(str[k]=='i')
						{
						for (int f = k+1; f < str.length(); f++)
				   	{
						if(str[f]=='d')
						{
						for (int e = f+1; e < str.length(); e++)
				   	{
						if(str[e]=='i')
						{
						c++;
						}
					}
						}
					}
						}
					}
				}
			}

		}
	}

	if(c==0)
		cout<<"NO";
	else
		cout<<"YES";

return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{

	string str;
	getline(cin,str);
	int c=0;
	for (int i = 0; i < str.length(); i++)
	{
		if(c!=0)
						{
						break;
						}

		if(str[i]=='h')
		{
			for (int j = i+1; j <str.length() ; j++)
			{
				if(c!=0)
						{
						break;
						}
				if(str[j]=='e')
				{
					for (int k = j+1; k < str.length(); k++)
					{
						if(c!=0)
						{
						break;
						}
						if(str[k]=='i')
						{
						for (int f = k+1; f < str.length(); f++)
				   	{
						if(c!=0)
						{
						break;
						}
						if(str[f]=='d')
						{
						for (int e = f+1; e < str.length(); e++)
				   	{
						if(str[e]=='i')
						{
						c++;
					break;
						}
					}
						}
					}
						}
					}
				}
			}

		}
	}

	if(c==0)
		cout<<"NO";
	else
		cout<<"YES";

	}

return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{

	string str;
	getline(cin,str);
	int c=0;
	for (int i = 0; i < str.length(); i++)
	{
		if(c!=0)
						{
						break;
						}

		if(str[i]=='h')
		{
			for (int j = i+1; j <str.length() ; j++)
			{
				if(c!=0)
						{
						break;
						}
				if(str[j]=='e')
				{
					for (int k = j+1; k < str.length(); k++)
					{
						if(c!=0)
						{
						break;
						}
						if(str[k]=='i')
						{
						for (int f = k+1; f < str.length(); f++)
				   	{
						if(c!=0)
						{
						break;
						}
						if(str[f]=='d')
						{
						for (int e = f+1; e < str.length(); e++)
				   	{
						if(str[e]=='i')
						{
						c++;
					break;
						}
					}
						}
					}
						}
					}
				}
			}

		}
	}

	if(c==0)
		cout<<"NO";
	else
		cout<<"YES";

return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{

	string str;
	getline(cin,str);
	int c=0;
	int u=0;
	for (int i = 0; i < str.length(); i++)
	{
		if(c!=0||u!=0)
						{
						break;
						}

		if(str[i]=='h')
		{
			for (int j = i+1; j <str.length() ; j++)
			{
				if(c!=0||u!=0)
						{
						break;
						}
				if(str[j]=='e')
				{
					for (int k = j+1; k < str.length(); k++)
					{
						if(c!=0||u!=0)
						{
						break;
						}
						if(str[k]=='i')
						{
						for (int f = k+1; f < str.length(); f++)
				   	{
						if(c!=0||u!=0)
						{
						break;
						}
						if(str[f]=='d')
						{
						for (int e = f+1; e < str.length(); e++)
				   	{
						if(str[e]=='i')
						{
						c++;
					break;
						}
						else
							u++;
					}
						}
					}
						}
					}
				}
			}

		}
	}

	if(c==0)
		cout<<"NO";
	else
		cout<<"YES";

return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{

	string str;
	getline(cin,str);
	int c=0;
	int u=0;
	for (int i = 0; i < str.length(); i++)
	{
		if(c!=0||u!=0)
						{
						break;
						}

		if(str[i]=='h')
		{
			for (int j = i+1; j <str.length() ; j++)
			{
				if(c!=0||u!=0)
						{
						break;
						}
				if(str[j]=='e')
				{
					for (int k = j+1; k < str.length(); k++)
					{
						if(c!=0||u!=0)
						{
						break;
						}
						if(str[k]=='i')
						{
						for (int f = k+1; f < str.length(); f++)
				   	{
						if(c!=0||u!=0)
						{
						break;
						}
						if(str[f]=='d')
						{
						for (int e = f+1; e < str.length(); e++)
				   	{
						if(str[e]=='i')
						{
						c++;
					break;
						}
						else
							u++;
					}
						}
		if(c==0||u==0)
						{
						break;
						}

						}
						}
		if(c==0||u==0)
						{
						break;
						}

					}
				}
			if(c==0||u==0)
						{
						break;
						}

			}

		}
	if(c==0||u==0)
						{
						break;
						}

	}

	if(c==0)
		cout<<"NO";
	else
		cout<<"YES";

return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	char arr[5]={'h','e','i','d','i'};
	string str;
	cin>>str;
	int j=0;
	int c=0;
	for (int i = 0; i < str.length(); i++)
	{
		if(str[i]==arr[j])
		{
		j++;
		c++;
		}
	}
	if(c==5)
		cout<<"YES";
	else
		cout<<"NO";
return 0;
}


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

	if (j == x.length())
		cout << "YES";
	else
		cout << "NO";

	return 0;
}


#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include <iterator>
#include<iomanip>
#include<vector>
#include<cmath>
#include <cstdio>
#include<queue>
#include<stack>
#include<list>
#include<stdio.h>
#include<set>
#include <functional>

#define mod 1000000007
#define mod2 30000000
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 2e9
#define pi 3.14159265359
#define eps  1e-9

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
int dx[] = {1 , 1 ,1 , 0 , 0  , -1 , -1  , -1  , 0 };
int dy[] = { -1 , 0  , 1 , 1 , -1 , 0 , 1 , -1 , 0 };
void boostIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
int main()
{
    string s ; cin >> s;
    string sear = "heidi" ; reverse(all(sear)) ;
    for(int i = 0 ; i < s.size() ; i++){
        if(s[i] == sear.back()){
            sear.pop_back() ;
            if(sear.empty()){
                cout << "YES" << endl ;
                return 0 ;
            }
        }
    }
    cout << "NO" << endl ;
}


#include <iostream>
#include <cstring>
#include <cmath>
#include <stdio.h>
#include <algorithm>
using namespace std;

int  main()
{
	char*mas = new char[1000];
	cin >> mas;
	int k = 0,i=0;
	int s = 0;
	char*mas1 = new char[6];
	mas1 = "heidi";
	char*x = mas;
	for (int i = 0; i < 5; ++i)
	{
		x = strchr(x, mas1[i]);
		if (x == NULL)
		{
			s = 1;
			break;
		}
	}

	if (s) cout << "NO";
	else cout << "YES";

	delete[] mas;

	system("pause");

	return 0;
}


#include <iostream>
#include <cstring>
#include <cmath>
#include <stdio.h>
#include <algorithm>
using namespace std;

int  main()
{
	char *mas = new char[1000];
	cin >> mas;
	int k = 0,i=0;
	int s = 0;
	char *mas1 = new char[6];
	mas1 = "heidi";
	char*x = mas;
	for (int i = 0; i < 5; ++i)
	{
		x = strchr(x, mas1[i]);
		if (x == NULL)
		{
			s = 1;
			break;
		}
	}
	//delete[] mas1;

	if (s) cout << "NO";
	else cout << "YES";

	delete[] mas;
	//

//	system("pause");

	return 0;
}


n = int(input())
seats = []
for i in range(n):
    seats.append(input().split("|"))
can = False
for s in seats:
    if s[0] =="OO":
        s = "++"
        can = True
        break
    elif s[1] == "OO":
        s[1] = "++"
        can = True
        break
if can:
    print("YES")
    for i in range(n):
        print("|".join(seats[i]))
else:
    print("NO")


n = int(input())
seats = []
for i in range(n):
    seats.append(input().split("|"))
can = False

for s in seats:
    if s[0] =="OO":
        s[0] = "++"
        can = True
        break
    elif s[1] == "OO":
        s[1] = "++"
        can = True
        break
if can:
    print("YES")
    print(seats)
else:
    print("NO")


n = int(input())
seats = []
for i in range(n):
    seats.append(input())
can = False
rows = seats.slpit("|")
for s in rows:
    if s[0] =="OO":
        s = "++"
        can = True
        break
    elif s[1] == "OO":
        s[1] = "++"
        can = True
        break
if can:
    print("YES")
    for i in range(n):
        print(rows[n].join("|"))
else:
    print("NO")


n = int(input())
seats = []
for i in range(n):
    seats.append(input().split("|"))
can = False
for i in range(len(seats)):
    if seats[i][0] =="OO":
        seats[i][0] = "++"
        can = True
        break
    elif seats[i][1] == "OO":
        seats[i][1] = "++"
        can = True
        break
if can:
    print("YES")
    for i in range(n):
        print("|".join(seats[i]))
else:
    print("NO")


import sys
input()
seats = sys.stdin.read()
print("NO" if seats.find('OO') < 0 else "YES\n" + seats.replace('OO', '++', 1))


import sys
input()
seats = sys.stdin.read()
index = seats.find('OO')
if index >= 0:
    print("YES\n" + seats[:index] + '++' + seats[index + 2:])
else:
    print('NO')


import sys
seats = sys.stdin.read()
print("NO" if seats.find('OO') < 0 else "YES" + seats.replace('OO', '++', 1)[seats.index('\n'):])


import sys, re
input()
seats = sys.stdin.read()
index = seats.find('OO')
if index >= 0:
    print("YES\n" + seats.replace('OO', '++', 1))
else:
    print('NO')


# UTF-8
# Python 3

"""
=========================================
Author: Johann Gordillo
=========================================
CodeChef problems
=========================================
"""

def main():
    """Main method."""
    n = int(input())
    z = -1
    finished = False
    for _ in range(n):
        r = list(input())
        flag = False
        for i in range(5):
            if r[i] == 'O':
                if flag == True:
                    if not finished:
                        finished = True
                        print("YES")
                        r[i] = '+'
                        r[z] = '+'
                    break

                else:
                    flag = True
                    z = i
        print(''.join(r))

if __name__ == "__main__":
    main()


# UTF-8
# Python 3

"""
=========================================
Author: Johann Gordillo
=========================================
CodeChef problems
=========================================
"""

def main():
    """Main method."""
    n = int(input())
    z = -1
    finished = False

    rows = []
    for _ in range(n):
        r = list(input())
        flag = False

        for i in range(5):
            if r[i] == 'O':
                if flag == True and finished == False:
                    finished = True
                    r[i] = '+'
                    r[z] = '+'
                flag = True
                z = i

            else:
                flag = False

        rows.append(''.join(r))

    if finished:
        print("YES")
        for r in rows:
            print(r)
    else:
        print("NO")

if __name__ == "__main__":
    main()


# UTF-8
# Python 3

"""
=========================================
Author: Johann Gordillo
=========================================
CodeChef problems
=========================================
"""

def main():
    """Main method."""
    n = int(input())
    z = -1
    finished = False

    rows = []
    for _ in range(n):
        r = list(input())
        flag = False
        for i in range(5):
            if r[i] == 'O':
                if flag == True:
                    if not finished:
                        finished = True
                        r[i] = '+'
                        r[z] = '+'
                    break

                else:
                    flag = True
                    z = i
        rows.append(''.join(r))

    if finished:
        print("YES")
        for r in rows:
            print r
    else:
        print("NO")

if __name__ == "__main__":
    main()


# UTF-8
# Python 3

"""
=========================================
Author: Johann Gordillo
=========================================
CodeChef problems
=========================================
"""

def main():
    """Main method."""
    n = int(input())
    z = -1
    finished = False

    rows = []
    for _ in range(n):
        r = list(input())
        flag = False

        for i in range(5):
            if r[i] == 'O':
                if flag == True:
                    r[i] = '+'
                    r[z] = '+'
                    finished = True
                flag = True
                z = i

            else:
                flag = False

        rows.append(''.join(r))

    if finished:
        print("YES")
        for r in rows:
            print(r)
    else:
        print("NO")

if __name__ == "__main__":
    main()


# UTF-8
# Python 3

"""
=========================================
Author: Johann Gordillo
=========================================
CodeChef problems
=========================================
"""

def main():
    """Main method."""
    n = int(input())
    z = -1
    finished = False

    rows = []
    for _ in range(n):
        r = list(input())
        flag = False
        for i in range(5):
            if r[i] == 'O':
                if flag == True:
                    if not finished:
                        finished = True
                        r[i] = '+'
                        r[z] = '+'
                    break

                else:
                    flag = True
                    z = i

        rows.append(''.join(r))

    if finished:
        print("YES")
        for r in rows:
            print(r)
    else:
        print("NO")

if __name__ == "__main__":
    main()


n=int(input())
seatarr=list()
flag=0
for i in range(n):
    row=input()
    if row[:2]=='OO' and flag==0:
        x='++'+row[2:]
        seatarr.append(x)
        print('YES')
        flag=1
    elif row[4:]=='OO' and flag==0:
        x=row[:4]+'++'
        seatarr.append(x)
        print('YES')
        flag==1
    else:
        seatarr.append(row)
for j in seatarr:
    print(j)


n=int(input())
seatarr=list()
flag=0
for i in range(n):
    row=input()
    if row[:2]=='OO' and flag==0:
        x='++'+row[2:]
        seatarr.append(x)
        flag=1
    elif row[4:]=='OO' and flag==0:
        x=row[:4]+'++'
        seatarr.append(x)
        flag==1
    else:
        seatarr.append(row)
if flag==1:
    print('YES')
    for j in seatarr:
        print(j)
else:
    print('NO')


n=int(input())
seatarr=list()
flag=0
for i in range(n):
    row=input()
    if row[:2]=='OO' and flag==0:
        x='++'+row[2:]
        seatarr.append(x)
        flag=1
    elif row[3:]=='OO' and flag==0:
        x=row[:4]+'++'
        seatarr.append(x)
        flag==1
    else:
        seatarr.append(row)
if flag==1:
    print('YES')
    for j in seatarr:
        print(j)
else:
    print('NO')


n=int(input())
seatarr=list()
flag=0
for i in range(n):
    row=input()
    if row[:2]=='OO' and flag==0:
        x='++'+row[2:]
        seatarr.append(x)
        flag=1
    elif row[3:]=='OO' and flag==0:
        x=row[:3]+'++'
        seatarr.append(x)
        flag=1
    else:
        seatarr.append(row)
if flag==1:
    print('YES')
    for j in seatarr:
        print(j)
else:
    print('NO')


n = int(input())
a = []
k = 0

for i in range(n):
    seat = input()
    if k == 0 and 'OO' in seat:
        a.append(seat.replace('OO', '++'))
        k = 1
    else:
        a.append(seat)

if k == 1:
    print('NO')
else:
    print('YES')
    for element in a:
        print(element)


n = int(input())
a = []
k = 0

for i in range(n):
    seat = input()
    if k == 0 and 'OO' in seat:
        a.append(seat.replace('OO', '++'))
        k = 1
    else:
        a.append(seat)

for element in a:
    print(element)


n = int(input())
a = []
k = 0

for i in range(n):
    seat = input()
    if k == 0 and 'OO' in seat:
        a.append(seat.replace('OO', '++', 1))
        k = 1
    else:
        a.append(seat)

if k == 0:
    print('NO')
else:
    print('YES')
    for element in a:
        print(element)


n = int(input())
a = []
k = 0

for i in range(n):
    seat = input()
    if k == 0 and 'OO' in seat:
        a.append(seat.replace('OO', '++'))
        k = 1
    else:
        a.append(seat)

if k == 0:
    print('NO')
else:
    print('YES')
    for element in a:
        print(element)


n = int(input())
flag = "NO"
result = []
for i in range(n):
  row = input().split('|')
  if row[0] == 'OO' and flag == 'NO':
    row[0] = '++'
    flag = "YES"
  elif row[1] == 'OO' and flag == 'NO':
    row[1] = '++'
  result.append(row[0]+'|'+row[1])
print(flag)
if(flag=='YES'):
  for i in result:
    print(*i)


n = int(input())
flag = "NO"
result = []
for i in range(n):
  row = input().split('|')
  if row[0] == 'OO' and flag == 'NO':
    row[0] = '++'
    flag = "YES"
  elif row[1] == 'OO' and flag == 'NO':
    row[1] = '++'
  result.append(row[0]+'|'+row[1])
print(flag)
if(flag=='YES'):
  for i in result:
    for y in i:
      print(y,end='')
    print()


n = int(input())
flag = "NO"
result = []
for i in range(n):
  row = input().split('|')
  if row[0] == 'OO' and flag == 'NO':
    row[0] = '++'
    flag = "YES"
  if row[1] == 'OO' and flag == 'NO':
    row[1] = '++'
  result.append(row[0]+'|'+row[1])
print(flag)
if(flag=='YES'):
  for i in result:
    for y in i:
      print(y,end='')
    print()


n = int(input())
flag = "NO"
result = []
for i in range(n):
  row = input().split('|')
  if row[0] == 'OO' and flag == 'NO':
    row[0] = '++'
    flag = "YES"
  if row[1] == 'OO' and flag == 'NO':
    row[1] = '++'
    flag = "YES"
  result.append(row[0]+'|'+row[1])
print(flag)
if(flag=='YES'):
  for i in result:
    for y in i:
      print(y,end='')
    print()


s = '\n'.join([input() for i in range(int(input()))])
pos = s.find('OO')
print(pos)
if pos >= 0:
	print("YES\n"+s[:x]+"++"+s[x+2:])
else:
	print("NO\n")


s = '\n'.join([input() for i in range(int(input()))])
pos = s.find('OO')
if pos > 0:
	print("Yes\n"+s[:x]+"++"+s[x+2:])
else:
	print("No\n")


s = '\n'.join([input() for i in range(int(input()))])
pos = s.find('OO')
if pos >= 0:
	print("YES\n"+s[:x]+"++"+s[x+2:])
else:
	print("NO\n")


s = '\n'.join([input() for i in range(int(input()))])
pos = s.find('OO')
if pos >= 0:
	print("YES\n"+s[:pos]+"++"+s[pos+2:])
else:
	print("NO\n")


b=[]
flag=0
t=int(input().strip())
for i in range(t):
  x=input().strip()
  if 'OO' in x and not flag:
    x=x[:x.index('OO')]+ '++' + x[x.index('OO')+2:]
    flag=1
  b.append(x)
if flag:
  print('YES')
  for i in b:
    print(i)
else:
  print('NO')


b=[]
flag=0
t=int(input().strip())
for i in range(t):
  x=input().strip()
  if 'OO' in x and not flag:
    x=x[:x.index('OO')]+ '++' + x[x.index('OO')+2:]
  t.append(x)
if flag:
  print('YES')
  for i in x:
    print(i)
else:
  print('NO')


b=[]
flag=0
t=int(input().strip())
for i in range(t):
  x=input().strip()
  if 'OO' in x and not flag:
    x=x[:x.index('OO')]+ '++' + x[x.index('OO')+2:]
  b.append(x)
if flag:
  print('YES')
  for i in b:
    print(i)
else:
  print('NO')


n = int(input())
s = ''

for i in range(n):
    x = input()
    if s.count('++')>0 or x.count('OO') == 0:
        s += x + '\n'
    else:
        x = x.replace('OO', '++')
        s += x + '\n'
if s.count('++')>0:
    print("YES")
    print(s)
else:
    print('NO')


n = int(input())
s = ''

for i in range(n):
    x = input()
    if '++' in s or 'OO' not in x:
        s += '\n' + x
    else:
        x.replace('OO', '++')
        s += '\n' + x
print(s)
if '++' in s:
    print("YES")
    print(s)
else:
    print('NO')


n = int(input())
s = ''

for i in range(n):
    x = input()
    if s.count('++')>0 or x.count('OO') == 0:
        s += x + '\n'
    else:
        x = x.replace('OO', '++', 1)
        s += x + '\n'
if s.count('++')>0:
    print("YES")
    print(s)
else:
    print('NO')


n = int(input())
s = ''

for i in range(n):
    x = input()
    if s.count('++')>0 or x.count('OO') == 0:
        s += x + '\n'
    else:
        x.replace('OO', '++')
        s += x + '\n'
if s.count('++')>0:
    print("YES")
    print(s)
else:
    print('NO')


n = int(input())
s = ''

for i in range(n):
    x = input()
    if '++' in s or 'OO' not in x:
        s += '\n' + x
    else:
        x.replace('OO', '++')
        s += '\n' + x
if '++' in s:
    print("YES")
    print(s)
else:
    print('NO')


n = int(input())
buf = []
res = False
for _ in range(n):
    buf.append(input())
    if not res and (buf[-1].startswith('OO') or buf[-1].endswith('OO')):
        buf[-1] = buf[-1].replace('OO', '++', 1)
        res = True

print('YES\n' + '\n'.join(buf) if res else 'NO')


s = '\n'.join([input() for _ in range(int(input()))]).replace('OO', '++', 1)
print('YES\n' + s if s.find('++') >= 0 else 'NO')


n = int(input())
buf = []
res = False
for _ in range(n):
    s =input()
    if not res:
        if s.startswith('OO'):
            s = '++' + s[2:]
            res = True
        elif s.endswith('OO'):
            s = s[:3] + '++'
            res = True
    buf.append(s)

print('YES' if res else 'NO')
print('\n'.join(buf))


n = int(input())
buf = []
res = False
for _ in range(n):
    s = input()
    if not res:
        if s.startswith('OO'):
            s = '++' + s[2:]
            res = True
        elif s.endswith('OO'):
            s = s[:3] + '++'
            res = True
    buf.append(s)

print('YES\n' + '\n'.join(buf) if res else 'NO')


n = int(input())
b = 0
c = []
for i in range(n):
    a = input()
    if a[0] == 'O' and a[1] == 'O' and b == 0:
        b = 1
        c.append(a.replace('O', '+', 2))
    elif a[-1] == 'O' and a[-2] == 'O' and b == 0:
        b = 1
        #a = a[::-1].replace('O', '+', 2)
        c.append(a[::-1].replace('O', '+', 2)[::-1])
    else:
        c.append(a)
if b == 1:
    print('YES')
    for i in c:
        print(i)
else:
    print('NO')


n = int(input())
b = 0
c = []
for i in range(n):
    a = input()
    if a[0] == 'O' and a[1] == 'O' and b == 0:
        b = 1
        c.append(a.replace('O', '+', 2))
    elif a[-1] == 'O' and a[-2] == 'O' and b == 0:
        b = 1
        c.append(a.replace('O', '+', 2))
    else:
        c.append(a)
if b == 1:
    print('YES')
    for i in c:
        print(i)
else:
    print('NO')


n = int(input())
b = 0
c = ''
f = ''
for i in range(n):
    a = input()
    c = c + a
x = 0
for i in range(len(c) // 5):
    if c[x:(x + 3)] == 'oo' and b <= 0:
        d = c[x:(x + 5)]
        d = d.replace('o', '+', 2)
        b = b + 1
        x = x + 5
        f = f + d
    elif c[(x + 3):(x + 5)] == 'oo' and b <= 0:
        d = c[x:(x + 5)]
        d = d[::-1]
        d = d.replace('o', '+', 2)
        d = d[::-1]
        b = b + 1
        x = x + 5
        f = f + d
    else:
        f = f + c[x:(x + 5)]
        x = x + 5
if '++' in f:
    print('YES')
    z = 0
    for i in range(len(f) // 5):
        g = f[z:z + 5]
        print(g)
        z = z + 5
else:
    print('NO')
    z = 0
    for i in range(len(f) // 5):
        g = f[z:z + 5]
        print(g)
        z = z + 5


n = int(input())
b = 0
c = ''
f = ''
for i in range(n):
    a = input()
    c = c + a
x = 0
for i in range(len(c) // 5):
    if c[x:(x + 3)] == 'OO' and b <= 0:
        d = c[x:(x + 5)]
        d = d.replace('O', '+', 2)
        b = b + 1
        x = x + 5
        f = f + d
    elif c[(x + 3):(x + 5)] == 'OO' and b <= 0:
        d = c[x:(x + 5)]
        d = d[::-1]
        d = d.replace('O', '+', 2)
        d = d[::-1]
        b = b + 1
        x = x + 5
        f = f + d
    else:
        f = f + c[x:(x + 5)]
        x = x + 5
if '++' in f:
    print('YES')
    z = 0
    for i in range(len(f) // 5):
        g = f[z:z + 5]
        print(g)
        z = z + 5
else:
    print('NO')
    z = 0
    for i in range(len(f) // 5):
        g = f[z:z + 5]
        print(g)
        z = z + 5


n = int(input())
b = 0
c = ''
f = ''
for i in range(n):
    a = input()
    c = c + a
x = 0
for i in range(len(c) // 5):
    if c[x:(x + 3)] == 'oo' and b <= 0:
        d = c[x:(x + 5)]
        d = d.replace('o', '+', 2)
        b = b + 1
        x = x + 5
        f = f + d
    elif c[(x + 3):(x + 5)] == 'oo' and b <= 0:
        d = c[x:(x + 5)]
        d = d[::-1]
        d = d.replace('o', '+', 2)
        d = d[::-1]
        b = b + 1
        x = x + 5
        f = f + d
    else:
        f = f + c[x:(x + 5)]
        x = x + 5
print(f)
if '++' in f:
    print('YES')
    z = 0
    for i in range(len(f) // 5):
        g = f[z:z + 5]
        print(g)
        z = z + 5
else:
    print('NO')
    z = 0
    for i in range(len(f) // 5):
        g = f[z:z + 5]
        print(g)
        z = z + 5


a, d, v = int(input()), [], False
for i in range(a):
	d.append(input())
	if (not v) and d[-1][:2]=='OO':
		d[-1] = '++'+d[-1][2:]
		v = True
	elif (not v) and d[-1][3]=='OO':
		d[-1] = d[-1][3]+'++'
if v:
	print('YES')
	for i in d:
		print(i)
else:
	print('NO')


a, d, v = int(input()), [], False
for i in range(a):
	d.append(input())
	if (not v) and d[-1][:2]=='OO':
		d[-1] = '++'+d[-1][:2]
		v = True
	elif (not v) and d[-1][3:]=='OO':
		d[-1] = d[-1][3:]+'++'
if v:
	print('YES')
	for i in d:
		print(i)
else:
	print('NO')


a, d, v = int(input()), [], False
for i in range(a):
	d.append(input())
	if (not v) and d[-1][:2]=='OO':
		d[-1] = '++'+d[-1][2:]
		v = True
	elif (not v) and d[-1][3:]=='OO':
		d[-1] = d[-1][3:]+'++'
if v:
	print('YES')
	for i in d:
		print(i)
else:
	print('NO')


a, d, v = int(input()), [], False
for i in range(a):
	d.append(input())
	if (not v) and d[-1][:2]=='OO':
		d[-1] = '++'+d[-1][3:]
		v = True
	elif (not v) and d[-1][3:]=='OO':
		d[-1] = d[-1][:2]+'++'
if v:
	print('YES')
	for i in d:
		print(i)
else:
	print('NO')


a, d, v = int(input()), [], False
for i in range(a):
	d.append(input())
	if (not v) and d[-1][:2]=='OO':
		d[-1] = '++'+d[-1][2:]
		v = True
	elif (not v) and d[-1][3:]=='OO':
		d[-1] = d[-1][:3]+'++'
		v = True
if v:
	print('YES')
	for i in d:
		print(i)
else:
	print('NO')


a, d, v = int(input()), [], False
for i in range(a):
	d.append(input())
	if (not v) and d[-1][:2]=='OO':
		d[-1] = '++'+d[-1][2:]
		v = True
	elif (not v) and d[-1][3:]=='OO':
		d[-1] = d[-1][:3]+'++'
if v:
	print('YES')
	for i in d:
		print(i)
else:
	print('NO')


n = int(input())
while n:
    val = input()
    print(val.replace("OO", "++", 2))
    n -= 1


n = int(input())
result = ''
count = 0

while n:
    val = input()
    if count == 0 and 'OO' in val:
        result += val.replace("OO", "++", 1) + '\n'
        count += 1
    else:
        result += val + '\n'
    n -= 1

print("YES\n"+result if '++' in result else "NO\n")


n = int(input())
result = ''
count = 0

while n:
    val = input()
    if count == 0 and 'OO' in val:
        result += val.replace("OO", "++") + '\n'
        count += 1
    else:
        result += val + '\n'
    n -= 1

print("YES\n"+result if '++' in result else "NO\n")


n = int(input())
result = ''

while n:
    val = input()
    result += val.replace("OO", "++", 2) + '\n'
    n -= 1

print("YES\n"+result if '++' in result else "NO\n"+result)


n = int(input())
result = ''
count = 0

while n:
    val = input()
    if count == 0:
        result += val.replace("OO", "++") + '\n'
        count += 1
    else:
        result += val + '\n'
    n -= 1

print("YES\n"+result if '++' in result else "NO\n"+result)


n = int(input())
result = ''
count = 0

while n:
    val = input()
    if count == 0:
        result += val.replace("OO", "++") + '\n'
        count += 1
    else:
        result += val + '\n'
    n -= 1

print("YES\n"+result if '++' in result else "NO\n")


n = int(input())

possible_seats = 0
outputted_yes = False

for i in range(n):
    row = input()
    number_of_possibilities = row.count('OO')
    if number_of_possibilities >= 1:
        if not outputted_yes:
            print('YES')
            row = row.replace('OO', '++')
            outputted_yes = True
        possible_seats += number_of_possibilities
    print(row)

if not outputted_yes:
    print('NO')


n = int(input())

output_yes = False

rows = []

for i in range(n):
    row = input()
    number_of_possibilities = row.count('OO')
    if number_of_possibilities >= 1:
        if not output_yes:
            row = row.replace('OO', '++')
        output_yes = True
    rows.append(row)

if not output_yes:
    print('NO')
else:
    print('YES')
    for row in rows:
        print(row)


n = int(input())

output_yes = False

rows = []

for i in range(n):
    row = input()
    if not output_yes:
        can_sit = bool(row.count('OO'))
        if can_sit:
            row = row.replace('OO', '++', 1)
            output_yes = True
    rows.append(row)

if output_yes:
    print('YES')
    for row in rows:
        print(row)
else:
    print('NO')


n = int(input())

output_yes = False

rows = []

for i in range(n):
    row = input()
    number_of_possibilities = row.count('OO')
    if not output_yes:
        if number_of_possibilities >= 1:
            row = row.replace('OO', '++')
            output_yes = True
    rows.append(row)

if not output_yes:
    print('NO')
else:
    print('YES')
    for row in rows:
        print(row)


n = int(input())

output_yes = False

rows = []

for i in range(n):
    row = input()
    if not output_yes:
        can_sit = bool(row.count('OO'))
        if can_sit:
            row = row.replace('OO', '++')
            output_yes = True
    rows.append(row)

if not output_yes:
    print('NO')
else:
    print('YES')
    for row in rows:
        print(row)


n = int(input())

output_yes = False

rows = []

for i in range(n):
    row = input()
    number_of_possibilities = row.count('OO')
    if number_of_possibilities >= 1:
        row = row.replace('OO', '++')
        output_yes = True
    rows.append(row)

if not output_yes:
    print('NO')
else:
    print('YES')

for row in rows:
    print(row)


n = int(input())

output_yes = False

rows = []

for i in range(n):
    row = input()
    number_of_possibilities = row.count('OO')
    if number_of_possibilities >= 1:
        if not output_yes:
            row = row.replace('OO', '++')
        output_yes = True
    rows.append(row)

if not output_yes:
    print('NO')
else:
    print('YES')

for row in rows:
    print(row)


n = int(input())

output_yes = False

rows = []

for i in range(n):
    row = input()
    if not output_yes:
        can_sit = bool(row.count('OO'))
        if can_sit:
            row = row.replace('OO', '++')
            output_yes = True
    rows.append(row)

if output_yes:
    print('YES')
    for row in rows:
        print(row)
else:
    print('NO')


n = int(input() )

a = []
for i in range(n):
    a.append(input().rstrip() )

for i in range(len(a) ):
    if a[i][:2] == 'OO':
        ok = True
        a[i] = ''.join(['++', a[i][2:] ])
        break
    elif a[i][3:] == 'OO':
        ok = True
        a[i] = ''.join([a[i][:3], '++'] )
        break

if ok:
    print('YES')
    for s in a: print(s)
else:
    print('NO')


import sys

s = sys.stdin.read()
i = s.find('OO')
print('NO' if i == -1 else 'YES\n' + s[:i] + '++' + s[i+2:])


import sys

s = sys.stdin.read().rstrip()
i = s.find('OO')
print('NO' if i == -1 else 'YES\n' + s[2:i] + '++' + s[i+2:])


import sys

input()
s = sys.stdin.read().rstrip()
i = s.find('OO')
print('NO' if i < 0 else 'YES\n' + s[:i] + '++' + s[i+2:])


n = int(input() )

a = []
for i in range(n):
    a.append(input().rstrip() )

ok = False
for i in range(len(a) ):
    if a[i][:2] == 'OO':
        ok = True
        a[i] = ''.join(['++', a[i][2:] ])
        break
    elif a[i][3:] == 'OO':
        ok = True
        a[i] = ''.join([a[i][:3], '++'] )
        break

if ok:
    print('YES')
    for s in a: print(s)
else:
    print('NO')


import sys

s = sys.stdin.read().rstrip()
i = s.find('OO')
print('NO' if i == -1 else 'YES\n' + s[:i] + '++' + s[i+2:])


x = int(input())
ins=[]
lp = 0
for i in range(x):
	x = input()
	x = list(x)
	ins.append(x)
for k in ins:
	if k[:2]==['O', 'O']:
		k.pop(0)
		k.pop(0)
		k.insert(0, "+")
		k.insert(0, "+")
		lp+=1
		break
	elif k[3:]==['O', 'O']:
		k.pop(3)
		k.pop(3)
		k.insert(4, "+")
		k.insert(4, "+")
		lp+=1
	else:
		pass
#print ("----------------")
if lp>0:
	print ("YES")
	for j in ins:
		print ("".join(j))
else:
	print ("NO")


x = int(input())
ins=[]
for i in range(x):
	x = input()
	x = list(x)
	ins.append(x)
for k in ins:
	if k[:2]==['O', 'O']:
		k.pop(0)
		k.pop(0)
		k.insert(0, "+")
		k.insert(0, "+")
		break
	else:
		pass
#print ("----------------")
for j in ins:
	print ("".join(j))


x = int(input())
ins=[]
for i in range(x):
	x = input()
	x = list(x)
	ins.append(x)
for k in ins:
	if k[:2]==['O', 'O']:
		k.pop(0)
		k.pop(0)
		k.insert(0, "+")
		k.insert(0, "+")
		break
	else:
		pass
print ("----------------")
for j in ins:
	print ("".join(j))


x = int(input())
ins=[]
lp = 0
for i in range(x):
	x = input()
	x = list(x)
	ins.append(x)
for k in ins:
	if k[:2]==['O', 'O']:
		k.pop(0)
		k.pop(0)
		k.insert(0, "+")
		k.insert(0, "+")
		lp+=1
		break
	elif k[3:]==['O', 'O']:
		k.pop(3)
		k.pop(3)
		k.insert(4, "+")
		k.insert(4, "+")
		lp+=1
		break
	else:
		pass
#print ("----------------")
if lp>0:
	print ("YES")
	for j in ins:
		print ("".join(j))
else:
	print ("NO")


x = int(input())
ins=[]
lp = 0
for i in range(x):
	x = input()
	x = list(x)
	ins.append(x)
for k in ins:
	if k[:2]==['O', 'O']:
		k.pop(0)
		k.pop(0)
		k.insert(0, "+")
		k.insert(0, "+")
		lp+=1
		break
	else:
		pass
#print ("----------------")
if lp>0:
	print ("YES")
	for j in ins:
		print ("".join(j))
else:
	print ("NO")


x = int(input())
ins=[]
lp = 0
for i in range(x):
	x = input()
	x = list(x)
	ins.append(x)
for k in ins:
	if k[:2]==['O', 'O']:
		k.pop(0)
		k.pop(0)
		k.insert(0, "+")
		k.insert(0, "+")
		lp+=1
		break
	elif k[3:]==['O', 'O']:
		k.pop(3)
		k.pop(3)
		k.append("+")
		k.append("+")
		lp+=1
	else:
		pass
#print ("----------------")
if lp>0:
	print ("YES")
	for j in ins:
		print ("".join(j))
else:
	print ("NO")


# -*- coding: utf-8 -*-
"""
Created on Sun Oct 28 17:01:04 2018

@author: Quaint Sun
"""

n=int(input())

seat=[[1]*5]*n

t=0
num=0
while t<n:
    seat[t]=input()
    if 'OO' not in seat[t]:
        num=num+1

    t=t+1

if num==n:
    print('NO')
else:
    for i in range(n):
        if 'OO' in seat[i]:
            print('YES')
            seat[i]=seat[i].replace('OO','++')
            if seat[i]='++|++'
                seat='++|OO'
            break
    print('\n'.join(seat))


# -*- coding: utf-8 -*-
"""
Created on Sun Oct 28 17:01:04 2018

@author: Quaint Sun
"""

n=int(input())

seat=[[1]*5]*n

t=0
num=0
while t<n:
    seat[t]=input()
    if 'OO' not in seat[t]:
        num=num+1

    t=t+1

if num==n:
    print('NO')
else:
    for i in range(n):
        if 'OO' in seat[i]:
            print('YES')
            seat[i]=seat[i].replace('OO','++')
            break

print('\n'.join(seat))


# -*- coding: utf-8 -*-
"""
Created on Sun Oct 28 17:01:04 2018

@author: Quaint Sun
"""

n=int(input())

seat=[[1]*5]*n

t=0
num=0
while t<n:
    seat[t]=input()
    if 'OO' not in seat[t]:
        num=num+1

    t=t+1

if num==n:
    print('NO')
else:
    for i in range(n):
        if 'OO' in seat[i]:
            print('YES')
            seat[i]=seat[i].replace('OO','++')
            break
    print('\n'.join(seat))


# -*- coding: utf-8 -*-
"""
Created on Sun Oct 28 17:01:04 2018

@author: Quaint Sun
"""

n=int(input())

seat=[[1]*5]*n

t=0
num=0
while t<n:
    seat[t]=input()
    if 'OO' not in seat[t]:
        num=num+1

    t=t+1

if num==n:
    print('NO')
else:
    for i in range(n):
        if 'OO' in seat[i]:
            print('YES')
            seat[i]=seat[i].replace('OO','++')
            if seat[i]=='++|++'
                seat='++|OO'
            break
    print('\n'.join(seat))


# -*- coding: utf-8 -*-
"""
Created on Sun Oct 28 17:01:04 2018

@author: Quaint Sun
"""

n=int(input())

seat=[[1]*5]*n

t=0
num=0
while t<n:
    seat[t]=input()
    if 'OO' not in seat[t]:
        num=num+1

    t=t+1

if num==n:
    print('NO')
else:
    for i in range(n):
        if 'OO' in seat[i]:
            print('YES')
            seat[i]=seat[i].replace('OO','++')
            if seat[i]=='++|++':
                seat[i]='++|OO'
            break
    print('\n'.join(seat))


n=int(input())
seat_find=[]
answer="NO"
for count in range(n):
	seat_config=input().split("|")
	seat_find.append(seat_config)
for find in seat_find:
	if "OO" in find:
		answer="YES"
		change=find.index("OO")
		find[change]="++"
		break
print(answer)
if answer=="YES":
	for printing in seat_find:
		print("|".join(printing))


n=int(input())
seat_find=[]
answer="NO"
for count in range(n):
	seat_config=input().split("|")
	seat_find.append(seat_config)
for find in seat_find:
	if "OO" in find:
		answer="YES"
		change=find.index("OO")
		find[change]="++"
		break
print(answer)
for printing in seat_find:
			print("|".join(printing))


n=int(input())
seat_find=[]
answer="NO"
for count in range(n):
	seat_config=input().split("|")
	seat_find.append(seat_config)
for find in seat_find:
	if "OO" in find:
		answer="YES"
		change=find.index("OO")
		find[change]="++"

print(answer)
for printing in seat_find:
			print("|".join(printing))


n=int(input())
seat_find=[]
for count in range(n):
	seat_config=input().split("|")
	seat_find.append(seat_config)
for find in seat_find:
	if "OO" in find:
		print("YES")
		change=find.index("OO")
		find[change]="++"

		for printing in seat_find:
			print("|".join(printing))
		break
	else:
		print("NO")


import re
n = int(input())
s = list()
message = "NO"
pattern = r"OO"
for i in range(n):
    x = input()
    if(re.search(pattern, x)) and (message == "NO"):
        message = "YES"
        re.sub(pattern, "++", x, 1)
    s.append(x)
print(message)
if(message == "YES"):
    for i in s:
        print(i)


import re
n = int(input())
s = list()
message = "NO"
pattern = r"OO"
for i in range(n):
    x = input()
    if(re.search(pattern, x)) and (message == "NO"):
        message = "YES"
        mod = re.sub(pattern, "++", x, 1)
        s.append(mod)
    else:
        s.append(x)
print(message)
if(message == "YES"):
    for i in s:
        print(i)


import re
n = int(input())
s = list()
message = "NO"
for i in range(n):
    x = input()
    if("OO" in x):
        message = "YES"
        re.sub(r"OO", "++", x, max = 1)
    s.append(x)
print(message)
if(message == "YES"):
    for i in s:
        print(i)


import re
n = int(input())
s = list()
message = "NO"
pattern = r"OO"
for i in range(n):
    x = input()
    if(re.search(pattern, x)) and (message == "NO"):
        message = "YES"
        re.sub(pattern, "++", x, max = 1)
    s.append(x)
print(message)
if(message == "YES"):
    for i in s:
        print(i)


import re
n = int(input())
s = list()
message = "NO"
for i in range(n):
    x = input()
    if("OO" in x):
        message = "YES"
        re.sub("OO", "++", x, max = 1)
    s.append(x)
print(message)
if(message == "YES"):
    for i in s:
        print(i)


x= int(input())
f=0
ylist=[]
for i in range (0,x,1):
    y=list(input())

    for j in range(0,len(y),1):
        if y[j]=='0'and y[j+1]=='0' and f==0:
            y[j]='+'
            y[j+1]='+'
            f=1
    ylist.append(y)

if f==1:
    print("YES")
    for i in range(0,x,1):
        print(''.join(ylist[i]))
else:
    print("NO")


x= int(input())
f=0
ylist=[]
for i in range (0,x,1):
    y=list(input())

    for j in range(0,len(y)-1,1):

        if y[j]=='0'and y[j+1]=='0' and f==0:
            y[j]='+'
            y[j+1]='+'
            f=1
    ylist.append(y)

if f==1:
    print("YES")
    for i in range(0,x,1):
        print(''.join(ylist[i]))
elif len(ylist)==x:
    print("NO")


x= int(input())
f=0
ylist=[]
for i in range (0,x,1):
    y=list(input())

    for j in range(0,len(y)-1,1):

        if y[j]=='O'and y[j+1]=='O' and f==0:
            y[j]='+'
            y[j+1]='+'
            f=1
    ylist.append(y)

if f>0:
    print("YES")
    for i in range(0,x,1):
        print(''.join(ylist[i]))
elif len(ylist)==x :
    print("NO")


import re
x= int(input())
f=0
for i in range (0,x,1):
    y=input()
    z= re.match(r'.*00.*',y)
    if z:
        f=1
if f==1:
    print("YES")
else:
    print("NO")


n=int(input())
l=[]
flag=1
for i in range(n):
	s=input()
	s=list(s)
	l.append(s)
for i in range(n):
	if(l[i][0]==l[i][1]):
		if(l[i][0]=='O'):
			l[i][0]='+'
			l[i][1]='+'
			flag=0
			break
	if(l[i][3]==l[i][4]):
		if(l[i][3]=='O'):
			l[i][3]='+'
			l[i][4]='+'
			flag=0
			break
if(flag==0):
	print('Yes')
	m=[]
	for i in range(len(l)):
		k="".join(l[i])
		m.append(k)
	for i in range(len(m)):
		print(m[i])
else:
	print('NO')


#include<bits/stdc++.h>
#define ll long long
using namespace std;
main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int s[n];
		vector<int> t;
		for(int i=0;i<n;i++) cin>>s[i],t.push_back(s[i]);
		sort(t.begin(),t.end());
		int flag=0,min=t[0];
		for(int i=0;i<n;i++){
			while(s[i]!=t[i]){
				//cout<<s[i]<<" "<<t[i]<<" "<<i<<endl;
				int itr=lower_bound(t.begin()+i+1,t.end(),s[i])-t.begin();
				while(s[itr]==t[itr]&&itr<n) itr++;
				if(__gcd(s[itr],s[i])==min) swap(s[itr],s[i]);
				else { flag=1; break; }
			}
			if(flag) break;
		}
		for(int i=0;i<n;i++) cout<<s[i]<<" ";
		if(flag) cout<<"NO\n";
		else cout<<"YES\n";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int s[n],t[n];
		for(int i=0;i<n;i++) cin>>s[i],t[i]=s[i];
		sort(t,t+n);
		map<int,int> m;
		for(int i=0;i<n;i++){
			if(s[i]!=t[i]){
				m[t[i]]=i;
			}
		}
		int flag=0,min=t[0];
		for(int i=0;i<n;i++){
			while(s[i]!=t[i]){
				int pos=m[s[i]];
				if(__gcd(s[i],s[pos])==2) swap(s[i],s[pos]);
				else { flag=1; break; }
			}
			if(flag) break;
		}
		if(flag) cout<<"NO\n";
		else cout<<"YES\n";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int s[n];
		vector<int> t;
		for(int i=0;i<n;i++) cin>>s[i],t.push_back(s[i]);
		sort(t.begin(),t.end());
		int flag=0,min=t[0];
		for(int i=0;i<n;i++){
			while(s[i]!=t[i]){
				//cout<<s[i]<<" "<<t[i]<<" "<<i<<endl;
				int itr=lower_bound(t.begin()+i+1,t.end(),s[i])-t.begin();
				while(s[itr]==t[itr]&&itr<n) itr++;
				if(__gcd(s[itr],s[i])==min) swap(s[itr],s[i]);
				else { flag=1; break; }
			}
			if(flag) break;
		}
		//for(int i=0;i<n;i++) cout<<s[i]<<" ";
		if(flag) cout<<"NO\n";
		else cout<<"YES\n";
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int s[n];
		vector<int> t;
		for(int i=0;i<n;i++) cin>>s[i],t.push_back(s[i]);
		sort(t.begin(),t.end());
		int flag=0,min=t[0];
		for(int i=0;i<n;i++){
			while(s[i]!=t[i]){
				//cout<<s[i]<<" "<<t[i]<<" "<<i<<endl;
				int itr=lower_bound(t.begin(),t.end(),s[i])-t.begin();
				while(s[itr]==t[itr]&&itr<n) itr++;
				if(__gcd(s[itr],s[i])==min) swap(s[itr],s[i]);
				else { flag=1; break; }
			}
			if(flag) break;
		}
		if(flag) cout<<"NO\n";
		else cout<<"YES\n";
	}
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>

/* Author Information
 * Author: JokerNoCry
 * Time: 2020-08-21 22:35:02
 * QQ:1160860141
**/

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define ll long long

using namespace std;

int t,n,minnum,a[100010];
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}
bool cmp(int x,int y)
{
    if(gcd(x,y) != minnum) return false;
    if(x<y) return true;
    if(x>y) return false;
    return false;
}

void swap(int *a,int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}
void selection_sort(int arr[], int len)
{
    int i,j;

    for (i = 0 ; i < len - 1 ; i++)
    {
        int min = i;
        for (j = i + 1; j < len; j++)
            if ( (gcd(arr[j],arr[min]) == minnum ) && (arr[j] < arr[min]))
                min = j;
           swap(&arr[min], &arr[i]);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        minnum = 0x7fffffff;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            minnum = min(minnum,a[i]);
        }
        selection_sort(a,n);
        bool flag = true;
        for(int i=1;i<n;i++)
        {
            if(a[i]<a[i-1])
            {
                flag = false;
                break;
            }
        }
        if(flag) printf("YES\n");
        else printf("NO\n");
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>

/* Author Information
 * Author: JokerNoCry
 * Time: 2020-08-21 22:35:02
 * QQ:1160860141
**/

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))
#define ll long long

using namespace std;

int t,n,minnum,a[100010];
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}

void swap(int *a,int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}
void selection_sort(int arr[], int len)
{
    int i,j;

    for (i = 0 ; i < len - 1 ; i++)
    {
        int min = i;
        for (j = i + 1; j < len; j++)
            if ( (gcd(arr[j],arr[min]) % minnum == 0 ) && (arr[j] < arr[min]))
                min = j;
           swap(&arr[min], &arr[i]);
    }
}

int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        minnum = 0x7fffffff;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            minnum = min(minnum,a[i]);
        }
        selection_sort(a,n);
        bool flag = true;
        for(int i=1;i<n;i++)
        {
            if(a[i]<a[i-1])
            {
                flag = false;
                break;
            }
        }
        if(flag) printf("YES\n");
        else printf("NO\n");
    }

    return 0;
}