import java.util.*;

public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); char[][] arr = new char[n+1][m+1]; for(int i = 1;i <= n;i ++){ String s = in.next(); for(int j = 1;j <= m;j ++){ arr[i][j] = s.charAt(j-1); } } int[][] dp = new int[n+1][m+1]; for(int i = 1;i <= n;i ++){ for(int j = 1;j <= m;j ++){ dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1])+getScore(arr[i][j]); } } System.out.println(dp[n][m]);

}

private static int getScore(char c) {
    if(c == 'l') return 4;
    if(c == 'o') return 3;
    if(c == 'v') return 2;
    if(c == 'e') return 1;
    return 0;
}

}