#include <bits/stdc++.h>
using namespace std;
const int N = 155, INF = 0x3f3f3f3f;
int n, m, cnt, cnts[N], ans, now, p;
char a[N][N];
inline int scan(int x, int o) {
  if (o) {
    for (int i = m; i; --i)
      if (a[x][i] == 'W') return i;
  } else {
    for (int i = 1; i <= m; ++i)
      if (a[x][i] == 'W') return i;
  }
  return o ? 0 : INF;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
      if (a[i][j] == 'W') ++cnt, ++cnts[i];
    }
  now = 1;
  for (int i = 1; i < n; ++i) {
    if (i & 1) {
      p = max(scan(i, 1), scan(i + 1, 1));
      if (p > now) ans += p - now, now = p;
    } else {
      p = min(scan(i, 0), scan(i + 1, 0));
      if (p < now) ans += now - p, now = p;
    }
    cnt -= cnts[i];
    if (cnt)
      ++ans;
    else
      break;
  }
  if (cnt) {
    if (n & 1) {
      p = scan(n, 1);
      ans += p - now;
    } else {
      p = scan(n, 0);
      ans += now - p;
    }
  }
  cout << ans << endl;
  return 0;
}
