#include <bits/stdc++.h>
using namespace std;
char str[151][151];
int main() {
  int n, m;
  cin >> n >> m;
  for (unsigned i = 0; i < n; i++) cin >> str[i];
  int p = 0, last = 0, res = 0;
  for (int i = 0; i < n; i++) {
    int left = p, right = p;
    bool sign = false;
    for (int j = 0; j < m; j++) {
      if (str[i][j] == 'W') {
        left = min(left, j);
        right = max(right, j);
        sign = true;
      }
      if (i + 1 < n && str[i + 1][j] == 'W') {
        left = min(left, j);
        right = max(right, j);
      }
    }
    if (i % 2 == 0) {
      res += right - p;
      p = right;
    } else {
      res += p - left;
      p = left;
    }
    if (sign) last = i;
  }
  cout << res + last << endl;
  return 0;
}
