/***
 *    ██████╗=====███████╗====███████╗====██████╗=
 *    ██╔══██╗====██╔════╝====██╔════╝====██╔══██╗
 *    ██║==██║====█████╗======█████╗======██████╔╝
 *    ██║==██║====██╔══╝======██╔══╝======██╔═══╝=
 *    ██████╔╝====███████╗====███████╗====██║=====
 *    ╚═════╝=====╚══════╝====╚══════╝====╚═╝=====
 *    ============================================
 */

import com.sun.org.apache.xalan.internal.xsltc.dom.ClonedNodeListIterator;
import sun.nio.cs.KOI8_U;

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

public class AD implements Runnable {

    public void run() {
        InputReader sc = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int i=0,j=0,k=0;
        int t=0;
        //t=sc.nextInt();
        for(int testcase = 0; testcase < t; testcase++)
        {
        }

        String str=sc.next();
        String heavy="heavy";
        String metal="metal";

        int strlen=str.length();
        long ans=0;
        int heavycount=0;
        for (i=0;i<strlen-4;i++)
        {
            String temp=str.substring(i,i+5);
            //out.println(str.substring(i,i+5));
            if (temp.equals(heavy))
            {
                heavycount++;
            }
            else if (temp.equals(metal))
            {
                ans+=heavycount;
            }
        }
        out.println(ans);
//================================================================================================================================
        out.flush();
        out.close();
    }

    //================================================================================================================================
    public static int[] sa(int n,InputReader sc)
    {
        int arr[]=new int[n];
        for (int i=0;i<n;i++)
            arr[i]=sc.nextInt();
        return arr;
    }
    public static long gcd(long a,long b){
        return (a%b==0l)?b:gcd(b,a%b);
    }
    private static long lcm(long a, long b)
    {
        return a * (b / gcd(a, b));
    }
    public int egcd(int a, int b) {
        if (a == 0)
            return b;

        while (b != 0) {
            if (a > b)
                a = a - b;
            else
                b = b - a;
        }

        return a;
    }

    public int countChar(String str, char c)
    {
        int count = 0;
        for(int i=0; i < str.length(); i++)
        {    if(str.charAt(i) == c)
            count++;
        }
        return count;
    }
    static int binSearch(Integer[] arr, int number){
        int left=0,right=arr.length-1,mid=(left+right)/2,ind=0;
        while(left<=right){
            if(arr[mid]<=number){
                ind=mid+1;
                left=mid+1;
            }
            else
                right=mid-1;
            mid=(left+right)/2;
        }
        return ind;
    }
    static int binSearch(int[] arr, int number){
        int left=0,right=arr.length-1,mid=(left+right)/2,ind=0;
        while(left<=right){
            if(arr[mid]<=number){
                ind=mid+1;
                left=mid+1;
            }
            else
                right=mid-1;
            mid=(left+right)/2;
        }
        return ind;
    }
    static class Pair
    {
        int a,b;
        Pair(int aa,int bb)
        {
            a=aa;
            b=bb;
        }
        String get()
        {
            return a+" "+b;
        }
        String getrev()
        {
            return b+" "+a;
        }
    }

    static boolean isPrime(long n) {
        if(n < 2) return false;
        if(n == 2 || n == 3) return true;
        if(n%2 == 0 || n%3 == 0) return false;
        long sqrtN = (long)Math.sqrt(n)+1;
        for(long i = 6L; i <= sqrtN; i += 6) {
            if(n%(i-1) == 0 || n%(i+1) == 0) return false;
        }
        return true;
    }
    static long factorial(long n)
    {
        if (n == 0)
            return 1;
        return n*factorial(n-1);
    }
//================================================================================================================================

    static class InputReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    public static void main(String args[]) throws Exception {
        new Thread(null, new AD(),"Main",1<<27).start();
    }
}


/***
 *    ██████╗=====███████╗====███████╗====██████╗=
 *    ██╔══██╗====██╔════╝====██╔════╝====██╔══██╗
 *    ██║==██║====█████╗======█████╗======██████╔╝
 *    ██║==██║====██╔══╝======██╔══╝======██╔═══╝=
 *    ██████╔╝====███████╗====███████╗====██║=====
 *    ╚═════╝=====╚══════╝====╚══════╝====╚═╝=====
 *    ============================================
 */

import sun.nio.cs.KOI8_U;

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

public class AD implements Runnable {

    public void run() {
        InputReader sc = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int i=0,j=0,k=0;
        int t=0;
        //t=sc.nextInt();
        for(int testcase = 0; testcase < t; testcase++)
        {
        }

        String str=sc.next();
        String heavy="heavy";
        String metal="metal";

        int strlen=str.length();
        int ans=0;
        int heavycount=0;
        for (i=0;i<strlen-4;i++)
        {
            String temp=str.substring(i,i+5);
            //out.println(str.substring(i,i+5));
            if (temp.equals(heavy))
            {
                heavycount++;
            }
            else if (temp.equals(metal))
            {
                ans+=heavycount;
            }
        }
        out.println(ans);
//================================================================================================================================
        out.flush();
        out.close();
    }

    //================================================================================================================================
    public static int[] sa(int n,InputReader sc)
    {
        int arr[]=new int[n];
        for (int i=0;i<n;i++)
            arr[i]=sc.nextInt();
        return arr;
    }
    public static long gcd(long a,long b){
        return (a%b==0l)?b:gcd(b,a%b);
    }
    private static long lcm(long a, long b)
    {
        return a * (b / gcd(a, b));
    }
    public int egcd(int a, int b) {
        if (a == 0)
            return b;

        while (b != 0) {
            if (a > b)
                a = a - b;
            else
                b = b - a;
        }

        return a;
    }

    public int countChar(String str, char c)
    {
        int count = 0;
        for(int i=0; i < str.length(); i++)
        {    if(str.charAt(i) == c)
            count++;
        }
        return count;
    }
    static int binSearch(Integer[] arr, int number){
        int left=0,right=arr.length-1,mid=(left+right)/2,ind=0;
        while(left<=right){
            if(arr[mid]<=number){
                ind=mid+1;
                left=mid+1;
            }
            else
                right=mid-1;
            mid=(left+right)/2;
        }
        return ind;
    }
    static int binSearch(int[] arr, int number){
        int left=0,right=arr.length-1,mid=(left+right)/2,ind=0;
        while(left<=right){
            if(arr[mid]<=number){
                ind=mid+1;
                left=mid+1;
            }
            else
                right=mid-1;
            mid=(left+right)/2;
        }
        return ind;
    }
    static class Pair
    {
        int a,b;
        Pair(int aa,int bb)
        {
            a=aa;
            b=bb;
        }
        String get()
        {
            return a+" "+b;
        }
        String getrev()
        {
            return b+" "+a;
        }
    }

    static boolean isPrime(long n) {
        if(n < 2) return false;
        if(n == 2 || n == 3) return true;
        if(n%2 == 0 || n%3 == 0) return false;
        long sqrtN = (long)Math.sqrt(n)+1;
        for(long i = 6L; i <= sqrtN; i += 6) {
            if(n%(i-1) == 0 || n%(i+1) == 0) return false;
        }
        return true;
    }
    static long factorial(long n)
    {
        if (n == 0)
            return 1;
        return n*factorial(n-1);
    }
//================================================================================================================================

    static class InputReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

    public static void main(String args[]) throws Exception {
        new Thread(null, new AD(),"Main",1<<27).start();
    }
}


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

public class Main {

	public static void main(String[] args) throws IOException,InterruptedException{
		Scanner sc=new Scanner(System.in);
		char[] arr=sc.next().toCharArray();
		int c=0;
		ArrayList<Character> arrayList=new ArrayList<>();
		for (int i = 0; i < arr.length-4; i++) {
			String m=arr[i]+""+arr[i+1]+""+arr[i+2]+""+arr[i+3]+""+arr[i+4];
			if (m.equals("heavy")) {
				arrayList.add('h');
			}else if (m.equals("metal")) {
				arrayList.add('m');
			}
		}
		char[] arr2=new char[arrayList.size()];
		int p=0;
		for (char k : arrayList) {
			arr2[p++]=k;
		}
		for (int i = 0; i < arr2.length; i++) {
			if(arr2[i]=='h') {
				for (int j = i+1; j < arr2.length; j++) {
					if(arr2[j]=='m') c++;
				}
			}
		}
		pw.println(c);
		pw.close();
    }
	static HashSet<Long> primes;
	static PrintWriter pw=new PrintWriter(System.out);
	static long pow(int a,int b) {
		long r=1l;
		for (int i = 0; i < b; i++) {
			r*=a;
		}
		return r;
	}
	static void primes() {
		boolean[] freq=new boolean[1000000];
		for (int i = 0; i < freq.length; i++) {
			freq[i]=true;
		}
		primes=new HashSet<>();
		for (int i = 2; i <= 1e3; i++) {
			if(freq[i-1]) {
				for (int j = i*i; j <= 1e6; j+=i) {
					freq[j-1]=false;
				}
			}
		}
		for (int i = 2; i < freq.length; i++) {
			if(freq[i-1]) primes.add((long)(i));
		}
	}
	static long gcd(long x,long y) {
		while (x!=y) {
			if(Math.max(x,y)/Math.min(x,y)==(double)(Math.max(x,y))/Math.min(x,y)) return Math.min(x,y);
			if(primes.contains(x)) {
				if(y/x==y/(double)x) return x;
				else return 1;
			}else if (primes.contains(y)) {
				if(x/y==x/(double)y) return y;
				else return 1;
			}
			if(x>y) x-=y;
			else y-=x;
		}
		return x;
	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}
		public boolean equals(Object o) {
            if (o instanceof pair) {
                pair p = (pair)o;
                return p.x == x && p.y == y;
            }
            return false;
        }
        public int hashCode() {
            return new Double(x).hashCode() * 31 + new Double(y).hashCode();
        }
        public int compareTo(pair other) {
        	if(this.x==other.x) {
        		return Long.compare(this.y, other.y);
        	}
			return Long.compare(this.x, other.x);
		}
	}
	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}
 	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


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

public class Main {

	public static void main(String[] args) throws IOException,InterruptedException{
		Scanner sc=new Scanner(System.in);
		char[] arr=sc.next().toCharArray();
		long c=0,cm=0;
		ArrayList<Character> arrayList=new ArrayList<>();
		for (int i = 0; i < arr.length-4; i++) {
			String m=arr[i]+""+arr[i+1]+""+arr[i+2]+""+arr[i+3]+""+arr[i+4];
			if (m.equals("heavy")) {
				arrayList.add('h');
			}else if (m.equals("metal")) {
				arrayList.add('m');
				cm++;
			}
		}
		char[] arr2=new char[arrayList.size()];
		int p=0;
		for (char k : arrayList) {
			arr2[p++]=k;
		}
		for (int i = 0; i < arr2.length; i++) {
			if(arr2[i]=='h') {
				c+=cm;
			}else {
				cm--;
			}
		}
		pw.println(c);
		pw.close();
    }
	static HashSet<Long> primes;
	static PrintWriter pw=new PrintWriter(System.out);
	static long pow(int a,int b) {
		long r=1l;
		for (int i = 0; i < b; i++) {
			r*=a;
		}
		return r;
	}
	static void primes() {
		boolean[] freq=new boolean[1000000];
		for (int i = 0; i < freq.length; i++) {
			freq[i]=true;
		}
		primes=new HashSet<>();
		for (int i = 2; i <= 1e3; i++) {
			if(freq[i-1]) {
				for (int j = i*i; j <= 1e6; j+=i) {
					freq[j-1]=false;
				}
			}
		}
		for (int i = 2; i < freq.length; i++) {
			if(freq[i-1]) primes.add((long)(i));
		}
	}
	static long gcd(long x,long y) {
		while (x!=y) {
			if(Math.max(x,y)/Math.min(x,y)==(double)(Math.max(x,y))/Math.min(x,y)) return Math.min(x,y);
			if(primes.contains(x)) {
				if(y/x==y/(double)x) return x;
				else return 1;
			}else if (primes.contains(y)) {
				if(x/y==x/(double)y) return y;
				else return 1;
			}
			if(x>y) x-=y;
			else y-=x;
		}
		return x;
	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}
		public boolean equals(Object o) {
            if (o instanceof pair) {
                pair p = (pair)o;
                return p.x == x && p.y == y;
            }
            return false;
        }
        public int hashCode() {
            return new Double(x).hashCode() * 31 + new Double(y).hashCode();
        }
        public int compareTo(pair other) {
        	if(this.x==other.x) {
        		return Long.compare(this.y, other.y);
        	}
			return Long.compare(this.x, other.x);
		}
	}
	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}
 	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


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

public class Main {

	public static void main(String[] args) throws IOException,InterruptedException{
		Scanner sc=new Scanner(System.in);
		char[] arr=sc.next().toCharArray();
		int c=0,cm=0;
		ArrayList<Character> arrayList=new ArrayList<>();
		for (int i = 0; i < arr.length-4; i++) {
			String m=arr[i]+""+arr[i+1]+""+arr[i+2]+""+arr[i+3]+""+arr[i+4];
			if (m.equals("heavy")) {
				arrayList.add('h');
			}else if (m.equals("metal")) {
				arrayList.add('m');
				cm++;
			}
		}
		char[] arr2=new char[arrayList.size()];
		int p=0;
		for (char k : arrayList) {
			arr2[p++]=k;
		}
		for (int i = 0; i < arr2.length; i++) {
			if(arr2[i]=='h') {
				c+=cm;
			}else {
				cm--;
			}
		}
		pw.println(c);
		pw.close();
    }
	static HashSet<Long> primes;
	static PrintWriter pw=new PrintWriter(System.out);
	static long pow(int a,int b) {
		long r=1l;
		for (int i = 0; i < b; i++) {
			r*=a;
		}
		return r;
	}
	static void primes() {
		boolean[] freq=new boolean[1000000];
		for (int i = 0; i < freq.length; i++) {
			freq[i]=true;
		}
		primes=new HashSet<>();
		for (int i = 2; i <= 1e3; i++) {
			if(freq[i-1]) {
				for (int j = i*i; j <= 1e6; j+=i) {
					freq[j-1]=false;
				}
			}
		}
		for (int i = 2; i < freq.length; i++) {
			if(freq[i-1]) primes.add((long)(i));
		}
	}
	static long gcd(long x,long y) {
		while (x!=y) {
			if(Math.max(x,y)/Math.min(x,y)==(double)(Math.max(x,y))/Math.min(x,y)) return Math.min(x,y);
			if(primes.contains(x)) {
				if(y/x==y/(double)x) return x;
				else return 1;
			}else if (primes.contains(y)) {
				if(x/y==x/(double)y) return y;
				else return 1;
			}
			if(x>y) x-=y;
			else y-=x;
		}
		return x;
	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}
		public boolean equals(Object o) {
            if (o instanceof pair) {
                pair p = (pair)o;
                return p.x == x && p.y == y;
            }
            return false;
        }
        public int hashCode() {
            return new Double(x).hashCode() * 31 + new Double(y).hashCode();
        }
        public int compareTo(pair other) {
        	if(this.x==other.x) {
        		return Long.compare(this.y, other.y);
        	}
			return Long.compare(this.x, other.x);
		}
	}
	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}
 	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


/**
 *
 * @author sarthak
 */

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

public class rnd188_B {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
static class P implements Comparable{

        private int x, y;

        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x * 31) ^ y;
        }

        public boolean equals(Object o) {
            if (o instanceof P) {
                P other = (P) o;
                return (x == other.x && y == other.y);
            }
            return false;
        }
        public int compareTo(Object obj) {
		P l = (P) obj;
		if (this.x == l.x){
			if (this.y == l.y) return 0;
			return (this.y < l.y)? -1: 1;
		}
		return (this.x < l.x)? -1: 1;
	}
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);
    StringBuilder op=new StringBuilder();

    String ip=s.next();;
    ArrayList<Integer> hs=new ArrayList<>();
    ArrayList<Integer> ms=new ArrayList<>();
    int len=ip.length();
    for(int i=0;i<len;i++){
        if(ip.charAt(i)=='h'&&i+4<len&&ip.substring(i, i+5).equals("heavy"))
            hs.add(i);
    }
    for(int i=0;i<len;i++){
        if(ip.charAt(i)=='m'&&i+4<len&&ip.substring(i, i+5).equals("metal"))
            ms.add(i);
    }
    int i=0;
    int j=0;
    int an=0;
    while(j<ms.size()&&i<hs.size()){
        while(j<ms.size()&&hs.get(i)>ms.get(j))
            j++;
        if(j==ms.size())
            break;
        an+=ms.size()-j;
        i++;

    }
    System.out.println(an);

    }
}


/**
 *
 * @author sarthak
 */

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

public class rnd188_B {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
static class P implements Comparable{

        private int x, y;

        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x * 31) ^ y;
        }

        public boolean equals(Object o) {
            if (o instanceof P) {
                P other = (P) o;
                return (x == other.x && y == other.y);
            }
            return false;
        }
        public int compareTo(Object obj) {
		P l = (P) obj;
		if (this.x == l.x){
			if (this.y == l.y) return 0;
			return (this.y < l.y)? -1: 1;
		}
		return (this.x < l.x)? -1: 1;
	}
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);
    StringBuilder op=new StringBuilder();

    String ip=s.next();;
    ArrayList<Integer> hs=new ArrayList<>();
    ArrayList<Integer> ms=new ArrayList<>();
    int len=ip.length();
    for(int i=0;i<len;i++){
        if(ip.charAt(i)=='h'&&i+4<len&&ip.substring(i, i+5).equals("heavy"))
            hs.add(i);
    }
    for(int i=0;i<len;i++){
        if(ip.charAt(i)=='m'&&i+4<len&&ip.substring(i, i+5).equals("metal"))
            ms.add(i);
    }
    int i=0;
    int j=0;
    long an=0;
    while(j<ms.size()&&i<hs.size()){
        while(j<ms.size()&&hs.get(i)>ms.get(j))
            j++;
        if(j>=ms.size())
            break;
        an+=(long)ms.size()-(long)j;
        i++;

    }
    System.out.println(an);

    }
}


import java.io.*;

public class CF318B {
	static int indexOf(char[] aa, char[] bb, int s) {
		int n = aa.length, m = bb.length;
		for (int i = s; i <= n - m; i++) {
			boolean equal = true;
			for (int j = 0; j < m; j++)
				if (aa[i + j] != bb[j]) {
					equal = false;
					break;
				}
			if (equal)
				return i;
		}
		return -1;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] aa = br.readLine().toCharArray();
		char[] hh = "heavy".toCharArray();
		char[] mm = "metal".toCharArray();
		int n = aa.length;
		int i = -1, j = -1, i_, j_, h = 0;
		long k = 0;
		while ((j_ = indexOf(aa, mm, j + 1)) >= 0) {
			j = j_;
			while (i < j && (i_ = indexOf(aa, hh, i + 1)) >= 0) {
				i = i_;
				h++;
			}
			k += i < j ? h : h - 1;
		}
		System.out.println(k);
	}
}


import java.io.*;

public class CF318B {
	static int indexOf(String s, String t, int i, int n) {
		return (i = s.indexOf(t, i)) < 0 ? n : i;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int n = s.length(), h = 0, i = -1, j = -1;
		long k = 0;
		while ((j = indexOf(s, "metal", j + 1, n)) < n) {
			while (i < j && (i = indexOf(s, "heavy", i + 1, n)) < n)
				h++;
			k += i < j || i == n ? h : h - 1;
		}
		System.out.println(k);
	}
}


import java.io.*;

public class CF318B {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int n = s.length();
		int i = -1, j = -1, i_, j_, h = 0;
		long k = 0;
		while ((j_ = s.indexOf("metal", j + 1)) >= 0) {
			j = j_;
			while (i < j && (i_ = s.indexOf("heavy", i + 1)) >= 0) {
				i = i_;
				h++;
			}
			k += i < j ? h : h - 1;
		}
		System.out.println(k);
	}
}


import java.io.*;

public class CF318B {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int n = s.length();
		int i = -1, j = -1, i_, j_, h = 0, k = 0;
		while ((j_ = s.indexOf("metal", j + 1)) >= 0) {
			j = j_;
			while (i < j && (i_ = s.indexOf("heavy", i + 1)) >= 0) {
				i = i_;
				h++;
			}
			k += i < j ? h : h - 1;
		}
		System.out.println(k);
	}
}


import java.util.Scanner;

/**
 * Created by amayorov on 10.09.2014.
 */
public class Codeforces318B {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        int st_index = str.indexOf("heavy", 0);

        long points = 0;

        while (st_index != -1) {
            int end_index = st_index;
            while (end_index != -1) {
                end_index = str.indexOf("metal", end_index + 5);
                points += end_index != -1 ? 1 : 0;
            }

            st_index = str.indexOf("heavy", st_index + 5);
        }

        System.out.println(points);
    }

}


import java.util.Scanner;

/**
 * Created by amayorov on 10.09.2014.
 */
public class Codeforces318B {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        int st_index = str.indexOf("heavy", 0);
        int end_index = st_index;

        long points = 0;
        long sts = 1;

        int next_st = 0;

        while (true) {
            int next_end = str.indexOf("metal", end_index + 5);

            if (next_st != -1) {
                next_st = str.indexOf("heavy", st_index + 5);
            }

            if (next_end == -1) {
                break;
            }

            if (next_st == -1 || next_end < next_st) {
                points += sts;
                end_index = next_end;
            } else {
                st_index = next_st;
                sts++;
            }
        }

        System.out.println(points);
    }

}


import java.util.Scanner;

/**
 * Created by amayorov on 10.09.2014.
 */
public class Codeforces318B {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        int st_index = str.indexOf("heavy", 0);
        int end_index = st_index;

        long points = 0;
        long sts = 1;

        while (true) {
            int next_end = str.indexOf("metal", end_index + 5);
            int next_st = str.indexOf("heavy", st_index + 5);

            if (next_end == -1) {
                break;
            }
            if (next_st == -1) {
                next_st = Integer.MAX_VALUE;
            }

            if (next_end < next_st) {
                points += sts;
                end_index = next_end;
            } else {
                st_index = next_st;
                sts++;
            }
        }

        System.out.println(points);
    }

}


import java.util.ArrayList;
import java.util.Scanner;

public class _318B {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		ArrayList<Integer> heavyIndexes = new ArrayList<Integer>();
		ArrayList<Integer> metalIndexes = new ArrayList<Integer>();
		int idx = s.indexOf("heavy");
		while (idx != -1) {
			heavyIndexes.add(idx);
			idx = s.indexOf("heavy", idx + 5);
		}
		idx = s.indexOf("metal");
		while (idx != -1) {
			metalIndexes.add(idx);
			idx = s.indexOf("metal", idx + 5);
		}
		long subStringCount = 0;
		int previousJ = 0;
		for (int i = 0; i < heavyIndexes.size(); i++) {
			for (int j = previousJ; j < metalIndexes.size(); j++) {
				if (heavyIndexes.get(i) < metalIndexes.get(j)) {
					subStringCount += metalIndexes.size() - j;
					previousJ = j;
					break;
				}
			}
		}
		System.out.println(subStringCount);
		scan.close();
	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class _318B {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		ArrayList<Integer> heavyIndexes = new ArrayList<Integer>();
		ArrayList<Integer> metalIndexes = new ArrayList<Integer>();
		int idx = s.indexOf("heavy");
		while (idx != -1) {
			heavyIndexes.add(idx);
			idx = s.indexOf("heavy", idx + 5);
		}
		idx = s.indexOf("metal");
		while (idx != -1) {
			metalIndexes.add(idx);
			idx = s.indexOf("metal", idx + 5);
		}
		int subStringCount = 0;
		int previousJ = 0;
		for (int i = 0; i < heavyIndexes.size(); i++) {
			for (int j = previousJ; j < metalIndexes.size(); j++) {
				if (heavyIndexes.get(i) < metalIndexes.get(j)) {
					subStringCount += metalIndexes.size() - i;
					previousJ = j;
					break;
				}
			}
		}
		System.out.println(subStringCount);
		scan.close();
	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class _318B {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		ArrayList<Integer> heavyIndexes = new ArrayList<Integer>();
		ArrayList<Integer> metalIndexes = new ArrayList<Integer>();
		int idx = s.indexOf("heavy");
		while (idx != -1) {
			heavyIndexes.add(idx);
			idx = s.indexOf("heavy", idx + 5);
		}
		idx = s.indexOf("metal");
		while (idx != -1) {
			metalIndexes.add(idx);
			idx = s.indexOf("metal", idx + 5);
		}
		int subStringCount = 0;
		int previousJ = 0;
		for (int i = 0; i < heavyIndexes.size(); i++) {
			for (int j = previousJ; j < metalIndexes.size(); j++) {
				if (heavyIndexes.get(i) < metalIndexes.get(j)) {
					subStringCount += metalIndexes.size() - j;
					previousJ = j;
					break;
				}
			}
		}
		System.out.println(subStringCount);
		scan.close();
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		int i=0,j=0,k=0,t1=0,t2=0,t3=0,t4=0;
		long s=0;
		ArrayList<Character> al=new ArrayList<Character>();
		for ( i = 0; i + 5 <= p.length(); i++) {
		      String sub = p.substring(i, i + 5);
		      if (sub.equals(q))
		        al.add('h');
		      else if (sub.equals(r))
		        al.add('m');
		    }
		int cnt=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=(int)cnt;
		}
		System.out.println(s+"   "+al.size());
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		ArrayList<Character> al=new ArrayList<Character>();
		int i=0,j=0,k=0,t1=0,t2=0;
		for( ;i<p.length();i++)
		{
			j=0;
			k=0;
			t1=i;
			while(i<p.length() && j<q.length() && p.charAt(i)==q.charAt(j))
			{
				i++;
				j++;
			}
			if(j==q.length())
				al.add('h');
			else
			{
				i=t1;
				j=0;
				k=0;
			}
			t2=i;
			while(i<p.length() && k<r.length() && p.charAt(i)==r.charAt(k))
			{
				i++;
				k++;
			}
			if(k==r.length())
			{
				al.add('m');
				i--;
			}
			else
			{
				i=t2;
				k=0;
				j=0;
			}
		}
		long cnt=0,s=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=cnt;
		}
		System.out.println(s);
		if(p.charAt(0)=='v')
		{
			System.out.println();
			System.out.println(al);
			System.out.println(cnt);
		}
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		ArrayList<Character> al=new ArrayList<Character>();
		int i=0,j=0,k=0,t1,t2;
		long s=0;
		for( ;i<p.length();i++)
		{
			j=0;
			k=0;
			t1=i;
			while(i<p.length() && j<q.length() && p.charAt(i)==q.charAt(j))
			{
				i++;
				j++;
			}
			if(j==q.length())
				al.add('h');
			else i=t1;
			t2=i;
			while(i<p.length() && k<r.length() && p.charAt(i)==r.charAt(k))
			{
				i++;
				k++;
			}
			if(k==r.length())
			{
				al.add('m');
				i--;
			}
			else
				i=t2;
		}
		int cnt=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=(long)cnt;
		}
		System.out.println(s);
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		ArrayList<Character> al=new ArrayList<Character>();
		int i=0,j=0,k=0,t1=0,t2=0,t3=0,t4=0;
		long s=0;
		for( ;i<p.length();i++)
		{
			t1=0;
			t2=0;
			t3=0;
			t4=0;
			j=0;
			k=0;
			while(i<p.length() && j<q.length() && p.charAt(i)==q.charAt(j))
			{
				t1=1;
				i++;
				j++;
			}
			if(j==q.length())
			{
				t2=1;
				al.add('h');
			}
			if(t1==1 && t2==0)
				i--;
			while(i<p.length() && k<r.length() && p.charAt(i)==r.charAt(k))
			{
				t3=1;
				i++;
				k++;
			}
			if(k==r.length())
			{
				t4=1;
				al.add('m');
				i--;
			}
			if(t3==1 && t4==0)
				i--;
		}
		int cnt=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=(long)cnt;
		}
		System.out.println(s);
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		ArrayList<Character> al=new ArrayList<Character>();
		int i=0,j=0,k=0,t1=0,t2=0,t3=0,t4=0;
		long s=0;
		for( ;i<p.length();i++)
		{
			t1=0;
			t2=0;
			j=0;
			k=0;
			t1=i;
			while(t1<p.length() && j<q.length() && p.charAt(t1)==q.charAt(j))
			{
				t1++;
				j++;
			}
			if(j==q.length())
			{
				al.add('h');
			}
			t2=i;
			while(t2<p.length() && k<r.length() && p.charAt(t2)==r.charAt(k))
			{
				t2++;
				k++;
			}
			if(k==r.length())
			{
				al.add('m');
			}
		}
		int cnt=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=(int)cnt;
		}
		System.out.println(s);
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		ArrayList<Character> al=new ArrayList<Character>();
		int i=0,j=0,k=0,t1=0,t2=0;
		for( ;i<p.length();i++)
		{
			j=0;
			k=0;
			t1=i;
			while(i<p.length() && j<q.length() && p.charAt(i)==q.charAt(j))
			{
				i++;
				j++;
			}
			if(j==q.length())
				al.add('h');
			else
			{
				i=t1;
				j=0;
				k=0;
			}
			t2=i;
			while(i<p.length() && k<r.length() && p.charAt(i)==r.charAt(k))
			{
				i++;
				k++;
			}
			if(k==r.length())
			{
				al.add('m');
				i--;
			}
			else
			{
				i=t2;
				k=0;
				j=0;
			}
		}
		long cnt=0,s=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=cnt;
		}
		System.out.println(al+" "+s);
		if(p.charAt(0)=='v')
		{
			System.out.println();
			System.out.println(cnt);
		}
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		ArrayList<Character> al=new ArrayList<Character>();
		int i=0,j=0,k=0,t1=0,t2=0,t3=0,t4=0;
		long s=0;
		for( ;i<p.length();i++)
		{
			t1=0;
			t2=0;
			t3=0;
			t4=0;
			j=0;
			k=0;
			while(i<p.length() && j<q.length() && p.charAt(i)==q.charAt(j))
			{
				t1=1;
				i++;
				j++;
			}
			if(j==q.length())
			{
				t2=1;
				al.add('h');
			}
			if(t1==1 && t2==0)
				i--;
			while(i<p.length() && k<r.length() && p.charAt(i)==r.charAt(k))
			{
				t3=1;
				i++;
				k++;
			}
			if(k==r.length())
			{
				t4=1;
				al.add('m');
				i--;
			}
			if(t3==1 && t4==0)
				i--;
		}
		int cnt=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=(int)cnt;
		}
		System.out.println(s);
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		int i=0,j=0,k=0,t1=0,t2=0,t3=0,t4=0;
		long s=0;
		ArrayList<Character> al=new ArrayList<Character>();
		for ( i = 0; i + 5 <= p.length(); i++) {
		      String sub = p.substring(i, i + 5);
		      if (sub.equals(q))
		        al.add('h');
		      else if (sub.equals(r))
		        al.add('m');
		    }
		int cnt=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=(int)cnt;
		}
		System.out.println(s);
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		int i=0,j=0,k=0,t1=0,t2=0,t3=0,t4=0;
		long s=0;
		ArrayList<Character> al=new ArrayList<Character>();
		for ( i = 0; i + 5 <= p.length(); i++) {
		      String sub = p.substring(i, i + 5);
		      if (sub.equals(q))
		        al.add('h');
		      else if (sub.equals(r))
		        al.add('m');
		    }
		int cnt=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=(int)cnt;
		}
		System.out.println(s);
		if(p.charAt(0)=='v')
			System.out.println(al.size());
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


/*
 * Code Author: Jayesh Udhani
 * Dhirubhai Ambani Institute of Information and Communication Technology (DA-IICT ,Gandhinagar)
 * 2nd Year ICT BTECH Student
 */
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------My Code Starts Here----------
		String p=in.next();
		String q="heavy";
		String r="metal";
		ArrayList<Character> al=new ArrayList<Character>();
		int i=0,j=0,k=0,t1=0,t2=0,t3=0,t4=0;
		long s=0;
		for( ;i<p.length();i++)
		{
			t1=0;
			t2=0;
			t3=0;
			t4=0;
			j=0;
			k=0;
			while(i<p.length() && j<q.length() && p.charAt(i)==q.charAt(j))
			{
				t1=1;
				i++;
				j++;
			}
			if(j==q.length())
			{
				t2=1;
				al.add('h');
			}
			if(t1==1 && t2==0)
				i--;
			while(i<p.length() && k<r.length() && p.charAt(i)==r.charAt(k))
			{
				t3=1;
				i++;
				k++;
			}
			if(k==r.length())
			{
				t4=1;
				al.add('m');
				i--;
			}
			if(t3==1 && t4==0)
				i--;
		}
		int cnt=0;
		for(i=0;i<al.size();i++)
		{
			if(al.get(i)=='h')
				cnt++;
			if(al.get(i)=='m')
				s+=(long)cnt;
		}
		System.out.println(s);
		if(p.charAt(0)=='v')
		    System.out.println(al.size());
		out.close();
		//---------------The End———————————————————
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


import java.util.Scanner;

public class StringsOfPower {

    static int lps[];
    static int flags[];
    static String text;
    static String pattern;

    public static void computeLPS() {
        lps = new int[pattern.length()];
        int i = 1;
        int len = 0;

        while (i < pattern.length()) {
            if (pattern.charAt(i) == pattern.charAt(len)) {
                len++;
                lps[i] = len;
                i++;
            } else {
                if (len != 0)
                    len = lps[len - 1];
                else {
                    lps[i] = 0;
                    i++;
                }
            }
        }

    }

    public static void KMPSearch() {
        int i = 0;
        int j = 0;

        while (i < text.length()) {
            if (text.charAt(i) == pattern.charAt(j)) {
                i++;
                j++;
            }
            if (j == pattern.length()) {
                if (pattern.equals("heavy"))
                    flags[i - j] = 1; // heavy
                else
                    flags[i - j] = -1; // metal
                j = lps[j - 1];
            } else if (i < text.length() && pattern.charAt(j) != text.charAt(i)) {

                if (j != 0)
                    j = lps[j - 1];
                else
                    i = i + 1;
            }

        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        text = sc.nextLine();
        flags = new int[text.length()];
        pattern = "heavy";
        computeLPS();
        KMPSearch();
        pattern = "metal";
        computeLPS();
        KMPSearch();
        int occ = 0;
        for (int i = 0; i < flags.length; i++) {
            if (flags[i] == 1) {
                for (int j = i + 1; j < flags.length; j++)
                    if (flags[j] == -1)
                        occ++;
            }
        }
        System.out.println(occ);
    }
}


import java.util.Scanner;

public class StringsOfPower {

    public static void main(String[] args) {
        long sum =0 ;
        long fo = 0;
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for (int i = 0; i < s.length(); i++) {
            if(i+5 <= s.length()){
                String comp = s.substring(i, i+5);
            if(comp.equals("heavy")) fo++;
            else
                if(comp.equals("metal")) sum+=fo;
            }
        }
        System.out.println(sum);
    }
}


import java.util.Scanner;

public class StringsOfPower {

    public static void main(String[] args) {
        int sum =0 ;
        int fo = 0;
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for (int i = 0; i < s.length(); i++) {
            if(i+5 <= s.length()){
                String comp = s.substring(i, i+5);
            if(comp.equals("heavy")) fo++;
            else
                if(comp.equals("metal")) sum+=fo;
            }
        }
        System.out.println(sum);
    }
}


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

public class SoP {

    static String input;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        input = br.readLine();
        int heavy = 0, total = 0;
        boolean ans;
        for (int i = 0; i < input.length()-4; i++) {
            if (input.charAt(i)=='h') {
                ans = analyze(i, "heavy");
                if (ans) heavy++;
            } else if (input.charAt(i) == 'm') {
                ans = analyze(i, "metal");
                if (ans) total+=heavy;
            }
        }
        System.out.println(total);
    }

    private static boolean analyze(int i, String string) {
        for (int j = i; j < i+5; j++) {
            if (input.charAt(j) != string.charAt(j-i)) return false;
        }
        return true;
    }

}


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

public class SoP {

    static String input;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        input = br.readLine();
        long heavy = 0, total = 0;
        boolean ans;
        for (int i = 0; i < input.length()-4; i++) {
            if (input.charAt(i)=='h') {
                ans = analyze(i, "heavy");
                if (ans) heavy++;
            } else if (input.charAt(i) == 'm') {
                ans = analyze(i, "metal");
                if (ans) total+=heavy;
            }
        }
        System.out.println(total);
    }

    private static boolean analyze(int i, String string) {
        for (int j = i; j < i+5; j++) {
            if (input.charAt(j) != string.charAt(j-i)) return false;
        }
        return true;
    }

}


import java.util.*;
public class StringsOfPower {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int l=s.length(),c1=0,d=0;
		for(int i=0;i<l;i++)
		{
			char c=s.charAt(i);
			if(c=='h')
			{
				String s1=s.substring(i, i+5);
				if(s1.equals("heavy"))
				{
					c1++;
					i=i+4;
				}
			}
			else if(c=='m' && c1>0)
			{
				String s1=s.substring(i, i+5);
				if(s1.equals("metal"))
				{
					d=d+(c1*1);
					i=i+4;
				}

			}
		}
		System.out.println(d);
	}

}


import java.util.*;
public class StringsOfPower {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int l=s.length(),c1=0,d=0;
		for(int i=0;i<l;i++)
		{
			char c=s.charAt(i);
			if(c=='h' && i<=(l-5))
   		{
				String s1=s.substring(i, i+5);
				if(s1.equals("heavy"))
				{
					c1++;
					i=i+4;
				}
			}
			else if(c=='m' && c1>0 && i<=l-5)
			{
				String s1=s.substring(i, i+5);
				if(s1.equals("metal"))
				{
					d=d+(c1*1);
					i=i+4;
				}

			}
		}
		System.out.println(d);
	}

}


import java.util.*;
public class StringsOfPower {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int l=s.length(),c1=0,d=0;
		for(int i=0;i<l;i++)
		{
			char c=s.charAt(i);
			if(c=='h' && i>=l-5)
			{
				String s1=s.substring(i, i+5);
				if(s1.equals("heavy"))
				{
					c1++;
					i=i+4;
				}
			}
			else if(c=='m' && c1>0 && i>=l-5)
			{
				String s1=s.substring(i, i+5);
				if(s1.equals("metal"))
				{
					d=d+(c1*1);
					i=i+4;
				}

			}
		}
		System.out.println(d);
	}

}


import java.util.*;
public class StringsOfPower {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int l=s.length();
		long c1=0,d=0;
		for(int i=0;i<l;i++)
		{
			char c=s.charAt(i);
			if(c=='h' && i<=(l-5))
   		{
				String s1=s.substring(i, i+5);
				if(s1.equals("heavy"))
				{
					c1++;
					i=i+4;
				}
			}
			else if(c=='m' && c1>0 && i<=l-5)
			{
				String s1=s.substring(i, i+5);
				if(s1.equals("metal"))
				{
					d=d+(c1*1);
					i=i+4;
				}

			}
		}
		System.out.println(d);
	}

}


import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		//long time1 = System.nanoTime();

		//StringBuilder s = new StringBuilder(input);
		//long time2 = System.nanoTime();

		ArrayList<Integer> heavyList = findAll(s, "heavy");
		ArrayList<Integer> metalList = findAll(s, "metal");
		//long time3 = System.nanoTime();

		/*for(int i = 0; i < heavyList.size(); i++)
			System.out.print(heavyList.get(i) + ", ");
		System.out.println();
		for(int i = 0; i < metalList.size(); i++)
			System.out.print(metalList.get(i) + ", ");
		System.out.println();*/

		long heavyCount = 0; //total occurrences of 'heavy'
		long total = 0; //total substrings found
		int heavyPoint = 0;
		int metalPoint = 0;
		while(heavyPoint < heavyList.size() && metalPoint < metalList.size())
		{
			//If metal comes before heavy, we shift the metal pointer and
			//add the previous counts of heavy
			if(heavyList.get(heavyPoint) > metalList.get(metalPoint))
			{
				total += heavyCount;
				metalPoint += 1;
			}
			//If heavy comes before metal, we pop from the heavy list and
			//increment the counts of heavy
			else if(metalList.get(metalPoint) > heavyList.get(heavyPoint))
			{
				heavyCount += 1;
				heavyPoint += 1;
			}
		}
		total += heavyCount*(metalList.size() - metalPoint);
		System.out.println(total);
		//long time4 = System.nanoTime();

		/*System.out.println("Creating string: " + Long.toString(time2 - time1));
		System.out.println("Searching string: " + Long.toString(time3 - time2));
		System.out.println("Shifting pointers: " + Long.toString(time4 - time3));*/
	}

	public static ArrayList<Integer> findAll(String s, String sub)
	{
		ArrayList<Integer> result = new ArrayList<Integer>();
		int currLoc = 0;
		while(true)
		{
			int loc = s.indexOf(sub, currLoc);
			if(loc >= 0)
			{
				result.add(loc);
				currLoc = loc + 1;
			}
			else break;
		}

		return result;
	}
}


import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		ArrayList<Integer> heavyList = Search(s, "heavy");
		ArrayList<Integer> metalList = Search(s, "metal");
		int heavyCount = 0; //total occurrences of 'heavy'
		int total = 0; //total substrings found
		int heavyPoint = 0;
		int metalPoint = 0;
		while(heavyPoint < heavyList.size() && metalPoint < metalList.size())
		{
			//If metal comes before heavy, we shift the metal pointer and
			//add the previous counts of heavy
			if(heavyList.get(heavyPoint) > metalList.get(metalPoint))
			{
				total += heavyCount;
				metalPoint += 1;
			}
			//If heavy comes before metal, we pop from the heavy list and
			//increment the counts of heavy
			else if(metalList.get(metalPoint) > heavyList.get(heavyPoint))
			{
				heavyCount += 1;
				heavyPoint += 1;
			}
		}
		total += heavyCount*(metalList.size() - metalPoint);
		System.out.println(total);

	}

	public static ArrayList<Integer> Search(String s, String sub)
	{
		ArrayList<Integer> result = new ArrayList<Integer>();
		int currLoc = 0;
		while(true)
		{
			int loc = s.indexOf(sub);
			if(loc >= 0)
			{
				result.add(loc + currLoc);
				s = s.substring(loc + 1);
				currLoc += loc + 1;
			}
			else break;
		}

		return result;
	}

/*
#Returns a list of the occurrences of substr in str
def search(s, sub):
	res = []
	stop = False
	currLoc = 0
	while(True):
		#print(s)
		loc = s.find(sub)
		if(loc >= 0):
			res.append(loc + currLoc)
			s = s[loc + 1:]
			currLoc += loc + 1
		else:
			break

	return res

if __name__ == '__main__':
	s = input()
	#s = 'heavymetal'*100000
	loc1 = search(s, 'heavy')
	loc2 = search(s, 'metal')
	heavyCount = 0 #total occurrences of 'heavy'
	total = 0 #total substrings found
	heavyPoint = 0
	metalPoint = 0
	while(heavyPoint < len(loc1) and metalPoint < len(loc2)):
		#If metal comes before heavy, we shift the metal pointer and
		#add the previous counts of heavy
		if(loc1[heavyPoint] > loc2[metalPoint]):
			total += heavyCount
			metalPoint += 1
		#If heavy comes before metal, we pop from the heavy list and
		#increment the counts of heavy
		elif(loc2[metalPoint] > loc1[heavyPoint]):
			heavyCount += 1
			heavyPoint += 1

	total += heavyCount*(len(loc2) - metalPoint)

	print(total)
*/
}


import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		//long time1 = System.nanoTime();

		StringBuilder s = new StringBuilder(input);
		//long time2 = System.nanoTime();

		ArrayList<Integer> heavyList = findAll(s, "heavy");
		ArrayList<Integer> metalList = findAll(s, "metal");
		//long time3 = System.nanoTime();

		/*for(int i = 0; i < heavyList.size(); i++)
			System.out.print(heavyList.get(i) + ", ");
		System.out.println();
		for(int i = 0; i < metalList.size(); i++)
			System.out.print(metalList.get(i) + ", ");
		System.out.println();*/

		int heavyCount = 0; //total occurrences of 'heavy'
		int total = 0; //total substrings found
		int heavyPoint = 0;
		int metalPoint = 0;
		while(heavyPoint < heavyList.size() && metalPoint < metalList.size())
		{
			//If metal comes before heavy, we shift the metal pointer and
			//add the previous counts of heavy
			if(heavyList.get(heavyPoint) > metalList.get(metalPoint))
			{
				total += heavyCount;
				metalPoint += 1;
			}
			//If heavy comes before metal, we pop from the heavy list and
			//increment the counts of heavy
			else if(metalList.get(metalPoint) > heavyList.get(heavyPoint))
			{
				heavyCount += 1;
				heavyPoint += 1;
			}
		}
		total += heavyCount*(metalList.size() - metalPoint);
		System.out.println(total);
		//long time4 = System.nanoTime();

		/*System.out.println("Creating string: " + Long.toString(time2 - time1));
		System.out.println("Searching string: " + Long.toString(time3 - time2));
		System.out.println("Shifting pointers: " + Long.toString(time4 - time3));*/
	}

	public static ArrayList<Integer> findAll(StringBuilder s, String sub)
	{
		ArrayList<Integer> result = new ArrayList<Integer>();
		int currLoc = 0;
		while(true)
		{
			int loc = s.indexOf(sub, currLoc);
			if(loc >= 0)
			{
				result.add(loc);
				currLoc = loc + 1;
			}
			else break;
		}

		return result;
	}
}


import java.util.Scanner;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		//long time1 = System.nanoTime();

		StringBuilder s = new StringBuilder(input);
		//long time2 = System.nanoTime();

		ArrayList<Integer> heavyList = findAll(s, "heavy");
		ArrayList<Integer> metalList = findAll(s, "metal");
		//long time3 = System.nanoTime();

		/*for(int i = 0; i < heavyList.size(); i++)
			System.out.print(heavyList.get(i) + ", ");
		System.out.println();
		for(int i = 0; i < metalList.size(); i++)
			System.out.print(metalList.get(i) + ", ");
		System.out.println();*/

		long heavyCount = 0; //total occurrences of 'heavy'
		long total = 0; //total substrings found
		int heavyPoint = 0;
		int metalPoint = 0;
		while(heavyPoint < heavyList.size() && metalPoint < metalList.size())
		{
			//If metal comes before heavy, we shift the metal pointer and
			//add the previous counts of heavy
			if(heavyList.get(heavyPoint) > metalList.get(metalPoint))
			{
				total += heavyCount;
				metalPoint += 1;
			}
			//If heavy comes before metal, we pop from the heavy list and
			//increment the counts of heavy
			else if(metalList.get(metalPoint) > heavyList.get(heavyPoint))
			{
				heavyCount += 1;
				heavyPoint += 1;
			}
		}
		total += heavyCount*(metalList.size() - metalPoint);
		System.out.println(total);
		//long time4 = System.nanoTime();

		/*System.out.println("Creating string: " + Long.toString(time2 - time1));
		System.out.println("Searching string: " + Long.toString(time3 - time2));
		System.out.println("Shifting pointers: " + Long.toString(time4 - time3));*/
	}

	public static ArrayList<Integer> findAll(StringBuilder s, String sub)
	{
		ArrayList<Integer> result = new ArrayList<Integer>();
		int currLoc = 0;
		while(true)
		{
			int loc = s.indexOf(sub, currLoc);
			if(loc >= 0)
			{
				result.add(loc);
				currLoc = loc + 1;
			}
			else break;
		}

		return result;
	}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */public final
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		s = s.replace("heavy","1");
		s = s.replace("metal","2");
		long c = 0;
		long sum = 0;
		for(int i=s.length()-1;i>=0;i--){
		     if(s.charAt(i)=='2')
		          c++;
		     else if(s.charAt(i)=='1'){
		          sum+=c;
		     }
		}
		System.out.println(sum);

	}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */public final
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		s = s.replace("heavy","1");
		s = s.replace("metal","2");
		int c = 0;
		int sum = 0;
		for(int i=s.length()-1;i>=0;i--){
		     if(s.charAt(i)=='2')
		          c++;
		     else if(s.charAt(i)=='1'){
		          sum+=c;
		     }
		}
		System.out.println(sum);

	}
}


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

public class Metal {
	public static void main(String[] args) throws IOException{
		BufferedReader br;
	    br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    int i;
	    int l = s.length();
	    long[] h = new long[l+1];
	    h[l] = 0;
	    for (i=l-1; i>=0; i--){
	    	h[i] = s.charAt(i) + h[i+1]*127;
	    }

	    long heavy=0, metal=0;
	    for (i=4; i>=0; i--){
	    	heavy = "heavy".charAt(i) + heavy*127;
	    	metal = "metal".charAt(i) + metal*127;
	    }
	    long numH = 0;
	    long resp = 0;

	    for (i=0; i<=l-5; i++){
	    	long aux = (h[i]-h[i+5]*(long)Math.pow(127,5));
	    	if (aux == heavy)
	    		numH++;
	    	else if (aux == metal)
	    		resp += numH;
	    }
	    System.out.println(resp);
	}
}


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

public class Metal {
	public static void main(String[] args) throws IOException{
		BufferedReader br;
	    br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    int i;
	    int l = s.length();
	    long[] h = new long[l+1];
	    h[l] = 0;
	    for (i=l-1; i>=0; i--){
	    	h[i] = s.charAt(i) + h[i+1]*33;
	    }

	    long heavy=0, metal=0;
	    for (i=4; i>=0; i--){
	    	heavy = "heavy".charAt(i) + heavy*33;
	    	metal = "metal".charAt(i) + metal*33;
	    }
	    int numH = 0;
	    int resp = 0;

	    for (i=0; i<=l-5; i++){
	    	long aux = (h[i]-h[i+5]*(long)Math.pow(33,5));
	    	if (aux == heavy)
	    		numH++;
	    	else if (aux == metal)
	    		resp += numH;
	    }
	    System.out.println(resp);
	}
}


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

public class Metal {
	public static void main(String[] args) throws IOException{
		BufferedReader br;
	    br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    int i;
	    int l = s.length();
	    long[] h = new long[l+1];
	    h[l] = 0;
	    for (i=l-1; i>=0; i--){
	    	h[i] = s.charAt(i) + h[i+1]*127;
	    }

	    long heavy=0, metal=0;
	    for (i=4; i>=0; i--){
	    	heavy = "heavy".charAt(i) + heavy*127;
	    	metal = "metal".charAt(i) + metal*127;
	    }
	    int numH = 0;
	    int resp = 0;

	    for (i=0; i<=l-5; i++){
	    	long aux = (h[i]-h[i+5]*(long)Math.pow(127,5));
	    	if (aux == heavy)
	    		numH++;
	    	else if (aux == metal)
	    		resp += numH;
	    }
	    System.out.println(resp);
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Vector;
import java.util.Scanner;
import java.util.Stack;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            Stack<String> s = new Stack<>();

            int res = 0;
            for (int i = 0; i < str.length(); ++i) {
                char ch = str.charAt(i);
                if (i + 4 >= str.length()) break;
                if (ch == 'h') {
                    if (str.substring(i, i + 5).equals("heavy")) {
                        s.add("heavy");
                        i += 4;
                    }
                } else if (ch == 'm') {
                    if (str.substring(i, i + 5).equals("metal")) {
                        res += s.size();
                        i += 4;
                    }
                }
            }

            out.print(res);
        }

    }
}


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

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            long count = 0;

            long res = 0;
            for (int i = 0; i < str.length(); ++i) {
                char ch = str.charAt(i);
                if (i + 4 >= str.length()) break;
                if (ch == 'h') {
                    if (str.substring(i, i + 5).equals("heavy")) {
                        count++;
                        i += 4;
                    }
                } else if (ch == 'm') {
                    if (str.substring(i, i + 5).equals("metal")) {
                        res += count;
                        i += 4;
                    }
                }
            }

            out.print(res);
        }

    }
}


/**
 * Created by MalhotR1 on 05/18/2018.
 */

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

public class StringsOfPower {
    public static void main(String[] args) throws IOException {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String input = br.readLine().trim();
            char[] in = input.toCharArray();
            char[] h = "heavy".toCharArray();
            char[] m = "metal".toCharArray();

            int hc = 0;
            int count = 0;
            for (int i = 0; i < in.length - 4;) {
                if (in[i] == 'h') {
                    int k = checkSubstr(in, h, i);
                    if (k == i + 5) hc++;
                    i = k;
                }
                else if (in[i] == 'm') {
                    int k = checkSubstr(in, m, i);
                    if (k == i + 5) {
                        count += hc;
                    }
                    i = k;
                }
                else {
                    i++;
                }
            }
            System.out.println(count    );

        }
    }

    private static int checkSubstr(char[] in, char[] m, int i) {
        int j = i;
        for (; j < i + 5; j++) {
            if (in[j] != m[j-i]) return j;
        }
        return j;
    }

}


/**
 * Created by MalhotR1 on 05/18/2018.
 */

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

public class StringsOfPower {
    public static void main(String[] args) throws IOException {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String input = br.readLine().trim();
            char[] in = input.toCharArray();
            char[] h = "heavy".toCharArray();
            char[] m = "metal".toCharArray();

            int hc = 0;
            long count = 0;
            for (int i = 0; i < in.length - 4;) {
                if (in[i] == 'h') {
                    int k = checkSubstr(in, h, i);
                    if (k == i + 5) hc++;
                    i = k;
                }
                else if (in[i] == 'm') {
                    int k = checkSubstr(in, m, i);
                    if (k == i + 5) {
                        count += hc;
                    }
                    i = k;
                }
                else {
                    i++;
                }
            }
            System.out.println(count    );

        }
    }

    private static int checkSubstr(char[] in, char[] m, int i) {
        int j = i;
        for (; j < i + 5; j++) {
            if (in[j] != m[j-i]) return j;
        }
        return j;
    }

}


import java.util.*;
import java.io.*;
import org.apache.http.cookie.*;

public class Main
{
	public static void main(String[] args)
	throws Exception
	{

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		int len = line.length();

		line = line.replace("heavy", "*");
		int lenH = line.length();
		int countH = (len - lenH) / 4;

		len = lenH;
		line = line.replace("metal", "#");
		int lenM = line.length();
		int countM = (len - lenM) / 4;

		if (countH == 0 || countM == 0)
		{
			System.out.println(0);
			return;
		}

		len = lenM;

		int ans,cM,cH;
		cM = cH = ans = 0;

		for(int i=0;i<len;i++)
		{
			if(line.charAt(i)=='*')
				cH++;
			else if(line.charAt(i)=='#')
			{
				cM++;
				ans += cH;

				if(cM==0)
					break;

			}

		}

		System.out.println(ans);

	}
}


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

public class Main
{
	public static void main(String[] args)
	throws Exception
	{

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		int len = line.length();

		line = line.replace("heavy", "*");
		int lenH = line.length();
		int countH = (len - lenH) / 4;

		len = lenH;
		line = line.replace("metal", "#");
		int lenM = line.length();
		int countM = (len - lenM) / 4;

		if (countH == 0 || countM == 0)
		{
			System.out.println(0);
			return;
		}

		len = lenM;

		int ans,cM,cH;
		cM = cH = ans = 0;

		for(int i=0;i<len;i++)
		{
			if(line.charAt(i)=='*')
				cH++;
			else if(line.charAt(i)=='#')
			{
				cM++;
				ans += cH;

				if(cM==0)
					break;

			}

		}

		System.out.println(ans);

	}
}


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

public class Main
{
	public static void main(String[] args)
	throws Exception
	{

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		int len = line.length();

		line = line.replace("heavy", "*");
		int lenH = line.length();
		int countH = (len - lenH) / 4;

		len = lenH;
		line = line.replace("metal", "#");
		int lenM = line.length();
		int countM = (len - lenM) / 4;

		if (countH == 0 || countM == 0)
		{
			System.out.println(0);
			return;
		}

		len = lenM;

		int cM,cH;
		long ans =0;
		cM = cH = 0;

		for(int i=0;i<len;i++)
		{
			if(line.charAt(i)=='*')
				cH++;
			else if(line.charAt(i)=='#')
			{
				cM++;
				ans += cH;

				if(cM==0)
					break;

			}

		}

		System.out.println(ans);

	}
}


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

public class Main
{
	public static void main(String[] args)
	throws Exception
	{

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		int len = line.length();

		line = line.replace("heavy", "*");
		int lenH = line.length();
		int countH = (len - lenH) / 4;

		len = lenH;
		line = line.replace("metal", "#");
		int lenM = line.length();
		int countM = (len - lenM) / 4;

		if (countH == 0 || countM == 0)
		{
			System.out.println(0);
			return;
		}

		len = lenM;
		String temp;
		int ind;
		int ans = 0;
		int lenT,lenR;

		for (int i=0;i < countH;i++)
		{

			ind = line.indexOf("*");
			temp = line.substring(0, ind);
			line = line.substring(ind+1);

			lenT = temp.length();
			lenR = temp.replace("#", "").length();

			countM -= (lenT-lenR);

			if (countM == 0)
				break;

			ans += countM;

		}

		System.out.println(ans);

	}
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Acm4J{
  public static void main(String []args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    //Scanner input = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    StringTokenizer st;
    String s = br.readLine();
    int sum =  0 ;
    int c = 0 ;
    int heavy = 0;
    int metal = 0;
    char ch [] = s.toCharArray();
    String ss ="heavymetal";
    int i = 0 ;
    for(i = 4 ; i < ch.length;i++){
      if(ch[i]=='l'){
        if(ch[i-4]=='m'&&ch[i-3]=='e'&&ch[i-2]=='t'&&ch[i-1]=='a'){
        metal+=heavy;
      }
      }
      else{
      if(ch[i-4]=='h'&&ch[i-3]=='e'&&ch[i-2]=='a'&&ch[i-1]=='v'&& ch[i]=='y'){
        heavy++;
      }
      }
    }

    pw.println(metal);
    pw.close();
  }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Acm4J{
  public static void main(String []args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    //Scanner input = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    StringTokenizer st;
    String s = br.readLine();
    int sum =  0 ;
    int c = 0 ;
    int heavy = 0;
    long metal = 0;
    char ch [] = s.toCharArray();
    String ss ="heavymetal";
    int i = 0 ;
    for(i = 4 ; i < ch.length;i++){
      if(ch[i]=='l'){
        if(ch[i-4]=='m'&&ch[i-3]=='e'&&ch[i-2]=='t'&&ch[i-1]=='a'){
        metal+=heavy;
      }
      }
      else{
      if(ch[i-4]=='h'&&ch[i-3]=='e'&&ch[i-2]=='a'&&ch[i-1]=='v'&& ch[i]=='y'){
        heavy++;
      }
      }
    }

    pw.println(metal);
    pw.close();
  }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Acm4J{
  public static void main(String []args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    //Scanner input = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    StringTokenizer st;
    String s = br.readLine();
    int sum =  0 ;
    int c = 0 ;
    int count = 0;
    char ch [] = s.toCharArray();
    String ss ="heavymetal";
    for(int i = 0 ; i < ch.length-4;i++){
      if(ch[i]=='h'&&ch[i+1]=='e'&&ch[i+2]=='a'&&ch[i+3]=='v'&& ch[i+4]=='y'){
        count++;
      }
      else if(ch[i]=='m'&&ch[i+1]=='e'&&ch[i+2]=='t'&&ch[i+3]=='a'&& ch[i+4]=='l'){
        count++;
      }
    }
    pw.println(count-1);
    pw.close();
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Template {
    StringTokenizer st;
    PrintWriter out;
    BufferedReader in;

    public static void main(String[] args) throws IOException {
        Template task = new Template();
        task.open();
        task.solve();
        task.close();
    }

    private void close() {
        out.close();
    }

    private void solve() throws IOException {
        String s = nextToken();
        long count = 0;
        long answ = 0;
        String metal = "metal";
        String heavy = "heavy";
        for (int i = 0; i < s.length(); i++) {
            if (i + 5 > s.length()) break;
            String a = s.substring(i, i + 5);
            if (a.equals(heavy)) count++;
            if (a.equals(metal)) answ+=count;
        }
        out.println(answ);

    }

    private void open() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

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

        }
        return st.nextToken();
    }

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

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Template {
    StringTokenizer st;
    PrintWriter out;
    BufferedReader in;

    public static void main(String[] args) throws IOException {
        Template task = new Template();
        task.open();
        task.solve();
        task.close();
    }

    private void close() {
        out.close();
    }

    private void solve() throws IOException {
        String s = nextToken();
        int count = 0;
        int answ = 0;
        String metal = "metal";
        String heavy = "heavy";
        for (int i = 0; i < s.length(); i++) {
            if (i + 5 > s.length()) break;
            String a = s.substring(i, i + 5);
            if (a.equals(heavy)) count++;
            if (a.equals(metal)) answ+=count;
        }
        out.println(answ);

    }

    private void open() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

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

        }
        return st.nextToken();
    }

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

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


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
       Scanner in = new Scanner(System.in);
       String str = in.next();
       int n = str.length();
       int [] arr = new int[n];
       if(n<10)
       {
           System.out.println(0);
           return;
       }
       for(int i = n-5;i>=5;i--)
       {
           if(str.substring(i,i+5).equals("metal"))
             arr[i] = 1;
             arr[i] += arr[i+1];
       }

       for(int i=4;i>=0;i--)
       {
           arr[i] = arr[i+1];
       }

      /* for(int i=0;i<n;i++)
       {
           System.out.print(arr[i]+" ");
       } */

       long sum = 0;
       for(int i=0;i<=n-5;i++)
       {
           if(str.substring(i,i+5).equals("heavy"))
            sum += (long) arr[i];
       }

       System.out.println(sum);
    }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
       Scanner in = new Scanner(System.in);
       String str = in.next();
       int n = str.length();
       int [] arr = new int[n];
       if(n<10)
       {
           System.out.println(0);
           return;
       }
       for(int i = n-5;i>=5;i--)
       {
           if(str.substring(i,i+5).equals("metal"))
             arr[i] = 1;
             arr[i] += arr[i+1];
       }

       for(int i=4;i>=0;i--)
       {
           arr[i] = arr[i+1];
       }

      /* for(int i=0;i<n;i++)
       {
           System.out.print(arr[i]+" ");
       } */

       int sum = 0;
       for(int i=0;i<=n-5;i++)
       {
           if(str.substring(i,i+5).equals("heavy"))
            sum += arr[i];
       }

       System.out.println(sum);
    }
}


import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class String_p {
    public static void main(String[] args) {

        FastReader in = new FastReader();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int i,j,a = 0,b,c,n,k,l,m;
        long sum = 0;
        boolean is,was,is1 = false,test=false;
        int[] brr = new int[1];
        int[] arr = new int[1];
        String s,s1;

        s = in.nextLine();
        l = s.length();

        for (i=0; i<l;){

            is = false;
            was = false;
            if (i+4 < l && s.charAt(i) == 'h'){
                i++;
                was = true;
                if (s.charAt(i) == 'e'){
                    i++;
                    if (s.charAt(i) == 'a'){
                        i++;
                        if (s.charAt(i) == 'v'){
                            i++;
                            if (s.charAt(i) == 'y'){
                                is = true;
                                i++;
                            }
                        }
                    }
                }
            }

            if (is){
                is1 = true;
                break;
            }
            if (!was) i++;

        }
       // out.println(i +  " point");
        //mergeSort(arr, 0, 7);
        //Arrays.binarySearch(arr,7);

        for (j=i; j<l;){

            is = false;
            was = false;
            if (j+4 < l && s.charAt(j) == 'm'){
                j++;
                was = true;
                if (s.charAt(j) == 'e'){
                    j++;
                    if (s.charAt(j) == 't'){
                        j++;
                        if (s.charAt(j) == 'a'){
                            j++;
                            if (s.charAt(j) == 'l') {
                                is = true;
                                j++;
                            }
                        }
                    }
                }
            }

            if (is){
                a ++;
            }
            if (!was) j++;
        }
       // out.println(a + " metal_number");

        //  total....heavymetaldfgheavymetal
        for (i=0; i<l;){

            is = false;
            was = false;
            if ( i+4 < l && s.charAt(i) == 'h'){
                i++;was = true;
                if (s.charAt(i) == 'e'){
                    i++;
                    if (s.charAt(i) == 'a'){
                        i++;
                        if (s.charAt(i) == 'v'){
                            i++;
                            if (s.charAt(i) == 'y'){
                                is = true;
                                test = true;
                                i++;
                            }
                        }
                    }
                }
            }

            if (is){
                sum += a;
            }

            // matal

            is1 = false;
            if (i+4 < l && s.charAt(i) == 'm' && test){
                i++;
                was = true;
                if (s.charAt(i) == 'e'){
                    i++;
                    if (s.charAt(i) == 't'){
                        i++;
                        if (s.charAt(i) == 'a'){
                            i++;
                            if (s.charAt(i) == 'l') {
                                is1 = true;
                                i++;
                            }
                        }
                    }
                }
            }

            if (is1){
                a --;
            }
            if (!was) i++;

        }

        out.println(sum);
        // metal heavy

        out.flush();

    }

    static void  mergeSort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Same as (l+r)/2, but avoids overflow for
            // large l and h
            int m = l+(r-l)/2;

            // Sort first and second halves
            mergeSort(arr, l, m);
            mergeSort(arr, m+1, r);

            merge(arr, l, m, r);
        }
    }

    static void merge(int arr[], int l, int m, int r)
    {
        int i, j, k;
        int n1 = m - l + 1;
        int n2 =  r - m;

        /* create temp arrays */
        int L[] = new int[n1],  R[] = new int[n2];

        /* Copy data to temp arrays L[] and R[] */
        for (i = 0; i < n1; i++)
            L[i] = arr[l + i];
        for (j = 0; j < n2; j++)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays back into arr[l..r]*/
        i = 0; // Initial index of first subarray
        j = 0; // Initial index of second subarray
        k = l; // Initial index of merged subarray
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

    /* Copy the remaining elements of L[], if there
       are any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

    /* Copy the remaining elements of R[], if there
       are any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

}