#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-6;
int main() {
  int n, m;
  char g[200][200];
  bool aru[200];
  cin >> n >> m;
  cin.get();
  fill(aru, aru + 200, false);
  memset(g, 'G', sizeof(g));
  for (int i = 0; i < n; ++i) {
    char buf[200];
    cin.getline(buf, sizeof(buf));
    for (int j = 0; j < m; ++j) {
      g[i][j] = buf[j];
      if (buf[j] == 'W') aru[i] = true;
    }
  }
  int ans = 0;
  int x, y;
  x = y = 0;
  int d = 1;
  while (true) {
    int len = 0;
    for (int i = x; 0 <= i && i < m; i += d)
      if (g[y][i] == 'W' || g[y + 1][i] == 'W') len = abs(x - i);
    ans += len + 1;
    x += len * d;
    ++y;
    d *= -1;
    bool tt = false;
    for (int i = y; i < n; ++i)
      if (aru[i]) tt = true;
    if (!tt) {
      --ans;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
