#include <bits/stdc++.h>
using namespace std;
int n, m, l[200], r[200], ans, ps, smth;
char A[200][200];
int32_t main() {
  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') {
        r[i] = j;
        if (!l[i]) l[i] = j;
      }
    }
  }
  ps = 1;
  smth = 1;
  for (int i = 1; i <= n; i++) {
    if (!l[i]) continue;
    ans += i - smth;
    if (i % 2) {
      if (ps > l[i]) {
        ans += ps - l[i];
        ps = l[i];
      }
      ans += r[i] - ps;
      ps = r[i];
    } else {
      if (ps < r[i]) {
        ans += r[i] - ps;
        ps = r[i];
      }
      ans += ps - l[i];
      ps = l[i];
    }
    smth = i;
  }
  cout << ans << endl;
}
