import java.util.Scanner;
import java.io.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        String[] arr=reader.readLine().split(" ");
        int n=Integer.parseInt(arr[0]);
        int m=Integer.parseInt(arr[1]);
        int[][] tmp=new int[n+2][m+2];
        for(int i=1;i<=n;i++){
            String s=reader.readLine();
            for(int j=1;j<=m;j++){
                char c=s.charAt(j-1);
                if(c=='l'){
                    tmp[i][j]+=4;
                }else if(c=='o'){
                    tmp[i][j]+=3;
                }else if(c=='v'){
                    tmp[i][j]+=2;
                }else if(c=='e'){
                    tmp[i][j]+=1;
                }else{
                    tmp[i][j]+=0;
                }
            }
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                tmp[i][j]+=Math.max(tmp[i-1][j],tmp[i][j-1]);
            }
        }
        System.out.print(tmp[n][m]);
    }
}