#include<iostream>
#include<map>
using namespace std;
char c[501][501];
int dp[501][501];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,m;
map<char,int> mp;
mp['l'] = 4;
mp['o'] = 3;
mp['v'] = 2;
mp['e'] = 1;
string str;
cin >> n >> m;
for(int i = 1; i <= n;++i){
cin >> str;
for(int j = 1;j <= m;++j)
c[i][j] = str[j - 1];
}
for(int i = 1;i <= n;++i){
for(int j = 1;j <= m;++j){
if(mp.find(c[i][j]) != mp.end())
dp[i][j] = max(dp[i - 1][j],dp[i][j - 1]) + mp[c[i][j]];
else
dp[i][j] = max(dp[i - 1][j],dp[i][j - 1]);
}
}
cout << dp[n][m];
}