#include <bits/stdc++.h>
const double eps = 1e-9;
const int int_inf = 1 << 31 - 1;
const long long i64_inf = 1ll << 63 - 1;
const double pi = acos(-1.0);
const int mod = (int)1e8;
using namespace std;
int n, m;
char second[200][200];
int l[200];
int r[200];
int cnt = 0;
int res = 0;
int done = 0;
int main() {
  scanf("%d%d\n", &n, &m);
  for (int i = 0; i < (int)n; i++) gets(second[i]);
  for (int i = 0; i < (int)n; i++) l[i] = m;
  for (int i = 0; i < (int)n; i++) r[i] = -1;
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++)
      if (second[i][j] == 'W') l[i] = min(l[i], j), r[i] = max(r[i], j), cnt++;
  int i = 0;
  int j = 0;
  bool where = 0;
  while (done != cnt) {
    if (!where)
      if (j < max(r[i], r[i + 1]))
        j++;
      else
        where ^= 1, i++;
    else if (j > min(l[i], l[i + 1]))
      j--;
    else
      where ^= 1, i++;
    res++;
    if (second[i][j] == 'W') done++;
  }
  cout << res << endl;
  return 0;
}
