#include <bits/stdc++.h>
using namespace std;
int N, M, l[200], r[200];
string a[200];
int main() {
  memset(l, -1, sizeof(l));
  memset(r, -1, sizeof(r));
  scanf("%d%d", &N, &M);
  for (int(i) = 0; (i) < (N); (i)++) {
    cin >> a[i];
    int j = 0;
    while (j < M) {
      if (a[i][j] == 'W') {
        l[i] = j;
        break;
      }
      j++;
    }
    j = M - 1;
    while (j >= 0) {
      if (a[i][j] == 'W') {
        r[i] = j;
        break;
      }
      j--;
    }
  }
  for (; N > 0 && l[N] == -1 && r[N] == -1; N--)
    ;
  N++;
  int y = 0;
  int ans = 0;
  for (int x = 0; x < N; x++) {
    if (x % 2 == 0) {
      int k;
      if (r[x + 1] == -1) {
        if (r[x] == -1)
          continue;
        else
          k = r[x];
      } else {
        k = r[x + 1];
        if (r[x] != -1) k = max(k, r[x]);
      }
      ans += (((y - k) < 0) ? (-(y - k)) : (y - k));
      y = k;
    } else {
      int k;
      if (l[x + 1] == -1) {
        if (l[x] == -1)
          continue;
        else
          k = l[x];
      } else {
        k = l[x + 1];
        if (l[x] != -1) k = min(k, l[x]);
      }
      ans += (((y - k) < 0) ? (-(y - k)) : (y - k));
      y = k;
    }
  }
  printf("%d\n", ans + N - 1);
  return 0;
}
