#include <bits/stdc++.h>
using namespace std;
char a[200][200];
int lef[200], righ[200];
bool is[200];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, bot = 0;
  cin >> n >> m;
  for (int i = 0; i < n + 1; i++) {
    lef[i] = m - 1;
    righ[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    bool f = 0;
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'W') {
        lef[i] = min(j, lef[i]);
        righ[i] = max(j, righ[i]);
        f = 1;
        bot = i;
      }
    }
    is[i] = f;
  }
  int cur = 0, ans = 0;
  for (int i = 0; i <= bot; i++) {
    if (is[i + 1] == 0 && is[i] == 0) continue;
    if (i % 2 == 0) {
      ans += abs(cur - max(righ[i + 1], righ[i]));
      cur = max(righ[i + 1], righ[i]);
    } else {
      ans += abs(cur - min(lef[i + 1], lef[i]));
      cur = min(lef[i + 1], lef[i]);
    }
  }
  cout << ans + bot;
  return 0;
}
