#include<iostream>usingnamespace std;constint N =510;char g[N][N];int dp[N][N];int m, n;intmain(){
cin >> m >> n;for(int i =1; i <= m; i++){for(int j =1; j <= n; j++){
cin >> g[i][j];}}for(int i =1; i <= m; i++){for(int j =1; j <= n; j++){int t =0;if(g[i][j]=='l') t =4;elseif(g[i][j]=='o') t =3;elseif(g[i][j]=='v') t =2;elseif(g[i][j]=='e') t =1;
dp[i][j]=max(dp[i -1][j], dp[i][j -1])+ t;}}
cout << dp[m][n]<< endl;return0;}