#include <bits/stdc++.h>
using namespace std;
const int N = 200;
int f[2][N], l[N], r[N], am[N], len[N];
int main() {
  int n, m, ans = 0, max1 = 0;
  char c;
  scanf("%d%d", &n, &m);
  l[0] = r[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c;
      if (c == 'W') {
        if (!l[i]) l[i] = j;
        r[i] = j;
      }
    }
    if (!l[i]) {
      if ((i - 1) & 1)
        l[i] = r[i] = r[i - 1];
      else
        l[i] = r[i] = l[i - 1];
    } else
      max1 = i;
    len[i] = r[i] - l[i];
  }
  for (int i = 1; i <= max1; i++) {
    if (i & 1) {
      if (i == 1) ans--;
      ans += (abs(l[i] - l[i - 1]) + len[i] + 1);
    } else
      ans += (abs(r[i] - r[i - 1]) + len[i] + 1);
  }
  printf("%d\n", ans);
  return 0;
}
