#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, r[200], l[200], s, x, j, flag;
  char a[200][200];
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    r[i] = 0;
    l[i] = 1000;
    for (j = 1; j <= m; j++) {
      cin >> a[i][j];
      if ((a[i][j] == 'W') && (j > r[i])) r[i] = j;
      if ((a[i][j] == 'W') && (j < l[i])) l[i] = j;
    }
  }
  flag = 0;
  for (i = n; i >= 1; i--) {
    if ((flag == 1) && (r[i] == 0)) r[i] = -1;
    if (r[i] != 0) flag = 1;
  }
  r[n + 1] = 0;
  l[n + 1] = 1000;
  i = 1;
  s = 0;
  x = 1;
  while (r[i] != 0) {
    if (r[i] > 0) {
      if (i % 2 == 1) {
        s += max(r[i], r[i + 1]) - x;
        if (r[i + 1] != 0) s++;
        x = max(r[i], r[i + 1]);
      } else {
        s += x - min(l[i], l[i + 1]);
        if (r[i + 1] != 0) s++;
        x = min(l[i], l[i + 1]);
      }
      i++;
    } else {
      if (r[i + 1] == -1) {
        s++;
        i++;
      } else if ((i + 1) % 2 == 1) {
        if (x >= l[i + 1]) {
          s += x - l[i + 1] + 1;
          x = l[i + 1];
        } else
          s++;
        i++;
      } else {
        if (x <= r[i + 1]) {
          s += r[i + 1] - x + 1;
          x = r[i + 1];
        } else
          s++;
        i++;
      }
    }
  }
  cout << s;
}
