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