#include <bits/stdc++.h>
using namespace std;
int main() {
  bool a[200][200];
  int mn[200];
  int mx[200];
  int i, j, n, m;
  scanf("%d%d", &n, &m);
  char hlam;
  memset(mx, -1, sizeof(mx));
  for (i = 0; i <= n; i++) mn[i] = m + 1;
  int mxx = 0;
  for (i = 0; i < n; i++) {
    scanf("%c", &hlam);
    for (j = 0; j < m; j++) {
      scanf("%c", &hlam);
      if (hlam == 'W') {
        a[i][j] = true;
        if (mn[i] == m + 1) mn[i] = j;
        mx[i] = j;
        mxx = i;
      } else
        a[i][j] = false;
    }
  }
  int cur = 0;
  int kol = -1;
  int tmp;
  for (i = 0; i <= mxx; i++)
    if (i % 2 == 0) {
      tmp = max(mx[i], mx[i + 1]);
      tmp = max(tmp, cur);
      kol += tmp - cur + 1;
      cur = tmp;
    } else {
      tmp = min(mn[i], mn[i + 1]);
      tmp = min(tmp, cur);
      kol += cur - tmp + 1;
      cur = tmp;
    }
  printf("%d\n", kol);
  return 0;
}
