#include <bits/stdc++.h>
const int LMT = 155;
char gra[LMT][LMT];
int main(void) {
  int n, m, k = 0, ss = 1, ans = 0, j = 0, l = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", gra[i]);
  for (int i = 0; i < n; i++, ss *= -1) {
    for (j += ss; j < m && j >= 0; j += ss) {
      k += ss > 0 ? (j > l ? 1 : -1) : (j < l ? 1 : -1);
      if (gra[i][j] == 'W') {
        ans += k;
        l = j;
        k = 0;
      }
    }
    k += 2;
  }
  printf("%d\n", ans);
  return 0;
}
