#include <bits/stdc++.h>
using namespace std;
const int MAXN = 155;
int n, m;
char str[MAXN][MAXN];
int first[MAXN], last[MAXN];
int main() {
  cin >> n >> m;
  cin.get();
  for (int i = 0; i < n; i++) cin.getline(str[i], MAXN);
  for (int i = 0; i < n; i++) {
    first[i] = MAXN;
    last[i] = -1;
    for (int j = 0; j < m; j++)
      if (str[i][j] == 'W') {
        if (first[i] == MAXN) first[i] = j;
        last[i] = j;
      }
  }
  int c = 0, r;
  for (int i = 0, cur = 0; i < n; i++) {
    if (i % 2 == 0) {
      r = last[i];
      if (i + 1 < n && last[i + 1] > r) r = last[i + 1];
      r = max(r, cur);
      c += r - cur;
      cur = r;
    } else {
      r = first[i];
      if (i + 1 < n && first[i + 1] < r) r = first[i + 1];
      r = min(r, cur);
      c += cur - r;
      cur = r;
    }
    int j;
    for (j = i + 1; j < n; j++)
      if (first[j] != MAXN) break;
    if (j == n) break;
    c++;
  }
  cout << c << '\n';
  return 0;
}
