#include <bits/stdc++.h>
using namespace std;
const int N = 155;
char a[N][N];
int num[N], st[N], ed[N];
int main() {
  int n, m, cnt = 0;
  scanf("%d%d", &n, &m);
  st[0] = ed[0] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", a[i]);
    bool f = 0;
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'W') {
        if (!f) {
          st[i] = j;
          f = 1;
        }
        ed[i] = j;
        cnt++;
        num[i]++;
      }
    }
    if (!f) {
      if (i & 1)
        st[i] = ed[i] = ed[i - 1];
      else
        st[i] = ed[i] = st[i - 1];
    }
  }
  st[0] = 0;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (i & 1) {
      if (st[i] > st[i + 1])
        st[i] = st[i + 1];
      else
        st[i + 1] = st[i];
    } else {
      if (ed[i] > ed[i + 1])
        ed[i + 1] = ed[i];
      else
        ed[i] = ed[i + 1];
    }
    ans += ed[i] - st[i];
    cnt -= num[i];
    if (cnt == 0)
      break;
    else
      ans++;
  }
  ans += ed[n - 1] - st[n - 1];
  printf("%d\n", ans);
  return 0;
}
