#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int maxn = 200;
string a[maxn];
int posl[maxn] = {};
int posr[maxn] = {};
int ccc[maxn] = {};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int dir = 1;
  memset(posl, 100, sizeof(posl));
  memset(posr, 0, sizeof(posr));
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int hasl = false;
    for (int j = 0; j < m; ++j)
      if (a[i][j] == 'W') {
        ccc[i]++;
        cnt++;
        if (!hasl) hasl = 1, posl[i] = j;
        posr[i] = j;
      }
  }
  int curpos = 0;
  int ans = 0;
  int curcnt = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2) {
      int tpos = min(curpos, posl[i]);
      if (i != n - 1) tpos = min(tpos, posl[i + 1]);
      ans += abs(curpos - tpos);
      curpos = tpos;
    } else {
      int tpos = max(curpos, posr[i]);
      if (i != n - 1) tpos = max(tpos, posr[i + 1]);
      ans += abs(curpos - tpos);
      curpos = tpos;
    }
    curcnt += ccc[i];
    if (curcnt == cnt) break;
    if (i != n - 1) ans++;
  }
  printf("%d", ans);
  return 0;
}
