#include <bits/stdc++.h>
using namespace std;
int n, m, a[200][200], l[200], r[200];
int main() {
  scanf("%d%d", &n, &m);
  int cnt = 1, s = 1;
  for (int i = 1; i <= n; i++) {
    char c;
    scanf("%c", &c);
    for (int j = 1; j <= m; j++) {
      scanf("%c", &c);
      if (c == 'W') {
        r[i] = j;
        if (!l[i]) l[i] = j;
        s = i;
      }
    }
  }
  int ans = 0, last = 1, flag = 0;
  for (int i = 1; i <= s; i++) {
    if (flag == 0) {
      if (l[i]) ans += abs(r[i] - last), last = r[i];
      if (i == s) break;
      flag = 1;
      if (!l[i + 1]) continue;
      ans += abs(r[i + 1] - last), last = r[i + 1];
    } else if (flag == 1) {
      if (r[i]) ans += abs(last - l[i]), last = l[i];
      if (i == s) break;
      flag = 0;
      if (!l[i + 1]) continue;
      ans += abs(last - l[i + 1]), last = l[i + 1];
    }
  }
  cout << ans + s - 1;
  return 0;
}
