#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
int r[150 + 5], l[150 + 5], cnt[150 + 5];
bool a[150 + 5][150 + 5];
int main() {
  int n, m;
  cin >> n >> m;
  int i, j;
  int c = 0;
  for (i = 0; i < n; i++) {
    c = 0;
    for (j = 0; j < m; j++) {
      char ch;
      cin >> ch;
      a[i][j] = (ch == 'W') ? 1 : 0;
      if (a[i][j]) c++;
    }
    cnt[i] = c;
  }
  int tot = 0;
  for (i = 0; i < n; i++) {
    int L = 0, R = m - 1;
    while (L < m && !a[i][L]) L++;
    while (R >= 0 && !a[i][R]) R--;
    l[i] = L;
    r[i] = R;
    tot += cnt[i];
  }
  int st = 0;
  int op = 0;
  if (tot == 0) {
    cout << 0;
    return 0;
  }
  l[n] = m;
  r[n] = -1;
  for (i = 0; i < n; i++) {
    if (i % 2 == 0) {
      op += max(0, (max(r[i], r[i + 1]) - st));
      if (st <= max(r[i], r[i + 1])) st = max(r[i], r[i + 1]);
    } else {
      op += max(0, st - min(l[i], l[i + 1]));
      if (st >= min(l[i], l[i + 1])) st = min(l[i], l[i + 1]);
    }
    tot -= cnt[i];
    if (!tot) break;
    op++;
  }
  cout << op;
  return 0;
}
