#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int n,l,r, ans,tmp;
int a[1234];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n == 1) return cout << "1\n", 0;
    for (int i = 0; i < n; i++) {
        l = i - 1, r = i + 1, tmp=a[i];
        while (l>=0 && tmp>=a[l]) tmp=a[l], l--;
        tmp = a[i];
        while (r<n && tmp>a[r]) tmp=a[r], r++;
        l++, r--;
        //cout << "TEST" << r - l + 1 << endl;
        ans = max(ans, r - l + 1);
    }
    return cout << ans << endl, 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int n, l, r, ans;
int a[1234];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n == 1) return cout << "1\n", 0;
    for (int i = 0; i < n; i++) {
        l = i, r=i;
        while (l > 0 && a[l] >= a[l - 1]) l--;
        while (r < n - 1 && a[r] >= a[r + 1]) r++;
        ans = max(ans, r - l + 1);
    }
    return cout << ans << endl, 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int n,l,r, ans,tmp;
int a[1234];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n == 1) return cout << "1\n", 0;
    for (int i = 1; i < n; i++) {
        l = i - 1, r = i + 1, tmp=a[i];
        while (l>=0 && tmp>=a[l]) tmp=a[l], l--;
        tmp = a[i];
        while (r<n && tmp>a[r]) tmp=a[r], r++;
        l++, r--;
        //cout << "TEST" << r - l + 1 << endl;
        ans = max(ans, r - l + 1);
    }
    return cout << ans << endl, 0;
}


#include <cstdio>
#include <vector>
#include <cmath>
#include <climits>
#include <ctime>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <complex>
#include <bitset>
#include <stack>
#include <functional>
#include <cassert>
#include <iomanip>
#include <numeric>

using namespace std;

#if defined(_MSC_VER) || __cplusplus > 199711L
#define typeof decltype
#endif
#ifndef DEBUG
#define dprintf(...)
#else
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
#define rep(i, n) for(int i = 0, _##i = n; i < _##i; ++i)
#define repe(i, n) for(int i = 0, _##i = n; i <= _##i; ++i)
#define foru(i, a, b) for(int i = (a), _##i = (b); i <= _##i; ++i)
#define ford(i, a, b) for(int i = (a), _##i = (b); i >= _##i; --i)
#define forit(i, m) for(typeof((m).begin()) i = (m).begin(), _##i = (m).end(); i != _##i; ++i)

const int MAXN = 1010;
const int INF = 1 << 30;

int N;
int L[MAXN], R[MAXN];
vector<int> a;
int ans;

int main(int argc,char *argv[])
{
	scanf("%d", &N);
	a.push_back(INF);
	rep(i, N)
	{
		int x;
		scanf("%d", &x);
		a.push_back(x);
	}
	a.push_back(INF);
	L[0] = 0;
	for (int i = 1; i < a.size() - 1; i++)
	{
		L[i] = i - 1;
		if (L[i] > 0 && a[L[i]] <= a[i]) L[i] = L[L[i]];
	}
	for (int i = a.size() - 2; i >= 1; i--)
	{
		R[i] = i + 1;
		if (R[i] < a.size() - 1 && a[R[i]] <= a[i]) R[i] = R[R[i]];
	}
	for (int i = 1; i < a.size() - 1; i++)
	{
		ans = max(ans, i - L[i] - 1 + R[i] - i - 1);
	}
	cout << ans + 1;
	return 0;
}


#include<stdio.h>

#define MAX 1000

int main(void)
{
int n,arr[MAX],i,j,count,current,max;

scanf("%d",&n);

for(i=0;i<n;i++)
	scanf("%d",&arr[i]);

max=0;
for(i=0;i<n;i++)
	{
	 j=i;
	 current=arr[j];
	 count=0;
	 while(j>=0 && arr[j]<=current)
			{
			current=arr[j];
			count++;
			j--;
			}

		j=i;
	 	current=arr[j];
		j++;
		while(j<n && arr[j]<=current)
			{
			current=arr[j];
			count++;
			j++;
			}

		if(count>max)
			max=count;

	}

printf("%d",max);
return 0;
}


#include<stdio.h>
int main(){
	int n,i,pos,max,sum,item=0;
	scanf("%d",&n);
	int arr[1000]={0};

	max=0;
	for(i=0;i<n;i++){
		scanf(" %d",&arr[i]);
	}

	for(i=0;i<n;i++){
		pos=i;
		sum=1;
		while((pos<n-1)&&(arr[pos]>=arr[pos+1])){
			sum++;
		//	printf("i=%d sum=%d pos=%d\n",i,sum,pos);
			pos++;
		}
		pos=i;
		while((pos>0)&&arr[pos]>=arr[pos-1]){
			sum++;
		//	printf("i=%d sum=%d pos=%d\n",i,sum,pos);
			pos--;
		}
		if(sum>max){
			max=sum;
		}
		item=i;
	}
	printf("%d",max);
}


#include<stdio.h>
int main()
{
    int i,j,k,a[1000],max=0,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        k=0;
        for(j=i+1;j<n;j++)
        if(a[j]<=a[j-1])
        k++;
        else
        break;
        for(j=i-1;j>=0;j--)
        if(a[j+1]>=a[j])
        k++;
        else
        break;
        if(k>max)
        max=k;
     }
     max++;
     printf("%d",max);
    return 0;
}


#include <stdio.h>

int G[1002];

int main()
{
	int i, j, n, h, ans = 0;
	scanf("%d\n", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &h);
		G[i] = h;
  	}
  	G[0] = G[n + 1] = 1001;
  	for (i = 1; i <= n; ++i) {
  		int k = 1;
  		int v = G[i];
	  	for (j = i - 1; j >= 0; --j) if (G[j] > v) break;
		  else {
  			++k;
  			v = G[j];
  		}
	  	for (j = i + 1; j <= n; ++j) if (G[j] > v) break;
		  else {
  			++k;
  			v = G[j];
  		}
  		if (k > ans) ans = k;
	}
	printf("%d\n", ans);
    return 0;
}


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

int main()
{
    int n;
    scanf("%d",&n);
    int* a=(int*)malloc(n*sizeof(int)),*b=(int*)malloc(n*sizeof(int));
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=1;
    }
    int m=0,j=0;
    for(i=0;i<n;i++)
    {
        if(i)
        {
            if(a[i-1]<a[i])
            {
                b[i]+=b[i-1];
            }
            if(a[i-1]==a[i])
            {
                b[i]=b[i-1];
            }
            else
            {
                j=i;
                while((j+1)<n&&a[j]>=a[j+1])
                {
                    b[i]++;
                    j++;
                }
            }

        }
        else
        {
            j=i;
            while((j+1)<n&&a[j]>=a[j+1])
            {
                b[i]++;
                j++;
            }
        }
        if(b[i]>m)
        {
            m=b[i];
        }
    }
    printf("%d",m);
    return 0;
}


#include <stdio.h>

int main()
{
     int n, max = 0, i, j;
     int a[1000];

     scanf("%d", &n);

     for (i = 0; i < n; i++) scanf("%d", &a[i]);

     for (i = 0; i < n; i++) {
	  int c = a[i];
	  int x = 1;

	  for (j = i - 1; j >= 0; j--) {
	       if (a[j] > c) break;

	       c = a[j];
	  }

	  x += i - j - 1;

	  c = a[i];

	  for (j = i + 1; j < n; j++) {
	       if (a[j] > c) break;

	       c = a[j];
	  }

	  x += j - i - 1;

	  if (x > max) max = x;
     }

     printf("%d\n", max);

     return 0;
}


#include <stdio.h>
#include <stdlib.h>

typedef struct __squareinfo {
    int n;
    int dec;
    int inc;
} S;

int compare(const void *a, const void *b) {
    S *sa = (S *)a;
    S *sb = (S *)b;

    int va = sa->dec + sa->inc;
    int vb = sb->dec + sb->inc;

    if (va > vb) {
        return -1;
    } else if (va < vb) {
        return 1;
    } else {
        return 0;
    }
}

int main(void) {
    int n = 0, i = 0;
    S list[1001] = {0, };

    scanf("%d", &n);
    for (i=0;i<n;i++) {
        scanf("%d", &list[i].n);
        list[i].dec = 1;
        list[i].inc = 1;
    }

    for (i=1;i<n;i++) {
        if (list[i - 1].n <= list[i].n) {
            list[i].inc += list[i - 1].inc;
        }
    }

    for (i=n-2;i>=0;i--) {
        if (list[i].n >= list[i + 1].n) {
            list[i].dec += list[i + 1].dec;
        }
    }

    qsort(list, n, sizeof(S), compare);
    printf("%d\n", list[0].dec + list[0].inc - 1);

    return 0;
}


#include <stdlib.h>
#include <stdio.h>

unsigned int BestCase  (unsigned int *list, size_t n);

int main (void) {

  unsigned int *list;
  size_t n, i;

  scanf("%u", &n);

  list = (unsigned int*)malloc(sizeof(unsigned int) * n);

  for (i = 0; i < n; i++)
    scanf("%u", &list[i]);

  printf("%u", BestCase(list, n));

  return 0;

}

unsigned int LeftSide (unsigned int *list, size_t pos) {

  unsigned int result = 0;

  while (pos && list[pos-1] <= list[pos]) {
    result++;
    pos--;
  }

  return result;

}

unsigned int RightSide (unsigned int *list, size_t pos, size_t max) {

  unsigned int result = 0;

  while (pos < max && list[pos+1] <= list[pos]) {
    result++;
    pos--;
  }

  return result;

}

unsigned int BestCase (unsigned int *list, size_t n) {

  unsigned int result = 0;
  unsigned int temp;
  size_t i;

  for (i = 0; i < n; i++) {
    temp = LeftSide(list, i) + RightSide(list, i, n-1) + 1;
    if (result < temp)
      result = temp;
  }

  return result;

}


#include <stdlib.h>
#include <stdio.h>

unsigned int BestCase  (unsigned int *list, size_t n);

int main (void) {

  unsigned int *list;
  size_t n, i;

  scanf("%u", &n);

  list = (unsigned int*)malloc(sizeof(unsigned int) * n);

  for (i = 0; i < n; i++)
    scanf("%u", &list[i]);

  printf("%u", BestCase(list, n));

  return 0;

}

unsigned int LeftSide (unsigned int *list, size_t pos) {

  unsigned int result = 0;

  while (pos && list[pos-1] <= list[pos]) {
    result++;
    pos--;
  }

  return result;

}

unsigned int RightSide (unsigned int *list, size_t pos, size_t max) {

  unsigned int result = 0;

  while (pos < max && list[pos+1] <= list[pos]) {
    result++;
    pos++;
  }

  return result;

}

unsigned int BestCase (unsigned int *list, size_t n) {

  unsigned int result = 0;
  unsigned int temp;
  size_t i;

  for (i = 0; i < n; i++) {
    temp = LeftSide(list, i) + RightSide(list, i, n-1) + 1;
    if (result < temp)
      result = temp;
  }

  return result;

}


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

int main()
{
  int n,i,j;
  scanf("%d",&n);
int a[n];
int sum[n];
for(i=0;i<n;i++)
    sum[i]=0;
  for(i=0;i<n;i++)
scanf("%d",&a[i]);

for(i=0;i<n;i++)
{j=i;
while(  (j+1)<n  &&  a[j+1] <=a[j])
       {sum[i]++;
        j++;
        }
j=i;
        while(  (j)>0  &&  a[j-1] <=a[j])
       {sum[i]++;
        j--;
        }
sum[i]++;
}

int max=sum[0];
for(i=0;i<n;i++)
{
    if(sum[i]>max)
        max=sum[i];
}
printf("%d",max);

    return 0;
}


#include <stdio.h>

int main () {
	int n;
	int res = 1;
	int count;
	int izq;
	int der;
	int resb = 1;
	int k = -1;
	scanf ("%i", &n);
	count = n - 1;
	int altura[n];
	while (n > 0){
		k++;
		scanf ("%i", &altura[k]);
		n = n -1;
	}
	while (k >= 0){
		izq = k;
		der = k;
		if (izq != 0){
			while (izq > 0){
				if (altura[izq - 1] <= altura[izq]){
					res++;
					izq = izq - 1;
				}
				else
					izq = 0;
				}
		}

		if (der != count){
			while (der < count){
				if (altura[der +1] <= altura[der]){
					res++;
					der++;
				}
				else
					der = count;
				}
		}
		if (res > resb)
			resb = res;
		k = k - 1;
		res = 1;
	}
	printf ("%i", resb);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
int area_regavel_por_indice(int tamanho_do_vetor, int vetor[], int indice){
    int numero_da_area_a_ser_regada, regavel_a_esquerda, regavel_a_direita;
    int i;

    for(regavel_a_esquerda = 0, i = indice, numero_da_area_a_ser_regada = vetor[i];i >= 0; i--) {
        if(numero_da_area_a_ser_regada >= vetor[i]){
            regavel_a_esquerda++;
            numero_da_area_a_ser_regada = vetor[i];
        }
        else break;
    }

    for(regavel_a_direita = 0, i = indice + 1, numero_da_area_a_ser_regada = vetor[i - 1]; i < tamanho_do_vetor; i++){
        if(numero_da_area_a_ser_regada >= vetor[i]){
            regavel_a_direita++;
            numero_da_area_a_ser_regada = vetor[i];
        }
        else break;
    }

    return regavel_a_esquerda + regavel_a_direita;
}
int main(){
        int i,n,altura[1000],nareadir,nareaesq,maiorarea=0;
        scanf("%d",&n);
        for(i=0;i<n;i++){
            scanf("%d",&altura[i]);
            }
        for(i=0;i<n;i++){
            if( maiorarea < area_regavel_por_indice(n,altura,i))
                maiorarea = area_regavel_por_indice(n,altura,i);
            }
        printf("%d\n",maiorarea);
        return 0;
        }


#include<stdio.h>

int main()
{
	int n, i, max;
	scanf("%d", &n);
	int ar[n];
	for(i=0;i<n;i++)
		scanf("%d", &ar[i]);
	max=0;
	int temp, temp_p, val, j, k;
	for(i=0;i<n;i++)
	{
		temp = ar[i];
		j=i-1;
		val=1;
		while(j>=0&&ar[j]<=temp)
		{
			val++;
			temp = ar[j];
			j--;
		}
		k=i+1;
		temp = ar[i];
		while(k<n&&ar[k]<=temp)
		{
			val++;
			temp = ar[k];
			k++;
		}
		if(val>max)
			max = val;
	}
	printf("%d", max);
	return 0;
}


#include <stdio.h>
#define MAX(x,y) ((x) > (y) ? (x) : (y))

int main(void)
{
	int n, i, p, x, ans, cnt;
	while (scanf("%d", &n) != EOF) {
		scanf("%d", &p);
		ans = cnt = 1;
		for (i = 1; i < n; i++) {
			scanf("%d", &x);
			if (p <= x) {
				cnt++;
			} else {
				ans = MAX(ans, cnt);
				cnt = 1;
			}
			p = x;
		}
		printf("%d\n", MAX(ans, cnt));
	}
	return 0;
}


#include <stdio.h>
#define MAX(x,y) ((x) > (y) ? (x) : (y))

int main(void)
{
	int n, i, j, ans, cnt, a[1024];
	while (scanf("%d", &n) != EOF) {
		for (i = 0; i < n; i++) {
			scanf("%d", a + i);
		}
		ans = 1;
		for (i = 0; i < n; i++) {
			cnt = 0;
			for (j = i + 1; j < n && a[j] <= a[j-1]; j++);
			cnt += j - i;
			for (j = i - 1; j >=0 && a[j] <= a[j+1]; j--);
			cnt += i - j;
			ans = MAX(ans, cnt);
		}
		printf("%d\n", ans - 1);
	}
	return 0;
}


#include<stdio.h>
//#include<string.h>
//char str[101];
int a[1000];
int max(int a,int b)
{
	return a>b?a:b;
}
int MAXI=-1;
int main()
{
	int n,i,j,k,count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++)  //assuming ith loc as the req loc
	{
		j=k=i;
		while(j<=n-1 && a[j]-a[j+1]>=0)
		{
			count++;
			j++;

		}
		printf("%d count 1  = %d ",a[i],count);
		while(k-1>=0)
		{
			if(a[k]-a[k-1]<0)
			break;
			count++;
			k--;

		}
		if(a[1]-a[0]>=0)
		count++;
		printf("count 2 =%d\n",count);
		MAXI=max(MAXI,count);
		count=0;
	}
	printf("%d\n",MAXI);
return 0;
}


#include<stdio.h>
//#include<string.h>
//char str[101];
int a[1000];
int max(int a,int b)
{
	return a>b?a:b;
}
int MAXI=-1;
int main()
{
	int n,i,j,k,count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++)  //assuming ith loc as the req loc
	{
		j=k=i;
		while(j<=n-1 && a[j]-a[j+1]>=0)
		{
			count++;
			j++;

		}
		//printf("%d count 1  = %d ",a[i],count);
		while(k-1>=0)
		{
			if(a[k]-a[k-1]<0)
			break;
			count++;
			k--;

		}
		if(a[1]-a[0]>=0)
		count++;
		//printf("count 2 =%d\n",count);
		MAXI=max(MAXI,count);
		count=0;
	}
	printf("%d\n",MAXI);
return 0;
}


#include<stdio.h>
//#include<string.h>
//char str[101];
int a[1000];
int max(int a,int b)
{
	return a>b?a:b;
}
int MAXI=-1;
int main()
{
	int n,i,j,k,count=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++)  //assuming ith loc as the req loc
	{
		j=k=i;
		while(j<n-1 && a[j]-a[j+1]>=0)
		{
			count++;
			j++;

		}
		//printf("%d count 1  = %d ",a[i],count);
		while(k-1>=0)
		{
			if(a[k]-a[k-1]<0)
			break;
			count++;
			k--;

		}
		//printf("count 2 =%d\n",count);
		MAXI=max(MAXI,count);
		count=1;
	}
	printf("%d\n",MAXI);
return 0;
}


#include<stdio.h>
//#include<string.h>
//char str[101];
int a[1000];
int max(int a,int b)
{
	return a>b?a:b;
}
int MAXI=-1;
int main()
{
	int n,i,j,k,count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++)  //assuming ith loc as the req loc
	{
		j=k=i;
		while(j<=n-1 && a[j]-a[j+1]>=0)
		{
			count++;
			j++;
		}
		while(k-1>=0)
		{
			if(a[k]-a[k-1]<0)
			break;
			count++;
			k--;

		}
		MAXI=max(MAXI,count);
		count=0;
	}
	printf("%d\n",MAXI);
return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int rt[1000];
int height[1000];
int lt[1000];

int main(){

	int i=0,N,temp,max;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d ",&height[i]);
	}
	i=0;
	while(i<N){
		rt[i] = 1;
		lt[i] = 0;
		i++;
	}
	for(i=1;i<N;i++){
		if(height[i]>=height[i-1]){
			lt[i] = lt[i-1]+1;
		}
	}
	for(i=N-2;i>=0;i--){
		if(height[i]>=height[i+1]){
			rt[i] = rt[i+1]+1;
		}
	}
	max=0;
	for(i=0;i<N;i++){

		temp = rt[i]+lt[i];
		//printf("%d\n",temp);
		if (temp>max)
			max = temp;

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


#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int rt[1000];
int height[1000];
int lt[1000];

int main(){

	int i=0,N,a=0,temp,max;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d ",&height[i]);
	}
	i=0;
	a = 1;
	lt[0] =1;
	for(i=1;i<N;i++){
		if(height[i]>=height[i-1]){
			lt[i] = lt[i-1]+1;
		}
	}
	rt[N-1] = 1;
		for(i=N-2;i>=0;i--){
		if(height[i]>=height[i+1]){
			rt[i] = rt[i+1]+1;
		}
	}
	max=0;
	for(i=0;i<N;i++){
		temp = rt[i]+lt[i];
		//printf("%d\n",temp);
		if (temp>max)
			max = temp;

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


#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int rt[1000];
int height[1000];
int lt[1000];

int main(){

	int i=0,N,a=0,temp,max;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d ",&height[i]);
	}
	i=0;
	a = 1;
	lt[0] =1;
	for(i=1;i<N;i++){
		if(height[i]>=height[i-1]){
			lt[i] = lt[i-1]+1;
		}
	}
	if(N>1)	rt[N-1] = 1;
	else rt[N-1] = 0;
	for(i=N-2;i>=0;i--){
		if(height[i]>=height[i+1]){
			rt[i] = rt[i+1]+1;
		}
	}
	max=0;
	for(i=0;i<N;i++){

		temp = rt[i]+lt[i];
		//printf("%d\n",temp);
		if (temp>max)
			max = temp;

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


#include<stdio.h>

int main(void)
{
  int n,a[1000],max,count,hold,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",a+i);
  max=0;
  for(i=0;i<n;i++)
  {
    hold=a[i];
    count=1;
    for(j=i+1;(a[j]<=hold&&j<n);j++)
    {
      count++;
      hold=a[j];
    }
    hold=a[i];
    for(j=i-1;(a[j]<=hold&&j>=0);j--)
    {
      count++;
      hold=a[j];
    }
    if(count>max)
      max=count;
    if(count==n)
      break;
  }
  printf("%d\n",max);
  return 0;
}


#include <stdio.h>

int a[1000];
int n;
int current_depth;
int max_depth;

int visit(int i, int j, int go_left)
{
    if (j < 0 || j >= n)
        return 0;
    if (a[i] >= a[j]) {
        current_depth++;
        //printf("%d vs %d ", i, j);
        if (go_left) visit(j, j-1, go_left);
        else visit(j, j+1, go_left);
    }
    return 1;
}

int main(void)
{
    int i;

    scanf("%d", &n);
    for (i=0; i<n; i++)
        scanf("%d", &a[i]);

    for (i=0, max_depth=0; i<n; i++) {
        current_depth = 1;
        visit(i, i-1, 1);
        visit(i, i+1, 0);
        if (current_depth > max_depth)
            max_depth = current_depth;
//        printf("\n");
    }
    printf("%d\n", max_depth);

    return 0;
}


#include <stdio.h>

#define MAX_N  1009

int as[MAX_N];
int N;

int solve(){
    int i,p,q,ans=0;
    for(i=1;i<=N;i++){
        for(p=i; as[p-1]<=as[p]; p--);
        for(q=i; as[q]>=as[q+1]; q++);
        if(ans < q - p + 1){
            ans = q - p + 1;
        }
    }
    return ans;
}

int main(){
    int i;
    scanf("%d\n",&N);
    for(i=1;i<=N;i++)scanf("%d",as+i);
    as[0] = 100000;
    as[N+1] = 100000;
    printf("%d\n",solve());
    return 0;
}


#include <stdio.h>

int N;
int A[1000];

int Left(int i)
{
    int j,k=0;
    for(j=i-1; j>=0&&A[j]<=A[j+1]; --j,++k);
    return k;
}

int Right(int i)
{
    int j,k=0;
    for(j=i+1; j<N&&A[j]<=A[j-1]; ++j,++k);
    return k;
}

int main()
{
    int i,Max,j;
    scanf("%d",&N);
    for(i=0; i<N; ++i)
    {
        scanf("%d",&A[i]);
    }
    for(Max=i=0; i<N; ++i)
    {
        j=Left(i)+Right(i)+1;
        if(Max<j)
        {
            Max=j;
        }
    }
    printf("%d\n",Max);
    return 0;
}


#include <stdio.h>

int N;
int A[1000];

int Left(int i)
{
    int j,k=0;
    for(j=i-1;j>=0&&A[j]<=A[j+1];--j,++k);
    return k;
}

int Right(int i)
{
    int j,k=0;
    for(j=i+1;j<N&&A[j]>=A[j+1];++j,++k);
    return k;
}

int main()
{
    int i,Max,j;
    scanf("%d",&N);
    for(i=0;i<N;++i)
    {
        scanf("%d",&A[i]);
    }
    for(Max=i=0;i<N;++i)
    {
        j=Left(i)+Right(i)+1;;
        if(Max<j)
        {
            Max=j;
        }
    }
    printf("%d\n",Max);
    return 0;
}


#include<stdio.h>

int main () {
	int squares[1000];
	int n;
	scanf("%d", &n);
	int i=0;
	while(i<n) {
		scanf(" %d", &squares[i]);
		i++;
	}
	int max = 0;
	int j;
	i = 0;
	while(i<n) {
		int cur = 1;
		int prev = squares[i];
		j=i-1;
		while(j>0) {
			if (squares[j] > prev) {
				break;
			} else {
				cur++;
				prev = squares[j];
			}
			j--;
		}
		j=i+1;
		while( j<n) {
			if (squares[j] > prev) {
				break;
			} else {
				cur++;
				prev = squares[j];
			}
			j++;
		}
		if (cur > max) max = cur;
		i++;
	}

	printf("%d", max);

	return 0;
}


#include<stdio.h>

int main () {
	int squares[1000];
	int n;
	scanf("%d", &n);
	int i=0;
	while(i<n) {
		scanf(" %d", &squares[i]);
		i++;
	}
	int max = 0;
	int j;
	i = 0;
	while(i<n) {
		int cur = 1;
		int prev = squares[i];
		j=i-1;
		while(j>=0) {
			if (squares[j] > prev) {
				break;
			} else {
				cur++;
				prev = squares[j];
			}
			j--;
		}
		j=i+1;
		prev=squares[i];
		while(j<n) {
			if (squares[j] > prev) {
				break;
			} else {
				cur++;
				prev = squares[j];
			}
			j++;
		}
		if (cur > max) max = cur;
		i++;
	}

	printf("%d", max);

	return 0;
}


#include<stdio.h>

int main () {
	int squares[1000];
	int n;
	scanf("%d", &n);
	int i=0;
	while(i<n) {
		scanf(" %d", &squares[i]);
		i++;
	}
	int max = 0;
	int j;
	i = 0;
	while(i<n) {
		int cur = 1;
		int prev = squares[i];
		j=i-1;
		while(j>=0) {
			if (squares[j] > prev) {
				break;
			} else {
				cur++;
				prev = squares[j];
			}
			j--;
		}
		j=i+1;
		while(j<n) {
			if (squares[j] > prev) {
				break;
			} else {
				cur++;
				prev = squares[j];
			}
			j++;
		}
		if (cur > max) max = cur;
		i++;
	}

	printf("%d", max);

	return 0;
}


#include<stdio.h>

int main () {
	int squares[1000];
	int n;
	scanf("%d", &n);
	for (int i=0 ; i<n ; i++) {
		scanf(" %d", &squares[i]);
	}
	int max = 0;
	int j;
	for (int i=0 ; i<n ; i++) {
		int cur = 1;
		int prev = squares[i];
		for (j=i-1 ; j>0 ; j--) {
			if (squares[j] > prev) {
				break;
			} else {
				cur++;
				prev = squares[j];
			}
		}
		for (j=i+1 ; j<n ; j++) {
			if (squares[j] > prev) {
				break;
			} else {
				cur++;
				prev = squares[j];
			}
		}
		if (cur > max) max = cur;
	}

	printf("%d", max);

	return 0;
}


#include<stdio.h>
int main()
{
int s[1000],n,i,val=0,mval=0,pre,j;
scanf("%d",&n);
for(i=0;i<n;i++)
	scanf("%d",&s[i]);
for(i=0;i<n;i++)
{
	val=1;
	pre=s[i];
	for(j=i-1;j>=0;j--)
	{
		if(s[j]<=pre)
		{
			val++;
			pre=s[j];
		}
		else
			break;
	}
	pre=s[i];
	for(j=i+1;j<n;j++)
	{
		if(s[j]<=pre)
		{
			val++;
			pre=s[j];
		}
		else
			break;
	}
	if(val>mval)
		mval=val;
}
	printf("%d\n",mval);
	return 0;
}


#include<stdio.h>
int main()
{
int s[1000],n,i,val=0,mval=0,pre,j;
scanf("%d",&n);
for(i=0;i<n;i++)
	scanf("%d",&s[i]);
for(i=0;i<n;i++)
{
	val=1;
	pre=s[i];
	for(j=i-1;j>=0;j--)
	{
		if(s[j]<=pre)
		{
			val++;
			pre=s[j];
		}
		else
			break;
	}
	pre=i;
	for(j=i+1;j<n;j++)
	{
		if(s[j]<=pre)
		{
			val++;
			pre=s[j];
		}
		else
			break;
	}
	if(val>mval)
		mval=val;
}
	printf("%d\n",mval);
	return 0;
}


#include<stdio.h>
int main()
{
int s[1000],n,i,val=0,mval=0,pre,j;
scanf("%d",&n);
for(i=0;i<n;i++)
	scanf("%d",&s[i]);
for(i=0;i<n;i++)
{
	val=1;
	pre=s[i];
	for(j=i-1;j>=0;j--)
	{
		if(s[j]<=pre)
		{
			val++;
			pre=s[j];
		}
		else
			break;
	}
	pre=i;
	for(j=i+1;j<n;j++)
	{
		if(s[j]<=pre)
		{
			val++;
			pre=s[j];
		}
		else
			break;
	}
	if(val>mval)
		mval=val;
}
	printf("%d\n",mval);
}


#include<stdio.h>
int main()
{
int s[1001],n,i,val=0,mval=0,pre,j;
scanf("%d",&n);
for(i=0;i<n;i++)
	scanf("%d",&s[i]);
for(i=0;i<n;i++)
{
	val=1;
	pre=s[i];
	for(j=i-1;j>=0;j--)
	{
		if(s[j]<=pre)
		{
			val++;
			pre=s[j];
		}
		else
			break;
	}
	pre=i;
	for(j=i+1;j<n;j++)
	{
		if(s[j]<=pre)
		{
			val++;
			pre=s[j];
		}
		else
			break;
	}
	if(val>mval)
		mval=val;
}
	printf("%d\n",mval);
}


#include<stdio.h>

int main(){
    int n,arr[1005],res[1005],left,right;
    int i,j,k,lx,rx;
    scanf("%d",&n);
    rx=0;
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    for(i=0;i<n;i++){
        left=right=0;
        lx=arr[i];
        j=i-1;
        k=i+1;
        while(j>=0 && arr[j]<=lx){
            left++;
            if(lx>arr[j]) lx=arr[j];
            j--;
        }
        lx=arr[i];
        while(k<n && arr[k]<=lx){
            right++;
            if(lx>arr[k]) lx=arr[k];
            k++;
        }
        if(rx<(left+right)) rx=left+right;
    }
    printf("%d\n",rx+1);
    return 0;
}


#include<stdio.h>
int n,g[1010];
int how(int w){
  int i,c=1;
  for(i=w;i<=n;i++){
    if(g[i+1]<=g[i])
      c++;
    else
      break;
  }
  for(i=w;i>=1;i--){
    if(g[i-1]<=g[i])
      c++;
    else
      break;
  }
  return c;
}
int main(){
  int i,m=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&g[i]);
  g[0]=2000;
  g[n+1]=2000;
  for(i=1;i<=n;i++){
    if(how(i)>m)
      m=how(i);
  }
  printf("%d",m);
  return 0;
}


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

int main(void)
{
    int i = 0, max = 1, n, a[1000], j = 0, prew, now, q;
    a[0] = 1;
    scanf("%d%d", &n, &prew);
    for (i = 1; i < n; i++){
        scanf("%d", &now);
        if (now > prew){
            j = i;
            a[i] = a[i - 1] + 1;
        } else {
            for(q = j; q < i; q++){
                a[q]++;
            }
            if (now == prew){
                a[i] = a[i - 1];
            } else {
                a[i] = 1;
            }
        }
        prew = now;
    }
    for(i = 0; i < n; i++){
        max = fmax(a[i], max);
    }
    printf("%d", max);

    return 0;
}


#include <stdio.h>

int max(int a, int b){
    return a < b ? b : a;
}

int main()
{
    int n, i, j, v[1001];
    scanf("%d", &n);
    for(i = 0; i < n; i++)
        scanf("%d", &v[i]);

    int cnt, ans = 0;
    for(i = 0; i < n; i++){
        cnt = 1;
        for(j = i-1; j >= 0 && v[j] <= v[j+1]; j--)++cnt;
        for(j = i+1; j < n  && v[j] <= v[j-1]; j++)++cnt;
        ans = max(ans, cnt);
    }
    printf("%d\n", ans);

}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <math.h>
#include <float.h>

/*---*/

#define FOR(i, b, e)	for(i = (b); i <= (e); i++)
#define FORL(i, b, e)	for(i = (b); i < (e); i++)
#define FORD(i, e, b)	for(i = (e); i >= (b); i--)
#define FOR0(i, e)		FORL(i, 0, e)

#define min(a, b)		(((a) < (b)) ? (a) : (b))
#define max(a, b)		(((a) > (b)) ? (a) : (b))
#define MINA(a, b)		do { if ((a) > (b)) (a) = (b); } while(0)
#define MAXA(a, b)		do { if ((a) < (b)) (a) = (b); } while(0)
#define MINA2(a, b, i, j)		do { if ((a) > (b)) { (a) = (b); (i) = (j); } } while(0)
#define MAXA2(a, b, i, j)		do { if ((a) < (b)) { (a) = (b); (i) = (j); } } while(0)

#define INT int

/*---*/

int main()
{
	int n, i, a, c, l, u, m, e;
#ifndef ONLINE_JUDGE
char ss[1000];
int cc;
#endif
#ifndef ONLINE_JUDGE
while((cc = getchar()) != EOF) {
	ungetc(cc, stdin);
#endif
	scanf("%d", &n);
	l = 0;
	c = 0;
	u = 1;
	m = 0;
	e = 1;
	FOR0(i, n) {
		scanf("%d", &a);
		c++;
		if (!(u && l <= a || !u && l >= a)) {
			if (!u) {
				c--;
				MAXA(m, c);
				c = e + 1;
			}
			u = !u;
			e = 1;
		} else
			if (l == a)
				e++;
		l = a;
	}
	MAXA(m, c);
	printf("%d\n", m);
#ifndef ONLINE_JUDGE
	gets(ss);
}
#endif
	return 0;
}


#include<stdio.h>
#include<limits.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
int main()
{
	int n,j;
	scanf("%d",&n);
	int a[n],ans=0,max=1,temp;
	for(int i=0;i<n;i++)  scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
	{
		for(j=i-1;j>=0;j--)
		{
			if(a[j]<=a[i] && a[j]<=a[j+1])
				ans++;
			else break;
		}
//		temp=ans;
	//	printf("i==%d L==%d",i,ans);
		for(j=i+1;j<n;j++)
		{
			if(a[j]<=a[i] && a[j-1]>=a[j])
				ans++;
			else break;
		}
	//	printf(" R==%d\n",ans-temp);
		if(ans>max)
			max=ans;
		ans=0;
	}
	if(max!=1)
	printf("%d",max+1);
	else printf("%d",max);
	return 0;
}


#include<stdio.h>
#include<limits.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
int main()
{
	int n,j;
	scanf("%d",&n);
	int a[n],ans=0,max=1,temp;
	for(int i=0;i<n;i++)  scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
	{
		for(j=i-1;j>=0;j--)
		{
			if(a[j]<=a[i] && a[j]<=a[j+1])
				ans++;
			else break;
		}
//		temp=ans;
//		printf("i==%d L==%d",i,ans);
		for(j=i+1;j<n;j++)
		{
			if(a[j]<=a[i] && a[j-1]>=a[j])
				ans++;
			else break;
		}
//		printf(" R==%d\n",ans-temp);
		if(ans>max)
			max=ans;
		ans=0;
	}
	if(n!=1)
	printf("%d",max+1);
	else printf("%d",max);
	return 0;
}


#include<stdio.h>
//#include<conio.h>
int main()
{
 long a[1005],found1=0,n,found2=0,max=0,ans=0,i,j;
// printf("enter the value of n:");
 scanf("%ld",&n);
 for(i=1;i<=n;i++)
 {
  scanf("%ld",&a[i]);
 }
 a[n+1]=1005;
 a[0]=1005;
 for(i=1;i<=n;i++)
 {
  found1=0;
  ans=0;
  for(j=i;j>=1 && found1==0;j--)
  {
   if(a[j-1]<=a[j])
   {
    ans++;
//    printf("%ld\n",ans);
   }
   else
    found1=1;
  }
  found2=0;
  for(j=i;j<=n && found2==0;j++)
  {
   if(a[j+1]<=a[j])
   {
    ans=ans++;
//    printf("%ld\n",ans);
   }
   else
    found2=1;
  }
  if(ans+1>max)
   max=ans+1;
 }
 if(n>1)
 printf("%ld",max);
 if(n==1)
 printf("1");
// getch();
// clrscr();
return 0;
}


#include<stdio.h>
//#include<conio.h>
int main()
{
 long a[1005],found1=0,n,found2=0,max=0,ans=0,i,j;
// printf("enter the value of n:");
 scanf("%ld",&n);
 for(i=1;i<=n;i++)
 {
  scanf("%ld",&a[i]);
 }
 for(i=1;i<=n;i++)
 {
  found1=0;
  ans=0;
  for(j=i;j>=1 && found1==0;j--)
  {
   if(a[j-1]<=a[j])
    ans++;
   else
    found1=1;
  }
  found2=0;
  for(j=i;j<=n && found2==0;j++)
  {
   if(a[j+1]<=a[j])
    ans=ans++;
   else
    found2=1;
  }
  if(ans>max)
   max=ans;
 }
 if(n>1)
 printf("%ld",max);
 if(n==1)
 printf("1");
// getch();
// clrscr();
return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int heavy[20000005]={0};
int metal[20000005]={0};
int main()
{
    string str;
	int long long ans=0;
	int long long cnt1=0,cnt2=0;
	cin>>str;
	int i,j;
	for(i=0;i<str.length();i++)
	{
		if(str[i]=='h' && str[i+1]=='e' && str[i+2]=='a' && str[i+3]=='v' && str[i+4]=='y')
		{
			heavy[++cnt1]=i;
			i+=4;
		}
		else if(str[i]=='m' && str[i+1]=='e' && str[i+2]=='t' && str[i+3]=='a' && str[i+4]=='l')
		{
			metal[++cnt2]=i;
			i+=4;
		}
	}
	for(i=1;i<=cnt1;i++)
		for(j=1;j<=cnt2;j++)
		    if(metal[j]>heavy[i])
		        ans++;
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int heavy[200005]={0};
int metal[200005]={0};
int main()
{
    string str;
	long long ans=0;
	int cnt1=0,cnt2=0;
	cin>>str;
	int i,j;
	int len=str.length();
	for(i=0;i<len;i++)
		if(str.substr(i,5)=="heavy")
			heavy[++cnt1]=i,i+=4;
		else if(str.substr(i,5)=="metal")
			metal[++cnt2]=i,i+=4;
	int last=1;
	int counter=cnt2;
	for(i=1;i<=cnt1;i++)
		for(j=last;j<=cnt2;j++)
		    if(metal[j]>heavy[i])
		    {
		        ans+=counter-j+1;
		        last=j;
		        break;
		    }
	cout<<ans<<endl;
	return 0;
}


/*Quite easy, today's 2ed problem*/
#include <iostream>
//#include <cmath>
//#include <algorithm>
//#include <fstream>
//#define fin cin
//#define fout cout
using namespace std;
int heavy[200005];
int metal[200005];
string str;
int main()
{
//	ifstream fin("input.txt");
//	ofstream fout("output.txt");
	long long ans=0;
	int cnt1=0,cnt2=0;
	cin>>str;
	for(int i=0;i<str.length();i++)
	{
		if(str[i]=='h' && str[i+1]=='e' && str[i+2]=='a' && str[i+3]=='v' && str[i+4]=='y')
		{
			heavy[++cnt1]=i;
			i+=5;
		}
		if(str[i]=='m' && str[i+1]=='e' && str[i+2]=='t' && str[i+3]=='a' && str[i+4]=='l')
		{
			metal[++cnt2]=i;
			i+=5;
		}
	}
//	cout<<heavy[1]<<endl;
	for(int i=1;i<=cnt1;i++)
	{
		for(int j=1;j<=cnt2;j++)
		    if(metal[j]>heavy[i])
		        ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int heavy[20000005]={0};
int metal[20000005]={0};
int main()
{
    string str;
	int long long ans=0;
	int long long cnt1=0,cnt2=0;
	cin>>str;
	int i,j;
	for(i=0;i<str.length();i++)
		if(str[i]=='h' && str[i+1]=='e' && str[i+2]=='a' && str[i+3]=='v' && str[i+4]=='y')
		{
			heavy[++cnt1]=i;
			i+=4;
		}
		else if(str[i]=='m' && str[i+1]=='e' && str[i+2]=='t' && str[i+3]=='a' && str[i+4]=='l')
		{
			metal[++cnt2]=i;
			i+=4;
		}
	int last=1;
	int long long counter=cnt2;
	for(i=1;i<=cnt1;i++)
		for(j=last;j<=cnt2;j++)
		    if(metal[j]>heavy[i])
		    {
		        ans+=counter-j+1;
		        break;
		        last=j;
		    }
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int heavy[20000005]={0};
int metal[20000005]={0};
int main()
{
    string str;
	int long long ans=0;
	int long long cnt1=0,cnt2=0;
	cin>>str;
	int i,j;
	for(i=0;i<str.length();i++)
	{
		if(str[i]=='h' && str[i+1]=='e' && str[i+2]=='a' && str[i+3]=='v' && str[i+4]=='y')
		{
			heavy[++cnt1]=i;
			i+=4;
		}
		else if(str[i]=='m' && str[i+1]=='e' && str[i+2]=='t' && str[i+3]=='a' && str[i+4]=='l')
		{
			metal[++cnt2]=i;
			i+=4;
		}
	}
	int long long counter=cnt2;
	for(i=1;i<=cnt1;i++)
		for(j=1;j<=cnt2;j++)
		    if(metal[j]>heavy[i])
		    {
		        ans+=counter-j+1;
		        break;
		    }
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
int heavy[200005]={0};
int metal[200005]={0};
int main()
{
    string str;
	int ans=0;
	int cnt1=0,cnt2=0;
	cin>>str;
	int i,j;
	int len=str.length();
	for(i=0;i<len;i++)
		if(str.substr(i,5)=="heavy")
			heavy[++cnt1]=i,i+=4;
		else if(str.substr(i,5)=="metal")
			metal[++cnt2]=i,i+=4;
	int last=1;
	int counter=cnt2;
	for(i=1;i<=cnt1;i++)
		for(j=last;j<=cnt2;j++)
		    if(metal[j]>heavy[i])
		    {
		        ans+=counter-j+1;
		        last=j;
		        break;
		    }
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
string h="heavy",m="metal";
int he[100009],me[100009],nh,nm,tmp;
bool checkh(int k,string s)
{
    int j=0;
    while(s[k] == h[j] && k < s.size())
        j++,k++;
    if(j == 5)
        {
        he[nh++]=k-4;
        return true;
        }
    return false;

}
bool checkm(int k ,string s)
{
    int j=0;
    while(s[k] == m[j] && k < s.size())
        j++,k++;
    if(j == 5)
        {
        me[nm++]=k-4;
        return true;
        }
    return false;
}
int main()
{
    string s;
    cin >> s;
    for(int i=0; i<s.size(); ++i)
    {
        if(s[i] == 'h' && checkh(i,s) == true)
            i+=3;
        if(s[i] == 'm' && checkm(i,s) == true)
            i+=3;
    }
    for(int i=0,j=0; i<nh; ++i)
    {
            if(he[i] <= me[j])
        {
            tmp+=nm-j;
            if(j < nm-1)
                j++;
        }
            else
        {
            while(me[j] < he[i] && j < nm-1)
                j++;
        }
    }
    cout << tmp;
}


#include<iostream>
#include<string>
using namespace std;
string h="heavy",m="metal";
int he[100009],me[100009],nh,nm,tmp;
bool checkh(int k,string s)
{
	int j=0;
	while(s[k] == h[j] && k < s.size())
		j++,k++;
	if(j == 5)
		{
		he[nh++]=k-4;
		return true;
		}
	return false;

}
bool checkm(int k ,string s)
{
	int j=0;
	while(s[k] == m[j] && k < s.size())
		j++,k++;
	if(j == 5)
		{
		me[nm++]=k-4;
		return true;
		}
	return false;
}
int main()
{
	string s;
	cin >> s;
	for(int i=0; i<s.size(); ++i)
	{
		if(s[i] == 'h' && checkh(i,s) == true)
			i+=3;
		if(s[i] == 'm' && checkm(i,s) == true)
			i+=3;
	}
	for(int i=0,j=0; i<nh; ++i)
		if(he[i] <= me[j] && j < nm)
			tmp+=nm-j,j++;
	cout << tmp;
}


#include<iostream>
#include<string>
using namespace std;
string h="heavy",m="metal";
int he[100009],me[100009],nh,nm,tmp;
bool checkh(int k,string s)
{
    int j=0;
    while(s[k] == h[j] && k < s.size())
        j++,k++;
    if(j == 5)
        {
        he[nh++]=k-4;
        return true;
        }
    return false;

}
bool checkm(int k ,string s)
{
    int j=0;
    while(s[k] == m[j] && k < s.size())
        j++,k++;
    if(j == 5)
        {
        me[nm++]=k-4;
        return true;
        }
    return false;
}
int main()
{
    string s;
    cin >> s;
    for(int i=0; i<s.size(); ++i)
    {
        if(s[i] == 'h' && checkh(i,s) == true)
            i+=3;
        if(s[i] == 'm' && checkm(i,s) == true)
            i+=3;
    }
    for(int i=0,j=0; i<nh; ++i)
        if(he[i] <= me[j])
        {
            tmp+=nm-j;
            if(j < nm-1)
                j++;
        }
    cout << tmp;
}


#include<iostream>
#include<string>
using namespace std;
string h = "heavy";
string m = "metal";
int64_t l,r;
string s;
int main()
{
    cin >> s;
    for(int64_t i=0; i<s.size(); ++i)
    {
        l=(s.substr(i,5) == h)?l+1:l;
        r=(s.substr(i,5) == m)?r+l:r;
    }
    cout << r;
}


#include<iostream>
#include<string>
using namespace std;
string h = "heavy";
string m = "metal";
int l,r;
string s;
int main()
{
    cin >> s;
    for(int i=0; i<s.size()-3; ++i)
    {
        l=(s.substr(i,5) == h)?l+1:l;
        r=(s.substr(i,5) == m)?r+l:r;
    }
    cout << r;
}


#include<iostream>
#include<string>
using namespace std;
string h = "heavy";
string m = "metal";
int l,r;
string s;
int main()
{
    cin >> s;
    for(int i=0; i<s.size()-4; ++i)
    {
        l=(s.substr(i,5) == h)?l+1:l;
        r=(s.substr(i,5) == m)?r+l:r;
    }
    cout << r;
}


#include<iostream>
#include<string>
using namespace std;
string h = "heavy";
string m = "metal";
int64_t l,r;
string s;
int main()
{
    cin >> s;
    for(int64_t i=0; i<s.size()-3; ++i)
    {
        l=(s.substr(i,5) == h)?l+1:l;
        r=(s.substr(i,5) == m)?r+l:r;
    }
    cout << r;
}


#include <iostream>
using namespace std;
#define x if(a.substr(i,i+5)==
main()
{
    std::string a;
    std::cin>>a;
    long long h,s,i=s=h=0;
    for(;i<a.size()-4;i++)
    x "heavy")
    h++;
    else x "metal")
    s+=h;
    std::cout<<s;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <math.h>

using namespace std;
#define int long long
main()
{
    string a;
    cin>>a;
    int n=a.size();
    int*heavy=new int[n];
    int*metal=new int[n];
    int h,m=h=0;
    int ans=0;
    for(int i=0;i<=n-5;i++)
    if(a[i]=='h' && a[i+1]=='e' && a[i+2]=='a' && a[i+3]=='v' && a[i+4]=='y')
    heavy[h++]=i;
    else if(a[i]=='m' && a[i+1]=='e' && a[i+2]=='t' && a[i+3]=='a' && a[i+4]=='l')
    metal[m++]=i,ans+=h;
    cout<<ans<<endl;
}


#include <iostream>
#define x a.substr(i-1,5)==
main()
{
    std::string a;
    std::cin>>a;
    long long h,s,i=s=h=0,n=a.size();
    while(i++<n-3)
    x"heavy"?h++:x"metal"?s+=h:0;
    std::cout<<s;
}


#include <iostream>
#define x a.substr(i,5)==
main()
{
    std::string a;
    std::cin>>a;
    long long h,s=h=0,n=a.size(),i=-1;
    while(i++<n-4)
    x"heavy"?h++:x"metal"?s+=h:0;
    std::cout<<s;
}


#include <iostream>
#define x a.substr(i,5)==
main()
{
    std::string a;
    std::cin>>a;
    long long h,s,i=s=h=0,n=a.size();
    while(i++<n-4)
    x"heavy"?h++:x"metal"?s+=h:0;
    std::cout<<s;
}


#include <iostream>
#define x if(a.substr(i,5)==
main()
{
    std::string a;
    std::cin>>a;
    long long h,s,i=s=h=0;
    for(;i<a.size()-4;i++)
    x "heavy")
    h++;
    else x "metal")
    s+=h;
    std::cout<<s;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <math.h>

using namespace std;

main()
{
    string a;
    cin>>a;
    int n=a.size();
    int*heavy=new int[n];
    int*metal=new int[n];
    int h,m=h=0;
    int ans=0;
    for(int i=0;i<=n-5;i++)
    if(a[i]=='h' && a[i+1]=='e' && a[i+2]=='a' && a[i+3]=='v' && a[i+4]=='y')
    heavy[h++]=i;
    else if(a[i]=='m' && a[i+1]=='e' && a[i+2]=='t' && a[i+3]=='a' && a[i+4]=='l')
    metal[m++]=i,ans+=h;
    cout<<ans<<endl;
}


#include <iostream>
#define x a.substr(i,5)==
main()
{
    std::string a;
    std::cin>>a;
    long long h,s,i=s=h=0,n=a.size();
    for(;i<n-4;i++)
    x"heavy"?h++:x"metal"?s+=h:0;
    std::cout<<s;
}


#include <iostream>
#define x if(a.substr(i,5)==
main()
{
    std::string a;
    std::cin>>a;
    long long h,s,i=s=h=0,n=a.size();
    for(;i<n-4;i++)
    x "heavy")
    h++;
    else x "metal")
    s+=h;
    std::cout<<s;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
 string s;
 cin>>s;
 //if(s.find("heavy")!=string::npos);
 //pos=find("heavy");
 int count=0,j,p;
 for(int i=0;i<s.length();i++)
 {
     p=s.find("heavy",i);
     if(p!=string::npos)
    {
        i=p;
        j=p;
        while(j<s.length())
        {
            j=s.find("metal",j);
            if(j!=string::npos)
             {
               j=j+4;
              //cout<<"metal "<<j-4<<endl;
              count++;
             }
             else
             break;
        }
     }
}
     cout<<count;
     return 0;
}


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

 int count=0,j,g,k,p,ans=0,sum=0,i=0,c=0;
 int y=s.length();
 vector<int> v;
 p=s.find("heavy");
 g=p;
 if(p!=string::npos)
 {
   for(i=p+5;i<y;i++)
 {
            p=s.find("metal",i);
            if(p!=string::npos)
             {

                v.push_back(p);
                i=p;
                count++;
             }
             else
             break;
        }
}

ans=count;

for(i=g+4;i<y;i++)
  {
     j=s.find("heavy",i);
     if(j!=string::npos && j<v[v.size()-1])
     {

            i=j;
            c=0;
            k=0;
            while(j>v[k])
            {
            k++;
            c++;
            }
        sum=c+sum;
        }

    }
if(sum==0)
{
    cout<<ans;
}
else
cout<<ans+(count-sum);
return 0;
}


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

 int count=0,j,g,k,p,ans=0,sum=0,i=0,c=0;
 int y=s.length();
 vector<int> v;
 p=s.find("heavy");
 g=p;
 if(p!=string::npos)
 {
   for(i=p+5;i<y;i++)
 {
            p=s.find("metal",i);
            if(p!=string::npos)
             {

                v.push_back(p);
                i=p;
                count++;
             }
             else
             break;
        }
}

//cout<<v[v.size()-1]<<endl;
ans=count;

for(i=g+5;i<y;i++)
  {
     j=s.find("heavy",i);

       if(j!=string::npos && j<v[v.size()-1])
     {

//    cout<<"heavy"<<endl;
            i=j;
            c=0;
            k=0;
            while(j>v[k])
            {
            k++;
            c++;
            //cout<<"aage"<<endl;
            }
            ans=ans + count-c;
        }

    }
cout<<ans<<endl;
return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
 string s;
 cin>>s;
 //if(s.find("heavy")!=string::npos);
 //pos=find("heavy");
 int count=0,j,p;
 for(int i=0;i<s.length();i++)
 {
     if(s.find("heavy",i)!=string::npos)
    {
        p=s.find("heavy",i);
        //cout<<"heavy "<<p<<endl;
        i=i+p;
        j=p;
        while(j<s.length())
        {
            if(s.find("metal",j+1)!=string::npos)
             {
              j=s.find("metal",j+1)+4;
              //cout<<"metal "<<j-4<<endl;
              count++;
             }
             else
             break;
        }
     }
     //cout<<"i is "<<i<<endl;

}
     cout<<count;
     return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
 string s;
 cin>>s;
 //if(s.find("heavy")!=string::npos);
 //pos=find("heavy");
 int count=0,j,p;
 for(int i=0;i<s.length();i++)
 {
     if(s.find("heavy",i)!=string::npos)
    {
        p=s.find("heavy",i);
        //cout<<"heavy "<<p<<endl;
        i=p;
        j=p;
        while(j<s.length())
        {
            if(s.find("metal",j)!=string::npos)
             {
              j=s.find("metal",j);
              j=j+4;
              //cout<<"metal "<<j-4<<endl;
              count++;
             }
             else
             break;
        }
     }
}
     cout<<count;
     return 0;
}


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

 int count=0,j,g,k,p,ans=0,sum=0,i=0,c=0;
 int y=s.length();
 vector<int> v;
 p=s.find("heavy");
 g=p;
 if(p!=string::npos)
 {
   for(i=p+5;i<y;i++)
 {
            p=s.find("metal",i);
            if(p!=string::npos)
             {

                v.push_back(p);
                i=p;
                count++;
             }
             else
             break;
        }
}

//cout<<v[v.size()-1]<<endl;
ans=count;
k=0;
for(i=g+5;i<y;i++)
  {
     j=s.find("heavy",i);

       if(j!=string::npos && j<v[v.size()-1])
     {

//    cout<<"heavy"<<endl;
            i=j;
            while(j>v[k])
            {
            k++;
            c++;
            //cout<<"aage"<<endl;
            }

                ans=ans + count-c;
        }

    }
cout<<ans<<endl;
return 0;
}


#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
 string s;
 cin>>s;
 //if(s.find("heavy")!=string::npos);
 //pos=find("heavy");
 int count=0,j,g,k,p,ans=0,sum=0,i=0,c=0;
 int y=s.length();
 vector<int> v;
 p=s.find("heavy");
 g=p;
 if(p!=string::npos)
 {
   for(i=p+5;i<y;i++)
 {
            p=s.find("metal",i);
            if(p!=string::npos)
             {
  //              cout<<"metal"<<endl;
                v.push_back(p);
                i=p;
                count++;
             }
             else
             break;
        }
}
//for(i=0;i<v.size();i++)
//cout<<v[i]<<" ";
ans=count;
//cout<<ans;
for(i=g+4;i<y;i++)
  {
     j=s.find("heavy",i);
     if(j!=string::npos)
     {
           //cout<<"heavy"<<endl;
            i=j;
            c=0;
            k=0;
            while(j>v[k])
            {
            k++;
            c++;
            //cout<<"aage"<<endl;
            }
        sum=c+sum;
        }
  //        cout<<sum<<endl;
    }
if(sum==0)
{
    cout<<ans;
}
else
cout<<ans+(count-sum);
return 0;
}


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

 int count=0,j,g,k,p,ans=0,sum=0,i=0,c=0;
 int y=s.length();
 vector<int> v;
 p=s.find("heavy");
 g=p;
 if(p!=string::npos)
 {
   for(i=p+5;i<y;i++)
 {
            p=s.find("metal",i);
            if(p!=string::npos)
             {

                v.push_back(p);
                i=p;
                count++;
             }
             else
             break;
        }
}

//cout<<v[v.size()-1]<<endl;
ans=count;
k=0;
for(i=g+5;i<y;i++)
  {
     j=s.find("heavy",i);

       if(j!=string::npos && j<v[v.size()-1])
     {

//    cout<<"heavy"<<endl;
            i=j;
            c=0;
            while(j>v[k])
            {
            k++;
            c++;
            //cout<<"aage"<<endl;
            }

            ans=ans + count-c;
        }

    }
cout<<ans<<endl;
return 0;
}


#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
 string s;
 cin>>s;
 //if(s.find("heavy")!=string::npos);
 //pos=find("heavy");
 int count=0,j,g,k,p,ans=0,sum=0,i=0,c=0;
 int y=s.length();
 vector<int> v;
 p=s.find("heavy");
 g=p;
 if(p!=string::npos)
 {
   for(i=p+5;i<y;i++)
 {
            p=s.find("metal",i);
            if(p!=string::npos)
             {
  //              cout<<"metal"<<endl;
                v.push_back(p);
                i=p;
                count++;
             }
             else
             break;
        }
}
//for(i=0;i<v.size();i++)
//cout<<v[i]<<" ";
ans=count;
//cout<<ans;
for(i=g+4;i<y;i++)
  {
     j=s.find("heavy",i);
     if(j!=string::npos && j<v[v.size()-1])
     {
           //cout<<"heavy"<<endl;
            i=j;
            c=0;
            k=0;
            while(j>v[k])
            {
            k++;
            c++;
            //cout<<"aage"<<endl;
            }
        sum=c+sum;
        }
  //        cout<<sum<<endl;
    }
if(sum==0)
{
    cout<<ans;
}
else
cout<<ans+(count-sum);
return 0;
}


#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
 string s;
 cin>>s;
 //if(s.find("heavy")!=string::npos);
 //pos=find("heavy");
 int count=0,j,g,k,p,ans=0,sum,i,c;
 int y=s.length();
 vector<int> v;
 p=s.find("heavy");
 g=p;
 if(p!=string::npos)
 {
   for(i=p+5;i<y;i++)
 {
            p=s.find("metal",i);
            if(p!=string::npos)
             {
  //              cout<<"metal"<<endl;
                v.push_back(p);
                i=p;
                count++;
             }
             else
             break;
        }
}
//for(i=0;i<v.size();i++)
//cout<<v[i]<<" ";
ans=count;
//cout<<ans;
for(i=g+1;i<y;i++)
  {
     j=s.find("heavy",i);
     if(j!=string::npos)
     {
           //cout<<"heavy"<<endl;
            i=j;
            k=0;
            while(j>v[k])
            {
            k++;
            c++;
            //cout<<"aage"<<endl;
            }
        sum=c+sum;
        }
  //        cout<<sum<<endl;
    }

cout<<ans+(count-sum);
return 0;
}


#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
 string s;
 cin>>s;
 //if(s.find("heavy")!=string::npos);
 //pos=find("heavy");
 int count=0,j,g,k,p,ans=0,sum=0,i=0,c=0;
 int y=s.length();
 vector<int> v;
 p=s.find("heavy");
 g=p;
 if(p!=string::npos)
 {
   for(i=p+5;i<y;i++)
 {
            p=s.find("metal",i);
            if(p!=string::npos)
             {
  //              cout<<"metal"<<endl;
                v.push_back(p);
                i=p;
                count++;
             }
             else
             break;
        }
}
//for(i=0;i<v.size();i++)
//cout<<v[i]<<" ";
ans=count;
//cout<<ans;
for(i=g+1;i<y;i++)
  {
     j=s.find("heavy",i);
     if(j!=string::npos)
     {
           //cout<<"heavy"<<endl;
            i=j;
            c=0;
            k=0;
            while(j>v[k])
            {
            k++;
            c++;
            //cout<<"aage"<<endl;
            }
        sum=c+sum;
        }
  //        cout<<sum<<endl;
    }

cout<<ans+(count-sum);
return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
 string s;
 cin>>s;
 //if(s.find("heavy")!=string::npos);
 //pos=find("heavy");
 int count=0,j,p;
 int y=s.length();
 for(int i=0;i<y;i++)
 {
     p=s.find("heavy",i);
     if(p!=string::npos)
    {
        i=p;
        j=p;
        while(j<y)
        {
            j=s.find("metal",j);
            if(j!=string::npos)
             {
               j=j+5;
              //cout<<"metal "<<j-4<<endl;
              count++;
             }
             else
             break;
        }
     }
}cout<<count;
     return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            str = s.substr(i+START.size();
            if (s.substr(i,START.size()) == START) count += Endings(str);
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector<int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.add(i);
}

int PowerFul(string &s) {
    vector<int> starts;
    FillVector(starts,s,START);
    vector<int> finishs;
    FillVector(finishs,s,FINISH);
    int counter = 0;
    int prev = 0;
    int cur = 0;
    int prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        int count = 0;
        int j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count++;
    return count;
}

int PowerFul(string &s) {
    int count = 0;
    int prevEndInd = s.size()-1;
    int startInd = 0;
    int endInd = 0;
    int cur = 0;
    int prev = 0;
    string str;
    string passed;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            startInd = s.size() - i - START.size();
            str = s.substr(startInd,START.size());
            if (str == START) {
                endInd = startInd + START.size() - 1;
                passed = s.substr(endInd,prevEndInd - endInd + 1);
                cur = prev + Endings(passed);
                prev = cur;
                count += cur;
                prevEndInd = endInd;
            }
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count++;
    return count;
}

int PowerFul(string &s) {
    int count = 0;
    int prevEndInd = s.size()-1;
    int startInd = 0;
    int endInd = 0;
    int cur = 0;
    int prev = 0;
    string str;
    string passed;
    for (int i= FINISH.size() - 1; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            startInd = s.size() - i - START.size();
            str = s.substr(startInd,START.size());
            if (str == START) {
                endInd = startInd + START.size() - 1;
                passed = s.substr(endInd,prevEndInd - endInd + 1);
                cur = prev + Endings(passed);
                prev = cur;
                count += cur;
                prevEndInd = endInd + FINISH.size() - 1;
            }
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <long long> &vec, string &s, string str) {
    for (long long i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

int PowerFul(string &s) {
    vector <long long> starts;
    FillVector(starts,s,START);
    vector <long long> finishs;
    FillVector(finishs,s,FINISH);
    long long counter = 0;
    long long prev = 0;
    long long cur = 0;
    long long prevInd = finishs.size()-1;
    for (long long i=starts.size()-1; i>=0; i--) {
        long long count = 0;
        long long j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
        int a = 0;
        int b = 0;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <Iostream>
using namespace std;
const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size())
            if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


const string START = "heavy";
const string FINISH = "metal";
#include <iostream>
using namespace std;

void FillVector(vector<int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

int PowerFul(string &s) {
    vector<int> starts;
    FillVector(starts,s,START);
    vector<int> finishs;
    FillVector(finishs,s,FINISH);
    int counter = 0;
    int prev = 0;
    int cur = 0;
    int prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        int count = 0;
        int j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <int> &vec, string &s, string str) {
    for (long long i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

int PowerFul(string &s) {
    vector <int> starts;
    FillVector(starts,s,START);
    vector <int> finishs;
    FillVector(finishs,s,FINISH);
    long long counter = 0;
    long long prev = 0;
    long long cur = 0;
    long long prevInd = finishs.size()-1;
    for (long long i=starts.size()-1; i>=0; i--) {
        long long count = 0;
        long long j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

int PowerFul(string &s) {
    vector <int> starts;
    FillVector(starts,s,START);
    vector <int> finishs;
    FillVector(finishs,s,FINISH);
    int counter = 0;
    int prev = 0;
    int cur = 0;
    int prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        int count = 0;
        int j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    int i=0;
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <long long> &vec, string &s, string str) {
    for (long long i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

long long PowerFul(string &s) {
    vector <long long> starts;
    FillVector(starts,s,START);
    vector <long long> finishs;
    FillVector(finishs,s,FINISH);
    long long counter = 0;
    long long prev = 0;
    long long cur = 0;
    long long prevInd = finishs.size()-1;
    for (long long i=starts.size()-1; i>=0; i--) {
        long long count = 0;
        long long j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <long long> &vec, string &s, string str) {
    for (long long i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

int PowerFul(string &s) {
    vector <long long> starts;
    FillVector(starts,s,START);
    vector <long long> finishs;
    FillVector(finishs,s,FINISH);
    long long counter = 0;
    long long prev = 0;
    long long cur = 0;
    long long prevInd = finishs.size()-1;
    for (long long i=starts.size()-1; i>=0; i--) {
        long long count = 0;
        long long j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
        int a = 0;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size())
            if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

long long PowerFul(string &s) {
    vector <int> starts;
    FillVector(starts,s,START);
    vector <int> finishs;
    FillVector(finishs,s,FINISH);
    long long counter = 0;
    long long prev = 0;
    long long cur = 0;
    long long prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        long long count = 0;
        long long j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <long long> &vec, string &s, string str) {
    for (long long i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

int PowerFul(string &s) {
    vector <long long> starts;
    FillVector(starts,s,START);
    vector <long long> finishs;
    FillVector(finishs,s,FINISH);
    long long counter = 0;
    long long prev = 0;
    long long cur = 0;
    long long prevInd = finishs.size()-1;
    for (long long i=starts.size()-1; i>=0; i--) {
        long long count = 0;
        long long j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.pushback(i);
}

int PowerFul(string &s) {
    vector <int> starts;
    FillVector(starts,s,START);
    vector <int> finishs;
    FillVector(finishs,s,FINISH);
    int counter = 0;
    int prev = 0;
    int cur = 0;
    int prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        int count = 0;
        int j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count++;
    return count;
}

int PowerFul(string &s) {
    int count = 0;
    int prevEndInd = s.size()-1;
    int startInd = 0;
    int endInd = 0;
    int cur = 0;
    int prev = 0;
    string str;
    string passed;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            startInd = s.size() - i - START.size();
            str = s.substr(startInd,START.size());
            if (str == START) {
                endInd = startInd + START.size() - 1;
                passed = s.substr(endInd,prevEndInd - endInd + 1);
                cur = prev + Endings(passed);
                prev = cur;
                count += cur;
                ((endInd + START.size()) <= s.size()) ? prevEndInd = endInd + START.size() - 1: prevEndInd = endInd;
            }
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

long long PowerFul(string &s) {
    vector <int> starts;
    FillVector(starts,s,START);
    vector <int> finishs;
    FillVector(finishs,s,FINISH);
    long long counter = 0;
    int prev = 0;
    int cur = 0;
    int prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        int count = 0;
        int j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector<int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.add(i);
}

int PowerFul(string &s) {
    vector<int> starts;
    FillVector(starts,s,START);
    vector<int> finishs;
    FillVector(finishs,s,FINISH);
    int counter = 0;
    int prev = 0;
    int cur = 0;
    int prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        int count = 0;
        int j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size())
            if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.add(i);
}

int PowerFul(string &s) {
    vector <int> starts;
    FillVector(starts,s,START);
    vector <int> finishs;
    FillVector(finishs,s,FINISH);
    int counter = 0;
    int prev = 0;
    int cur = 0;
    int prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        int count = 0;
        int j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}

int PowerFul(string &s) {
    int count = 0;
    int prevStartInd = s.size()-1;
    int startInd = 0;
    int endInd = 0;
    string str;
    string passed;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            startInd = s.size() - i - START.size();
            str = s.substr(startInd,START.size());
            if (str == START) {
                endInd = startInd + START.size() - 1;
                passed = s.substr(endInd,prevStartInd - endInd + 1);
                count += count + Endings(passed);
                prevStartInd = startInd;
            }
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count++;
    return count;
}

int PowerFul(string &s) {
    int count = 0;
    int prevEndInd = s.size()-1;
    int startInd = 0;
    int endInd = 0;
    int cur = 0;
    int prev = 0;
    string str;
    string passed;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            startInd = s.size() - i - START.size();
            str = s.substr(startInd,START.size());
            if (str == START) {
                endInd = startInd + START.size() - 1;
                passed = s.substr(endInd,prevEndInd - endInd);
                cur = prev + Endings(passed);
                prev = cur;
                count += cur;
                prevEndInd = endInd;
            }
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

void FillVector(vector <int> &vec, string &s, string str) {
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + str.size())
            if (s.substr(i,str.size()) == str) vec.push_back(i);
}

int PowerFul(string &s) {
    vector <int> starts;
    FillVector(starts,s,START);
    vector <int> finishs;
    FillVector(finishs,s,FINISH);
    int counter = 0;
    int prev = 0;
    int cur = 0;
    int prevInd = finishs.size()-1;
    for (int i=starts.size()-1; i>=0; i--) {
        int count = 0;
        int j;
        for (j = prevInd; j>=0; j--) {
            if (finishs[j] > starts[i]) {
                count ++;
            } else break;
        }
        prevInd = j;
        cur = prev + count;
        prev = cur;
        counter += cur;
    }
    return counter;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            str = s.substr(i+START.size());
            if (s.substr(i,START.size()) == START) count += Endings(str);
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size())
            if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}

int PowerFul(string &s) {
    int count = 0;
    int prevStartInd = s.size()-1;
    int startInd = 0;
    int endInd = 0;
    int cur = 0;
    int prev = 0;
    string str;
    string passed;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            startInd = s.size() - i - START.size();
            str = s.substr(startInd,START.size());
            if (str == START) {
                endInd = startInd + START.size() - 1;
                passed = s.substr(endInd,prevStartInd - endInd + 1);
                cur = prev + Endings(passed);
                prev = cur;
                count += cur;
                prevStartInd = startInd;
            }
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size())
            if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;
const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count++;
    return count;
}

int PowerFul(string &s) {
    int count = 0;
    int prevEndInd = s.size()-1;
    int startInd = 0;
    int endInd = 0;
    int cur = 0;
    int prev = 0;
    string str;
    string passed;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            startInd = s.size() - i - START.size();
            str = s.substr(startInd,START.size());
            if (str == START) {
                endInd = startInd + START.size() - 1;
                passed = s.substr(endInd,prevEndInd - endInd + 1);
                cur = prev + Endings(passed);
                prev = cur;
                count += cur;
                prevEndInd = endInd;
            }
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
#include "simpio.h"
#include "vector.h"
#include "genlib.h"
#include <fstream>
#include "strutils.h"
#include "Set.h"

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
	int count = 0;
	string str;
	for (int i=0; i<s.size(); i++)
		if(s.size() >= i + FINISH.size())
			if (s.substr(i,FINISH.size()) == FINISH) count += 1;
	return count;
}
int PowerFul(string &s) {
	int count = 0;
	for (int i=0; i<s.size(); i++)
		if (s.size() >= i + START.size())
			if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
	return count;
}

int main() {
    string s;
    cin >>s;
    cout << PowerFul(s) << endl;
    return 0;

}


#include <iostream>
using namespace std;
const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size())
            if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size())
            if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
using namespace std;

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}

int PowerFul(string &s) {
    int count = 0;
    int prevStartInd = s.size()-1;
    int startInd = 0;
    int endInd = 0;
    int cur = 0;
    int prev = 0;
    string str;
    string passed;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size()) {
            startInd = s.size() - i - START.size();
            str = s.substr(startInd,START.size());
            if (str == START) {
                endInd = startInd + START.size() - 1;
                passed = s.substr(endInd,prevStartInd - endInd + 1);
                cur = prev + Endings(passed);
                prev = cur;
                count += cur;
                prevStartInd = startInd;
            }
        }
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


#include <iostream>
#include using namespace std

const string START = "heavy";
const string FINISH = "metal";

int Endings(string &s) {
    int count = 0;
    string str;
    for (int i=0; i<s.size(); i++)
        if(s.size() >= i + FINISH.size())
            if (s.substr(i,FINISH.size()) == FINISH) count += 1;
    return count;
}
int PowerFul(string &s) {
    int count = 0;
    for (int i=0; i<s.size(); i++)
        if (s.size() >= i + START.size())
            if (s.substr(i,START.size()) == START) count += Endings(s.substr(i+START.size()));
    return count;
}

int main() {
    string s;
    cin >> s;
    cout << PowerFul(s) << endl;
    return 0;
}


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

int main()
{ string s ;
int n=0 , sum=0 ;  // da enty ms2lh -_- yarab Acc kefia el natega mnakeda 3alya
cin>>s;

for(int i=0 ; i<s.size(); i++)
{
   if(s.substr(i , 5)=="heavy")
   {
       n++; i+=4; }
  if(s.substr(i , 5) == "metal"){
    sum+=n;  i+=4;
  }
    }

cout<<sum;
return 0 ; }


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

int main()
{ string s ;
long long n=0 , sum=0 ;  // da enty ms2lh -_- yarab Acc kefia el natega mnakeda 3alya
cin>>s;

for(int i=0 ; i<s.size(); i++)
{
   if(s.substr(i , 5)=="heavy")
   {
       n++; i+=4; }
  if(s.substr(i , 5) == "metal"){
    sum+=n;  i+=4;
  }
    }

cout<<sum;
return 0 ; }


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

int main()
{  string s ;
cin>>s;
int c=0, i=0 , j=0;               // yarb Accepted  7aga tefar7 badel el natega ely nakdet 3lea :(

while (s.find("heavy" , i)!=-1 )
{      j=int (s.find("heavy" , i)) +2;
      i=int (s.find("heavy" , i)) +2;
  while (s.find("metal" , j)!=-1)
  {
      c++;

      j=int (s.find("metal" , j))+2  ;
  }

 }
 cout<<c;

return 0 ; }


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

int main()
{  string s ;
cin>>s;
int c=0, i=0 , j=0;               // yarb Accepted  7aga tefar7 badel el natega ely nakdet 3lea :(

while (s.find("heavy" , i)!=-1 )
{
  while (s.find("metal" , j)!=-1)
  {
      c++;

      j=int (s.find("metal" , j))+2  ;
  }  i=int (s.find("heavy" , i)) +2;
      j=int (s.find("heavy" , i)) +2;

 }
 cout<<c;

return 0 ; }


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

int main()
{ string s ;
int n=0 , sum=0 ;  // da enty ms2lh -_- yarab Acc kefia el natega mnakeda 3alya
cin>>s;

for(int i=0 ; i<s.size(); i++)
{
    if(s.find("heavy")!=-1)
    { n++; }
    if(s.find("metal")!=-1)
    {sum+=n; }

    s=s.substr(int(s.find("metal")+4)); i=0;
    }

cout<<sum;
return 0 ; }


#include <iostream>
#include <algorithm>

using namespace std;

int main()
{ string s, k  ;
int i , x , c=0;
cin>>s;
k="heavymetal";
i=s.find(k);
if(i==-1)
{ cout<<1;
    return 0;}

if(i==0)
   c++;
    else
    c+=2;

i+=9;

while(1)
{
    if(s.find(k , i)!=-1)
    {
        if(s.find(k , i)>i+1)
        {
            c+=2;    i=s.find(k , i) +10;
        }
        else {
            c++;
            i=s.find(k , i) +10;
        }
    }  else {
        if(i<s.size())
        {
            cout<<c+1;
            return 0;
        } else
        {
            cout<<c;
            return 0;
        }
     }
}

return 0 ; }


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

int main()
{  string s ;
cin>>s;
long long c=0, i=0 , j=0;               // yarb Accepted  7aga tefar7 badel el natega ely nakdet 3lea :(

while (s.find("heavy" , i)!=-1 )
{      j=int (s.find("heavy" , i)) +2;
      i=int (s.find("heavy" , i)) +2;
  while (s.find("metal" , j)!=-1)
  {
      c++;

      j=int (s.find("metal" , j))+2  ;
  }

 }
 cout<<c;

return 0 ; }


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>

using namespace std;
char A[1000000];
int heavy[200000];
int metal[200000];

int main()
{
    string s1,s2;
    s1 = "heavy";
    s2 = "metal";
    string s;
    int i,j,k,l,m,n;
    i = 0;
    cin >> A;
    k = 0;
    l = 0;
    for(i = 0; i + 5 <= strlen(A); i++)
    {
          s = "";
          for(j = i;j < i + 5; j++)
          {
                s += A[j];
          }
          if(s == s1)
          {
               heavy[k] = i;
               k++;
          }
          if(s == s2)
          {
               metal[l] = i;
               l++;
          }
    }
    long long int count = 0;
    for(i = 0; i < k; i++)
    {
          for(j = 0; j < l; j++)
          {
                if(heavy[i] < metal[j])
                {
                        count += l - j;
                        break;
                }
          }
    }
    cout << count << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>

using namespace std;
char A[1000000];
int heavy[200000];
int metal[200000];

int main()
{
    string s1,s2;
    s1 = "heavy";
    s2 = "metal";
    string s;
    int i,j,k,l,m,n;
    i = 0;
    cin >> A;
    k = 0;
    l = 0;
    for(i = 0; i + 5 <= strlen(A); i++)
    {
          s = "";
          for(j = i;j < i + 5; j++)
          {
                s += A[j];
          }
          if(s == s1)
          {
               heavy[k] = i;
               k++;
          }
          if(s == s2)
          {
               metal[l] = i;
               l++;
          }
    }
    long long int count = 0;
    j = 0;
    for(i = 0; i < k; i++)
    {
                while(heavy[i] > metal[j] && j < l)
                {
                        j++;
                }
                count += l - j;
    }
    cout << count << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>

using namespace std;

int heavy[1000000];

int metal[1000000];

int main()
{
    string s1,s2,A;
    s1 = "heavy";
    s2 = "metal";
    string s;
    int i,j,k,l,m,n;
    i = 0;
    cin >> A;
    k = 0;
    l = 0;
    for(i = 0; i + 5 <= A.length(); i++)
    {
          if(A[i] == 'h' || A[i] == 'm')
          {
          s = "";
          for(j = i;j < i + 5; j++)
          {
                s += A[j];
          }
          if(s == s1)
          {
               heavy[k] = i;
               i = i + 4;
               k++;
          }
          if(s == s2)
          {
               metal[l] = i;
               i = i + 4;
               l++;
          }
          }
    }
    long long int sum = 0;
    j = 0;
    for(i = 0; i < k; i++)
    {
          while(heavy[i] > metal[j] && j < l )
          {
                         j++;
          }
          sum += l - j;
    }
    cout << sum << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>

using namespace std;

typedef long long int ll;

char A[1000000];
int heavy[10000];
int metal[10000];

int main()
{
    int i,j,k,l;
    int counter1 = 0;
    int counter2 = 0;
    k = 0;
    l = 0;
    i = 0;
    int chk = 0;
    int chk1 = 0;
    while(1)
    {
            A[i] = getchar();
            if(A[i] == '\n')
            {
                    break;
            }
            if(A[i] == 'h' || chk == 1)
            {
                    counter1++;
                    chk = 1;
                    if(counter1 == 2 && A[i] != 'e')
                    {
                         chk = 0;
                         counter1 = 0;
                    }
                    else if(counter1 == 3 && A[i] != 'a')
                    {
                         chk = 0;
                         counter1 = 0;
                    }
                    else if(counter1 == 4 && A[i] != 'v')
                    {
                         chk = 0;
                         counter1 = 0;
                    }
                    else if(counter1 == 5 && A[i] != 'y')
                    {
                         chk = 0;
                         counter1 = 0;
                    }
                    else if(counter1 == 5 && A[i] == 'y')
                    {
                         chk = 0;
                         heavy[l] = i;
                         l++;
                         counter1 = 0;
                    }
            }
            else if(A[i] == 'm' || chk1 == 1)
            {
                 counter2++;
                 chk1 = 1;
                 if(counter2 == 2 && A[i] != 'e')
                 {
                      chk1 = 0;
                      counter2 = 0;
                 }
                 else if(counter2 == 3 && A[i] != 't')
                 {
                      chk1 = 0;
                      counter2 = 0;
                 }
                 else if(counter2 == 4 && A[i] != 'a')
                 {
                      chk1 = 0;
                      counter2 = 0;
                 }
                 else if(counter2 == 5 && A[i] != 'l')
                 {
                      chk1 = 0;
                      counter2 = 0;
                 }
                 else if(counter2 == 5 && A[i] == 'l')
                 {
                      chk1 = 0;
                      metal[k] = i;
                      k++;
                      counter2 = 0;
                 }
            }
            i++;
    }
    ll count = 0;
    for(i = 0; i < l; i++)
    {
          for(j = 0; j < k; j++)
          {
                if(heavy[i] < metal[j])
                {
                        count += k - j;
                        break;
                }
          }
    }
    printf("%I64d\n",count);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>

using namespace std;
char A[1000000];
int heavy[200000];
int metal[200000];

int main()
{
    string s1,s2;
    s1 = "heavy";
    s2 = "metal";
    string s;
    int i,j,k,l,m,n;
    i = 0;
    while(1)
    {
            A[i] = getchar();
            if(A[i] == '\n')
            {
                    break;
            }
            i++;
    }
    k = 0;
    l = 0;
    for(i = 0; i + 5 <= strlen(A) - 1; i++)
    {
          s = "";
          for(j = i;j < i + 5; j++)
          {
                s += A[j];
          }
          if(s == s1)
          {
               heavy[k] = i;
               k++;
          }
          if(s == s2)
          {
               metal[l] = i;
               l++;
          }
    }
    long long int count = 0;
    for(i = 0; i < k; i++)
    {
          for(j = 0; j < l; j++)
          {
                if(heavy[i] < metal[j])
                {
                        count += l - j;
                        break;
                }
          }
    }
    printf("%I64d\n",count);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>

using namespace std;

typedef long long int ll;

char A[1000000];
int heavy[200000];
int metal[200000];

int main()
{
    int i,j,k,l;
    int counter1 = 0;
    int counter2 = 0;
    k = 0;
    l = 0;
    i = 0;
    int chk = 0;
    int chk1 = 0;
    while(1)
    {
            A[i] = getchar();
            if(A[i] == '\n')
            {
                    break;
            }
            if(A[i] == 'h' || chk == 1)
            {
                    counter1++;
                    chk = 1;
                    if(counter1 == 2 && A[i] != 'e')
                    {
                         chk = 0;
                         counter1 = 0;
                    }
                    else if(counter1 == 3 && A[i] != 'a')
                    {
                         chk = 0;
                         counter1 = 0;
                    }
                    else if(counter1 == 4 && A[i] != 'v')
                    {
                         chk = 0;
                         counter1 = 0;
                    }
                    else if(counter1 == 5 && A[i] != 'y')
                    {
                         chk = 0;
                         counter1 = 0;
                    }
                    else if(counter1 == 5 && A[i] == 'y')
                    {
                         chk = 0;
                         heavy[l] = i;
                         l++;
                         counter1 = 0;
                    }
            }
            else if(A[i] == 'm' || chk1 == 1)
            {
                 counter2++;
                 chk1 = 1;
                 if(counter2 == 2 && A[i] != 'e')
                 {
                      chk1 = 0;
                      counter2 = 0;
                 }
                 else if(counter2 == 3 && A[i] != 't')
                 {
                      chk1 = 0;
                      counter2 = 0;
                 }
                 else if(counter2 == 4 && A[i] != 'a')
                 {
                      chk1 = 0;
                      counter2 = 0;
                 }
                 else if(counter2 == 5 && A[i] != 'l')
                 {
                      chk1 = 0;
                      counter2 = 0;
                 }
                 else if(counter2 == 5 && A[i] == 'l')
                 {
                      chk1 = 0;
                      metal[k] = i;
                      k++;
                      counter2 = 0;
                 }
            }
            i++;
    }
    ll count = 0;
    for(i = 0; i < l; i++)
    {
          for(j = 0; j < k; j++)
          {
                if(heavy[i] < metal[j])
                {
                        count += k - j;
                        break;
                }
          }
    }
    printf("%I64d\n",count);
    return 0;
}


#include<stdio.h>

#include<string.h>
#include<string>
#include<iostream>
using namespace std;
long long d[1000000];
long long e[1000000];
int main()
{
        string a;
        string b;
        string c;
        string f;
        f="metal";
        cin >> a;
        c="heavy";

        long long i,j,k,l,n,m,t;
        m=t=0;
        for(i=0;i<a.length();i++)
        {
                       b="";
                       for(j=i;(j<(i+5))&&(j<a.length());j++)
                       b+=a[j];
                       if(b==c)
                       d[m++]=i;
                       if(b==f)
                       e[t++]=i;
        }
        l=0;
        j=0;
        for(i=0;i<m;i++)
        {
                        while(d[i]>e[j] && j<t)
                        j++;
                        l=l+(t-j);
        }
        cout << l << endl;

        return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>

using namespace std;

char A[1000000];

int heavy[200000];

int metal[200000];

int main()
{
    string s1,s2;
    s1 = "heavy";
    s2 = "metal";
    string s;
    int i,j,k,l,m,n;
    i = 0;
    cin >> A;
    k = 0;
    l = 0;
    for(i = 0; i + 5 <= strlen(A); i++)
    {
          if(A[i] == 'h' || A[i] == 'm')
          {
          s = "";
          for(j = i;j < i + 5; j++)
          {
                s += A[j];
          }
          if(s == s1)
          {
               heavy[k] = i;
               i = i + 4;
               k++;
          }
          if(s == s2)
          {
               metal[l] = i;
               i = i + 4;
               l++;
          }
          }
    }
    long long int sum = 0;
    for(i = 0; i < k; i++)
    {
          for(j = 0; j < l; j++)
          {
                if(heavy[i] < metal[j])
                {
                            sum += l - j;
                            break;
                }
          }
    }
    cout << sum << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>

using namespace std;

int heavy[200000];
int metal[200000];

int main()
{
    string s1,s2;
    s1 = "heavy";
    s2 = "metal";
    string A,s;
    int i,j,k,l,m,n;
    cin >> A;
    k = 0;
    l = 0;
    for(i = 0; i + 5 <= A.length(); i++)
    {
          for(j = i;j < i + 5; j++)
          {
                s += A[j];
          }
          if(s == s1)
          {
               heavy[k] = i;
               k++;
          }
          if(s == s2)
          {
               metal[l] = i;
               l++;
          }
          s.clear();
    }
    long long int count = 0;
    for(i = 0; i < k; i++)
    {
          for(j = 0; j < l; j++)
          {
                if(heavy[i] < metal[j])
                {
                        count += l - j;
                        break;
                }
          }
    }
    printf("%I64d\n",count);
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>

using namespace std;

int main()
{
    char str[1000005];
    int arr[1000005];
    int count=0;
    cin>>str;
    int len = strlen(str);

    for(int i=0;i<len;i++)
    {
        if(str[i]=='h'&&str[i+1]=='e'&&str[i+2]=='a'&&str[i+3]=='v'&&str[i+4]=='y')
        {
            arr[i]=1;
        }

        if(str[i]=='m'&&str[i+1]=='e'&&str[i+2]=='t'&&str[i+3]=='a'&&str[i+4]=='l')
        {
            arr[i]=2;
        }
    }

    for(int i=0;i<len;i++)
    {
        if(arr[i]==1)
        {
            for(int j=i+1;j<len;j++)
            {
                if(arr[j]==2)
                    count++;
            }
        }
    }
//  for(int i=0;i<len;i++)
//      cout<<arr[i];

//      cout<<"\n";

    cout<<count<<endl;

    return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>

using namespace std;

int main()
{
    char str[1000005];
    int arr[1000005]={0};
    long long count=0;
    cin>>str;
    int len = strlen(str);
    int counter=1;
    int flag[100005]={0};
    for(int i=len-1;i>=0;i--)
    {

        if(str[i-4]=='h'&&str[i-3]=='e'&&str[i-2]=='a'&&str[i-1]=='v'&&str[i]=='y')
        {
            arr[i]=1;flag[i]=0;
        }

        if(str[i-4]=='m'&&str[i-3]=='e'&&str[i-2]=='t'&&str[i-1]=='a'&&str[i]=='l')
        {
            arr[i]=counter++;flag[i]=1;
        }
    }
    int metal=0;
    for(int i=len-1;i>=0;i--)
    {
        if(flag[i])
        {
            metal=arr[i];

        }
        if(arr[i]==1 && flag[i]==0)
        {
            count+=(long long)arr[i]*(long long)metal;

        }

    }

    cout<<count<<endl;
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>

using namespace std;

int main()
{
    char str[1000005];
    int arr[1000005]={0};
    int count=0;
    cin>>str;
    int len = strlen(str);
    int counter=1;
    int flag[100005]={0};
    for(int i=len-1;i>=0;i--)
    {

        if(str[i-4]=='h'&&str[i-3]=='e'&&str[i-2]=='a'&&str[i-1]=='v'&&str[i]=='y')
        {
            arr[i]=1;flag[i]=0;
        }

        if(str[i-4]=='m'&&str[i-3]=='e'&&str[i-2]=='t'&&str[i-1]=='a'&&str[i]=='l')
        {
            arr[i]=counter++;flag[i]=1;
        }
    }
    int metal=0;
    for(int i=len-1;i>=0;i--)
    {
        if(flag[i])
        {
            metal=arr[i];

        }
        if(arr[i]==1 && flag[i]==0)
        {
            count+=arr[i]*metal;

        }

    }

    cout<<count<<endl;
    return 0;
}