package main

import (
	"fmt"
	"strings"
)

func solution(arr [][]int) int {
	for r := 0; r < len(arr); r++ {
		for c := 0; c < len(arr[0]); c++ {
			if r == 0 && c == 0 {
				continue
			}
			if r > 0 && c > 0 {
				//可选右下
				arr[r][c] += max(arr[r][c-1], arr[r-1][c])
			} else if r > 0 {
				//可选下
				arr[r][c] += arr[r-1][c]
			} else if c > 0 {
				//可选右
				arr[r][c] += arr[r][c-1]
			}
		}
	}
	return arr[len(arr)-1][len(arr[0])-1]
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func getScore(str string) int {
	switch str {
	case "l":
		return 4
	case "o":
		return 3
	case "v":
		return 2
	case "e":
		return 1
	default:
		return 0
	}
}

/*
*
2 3
lle
ove
结果
11
*/
func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	dp := make([][]int, n)
	for r := 0; r < n; r++ {
		tmp := make([]int, m)
		var t string
		fmt.Scan(&t)
		tt := strings.Split(t, "")
		for i := 0; i < len(t); i++ {
			tmp[i] = getScore(tt[i])
		}
		dp[r] = tmp
	}
	fmt.Println(solution(dp))
}