#include <bits/stdc++.h>
using namespace std;
int n, m, sb, l[151], r[151], ans, now = 1;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    l[i] = 2147483647;
    r[i] = -2147483648;
    for (int j = 0; j < s.size(); j++)
      if (s[j] == 'W') {
        sb = i;
        l[i] = j + 1;
        break;
      }
    for (int j = s.size() - 1; j >= 0; j--)
      if (s[j] == 'W') {
        r[i] = j + 1;
        break;
      }
  }
  for (int i = 1; i <= sb; i++) {
    if (i == sb) {
      if (i % 2 == 0)
        ans += now - l[i];
      else
        ans += r[i] - now;
      break;
    }
    ans++;
    if (i % 2 == 1) {
      if (r[i] == -2147483648 && r[i + 1] == -2147483648) continue;
      ans += abs(max(r[i], r[i + 1]) - now);
      now = max(r[i], r[i + 1]);
    } else {
      if (l[i] == 2147483647 && l[i + 1] == 2147483647) continue;
      ans += abs(now - min(l[i], l[i + 1]));
      now = min(l[i], l[i + 1]);
    }
  }
  cout << ans;
}
