#include using namespace std; using ll = long long; #define all(A) A.begin(),A.end() using vll = vector; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector>; ll mod=1e9+7; int main() { ll H,W; cin>>H>>W; vector> C(H+1,vector (W+1,false)); rep(h,H){ string S; cin>>S; rep(w,W){ if(S[w]=='k')C[h][w]=true; } } vector DP(H+1,vll(W+1,1e18)); DP[0][0]=0; rep(h,H){ rep(w,W){ if(C[h][w+1])DP[h][w+1]=min(DP[h][w+1],DP[h][w]+2+h+w); else DP[h][w+1]=min(DP[h][w+1],DP[h][w]+1); if(C[h+1][w])DP[h+1][w]=min(DP[h+1][w],DP[h][w]+2+h+w); else DP[h+1][w]=min(DP[h+1][w],DP[h][w]+1); } } cout<