#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-5;
template <typename T>
T abs(const T& a) {
  if (a >= 0) return a;
  return -a;
}
int N, M;
string mat[160];
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  int last_line = 0;
  for (int i = 0; i < N; ++i) {
    cin >> mat[i];
    if (mat[i].find_first_of('W') != -1) last_line = i;
  }
  int ans = 0;
  int currc = 0;
  for (int i = 0; i < last_line; ++i) {
    if (i % 2 == 0) {
      int pos = mat[i].find_last_of('W');
      int pos2 = mat[i + 1].find_last_of('W');
      if (pos == -1 || pos2 > pos) pos = pos2;
      if (pos != -1) {
        ans += abs(pos - currc);
        currc = pos;
      }
    } else {
      int pos = mat[i].find_first_of('W');
      int pos2 = mat[i + 1].find_first_of('W');
      if (pos == -1 || (pos2 != -1 && pos2 < pos)) pos = pos2;
      if (pos != -1) {
        ans += abs(currc - pos);
        currc = pos;
      }
    }
    ans++;
  }
  if (last_line % 2 == 0) {
    int pos = mat[last_line].find_last_of('W');
    if (pos != -1) {
      ans += abs(pos - currc);
    }
  } else {
    int pos = mat[last_line].find_first_of('W');
    if (pos != -1) {
      ans += abs(pos - currc);
    }
  }
  cout << ans << '\n';
  return 0;
}
