#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, INF = 1e18, mx = 1e6;
int testCase = 1, cas = 0;
int n, m, Weed, WeedTaken, Ans;
set<int> G[160];
void dfs(int curX, int curY, int right) {
  if (curX == n || WeedTaken == Weed) return;
  Ans++;
  if (right) {
    while (1) {
      if ((G[curX].size() == 0 || *G[curX].rbegin() < curY + 1) &&
          (G[curX + 1].size() == 0 || *G[curX + 1].rbegin() < curY + 1))
        break;
      Ans++;
      curY++;
    }
    WeedTaken += G[curX].size();
    dfs(curX + 1, curY, 0);
  } else {
    while (1) {
      if ((G[curX].size() == 0 || *G[curX].begin() > curY - 1) &&
          (G[curX + 1].size() == 0 || *G[curX + 1].begin() > curY - 1))
        break;
      Ans++;
      curY--;
    }
    WeedTaken += G[curX].size();
    dfs(curX + 1, curY, 1);
  }
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  cin.ignore();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char ch;
      cin >> ch;
      if (ch == 'W') {
        Weed++;
        G[i].insert(j);
      }
    }
  }
  dfs(0, 0, 1);
  if (Ans) Ans--;
  cout << Ans << endl;
  return 0;
}
