#include <bits/stdc++.h>
using namespace std;
char a[200][200];
int n, m, ans = 0;
int main() {
  scanf("%d %d\n", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) scanf("%c", &a[i][j]);
    scanf("\n");
  }
  int last = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == 'W') last = i;
  n = last;
  int cur = 1;
  for (int i = 1; i <= n; i++) {
    int p = cur;
    if (i % 2 == 1) {
      for (int j = m; j >= cur; j--) {
        if (a[i][j] == 'W') {
          p = j;
          break;
        }
        if (i < n) {
          if (a[i + 1][j] == 'W') {
            p = j;
            break;
          }
        }
      }
      ans += (p - cur);
      cur = p;
    } else {
      for (int j = 1; j <= cur; j++) {
        if (a[i][j] == 'W') {
          p = j;
          break;
        }
        if (i < n) {
          if (a[i + 1][j] == 'W') {
            p = j;
            break;
          }
        }
      }
      ans += (cur - p);
      cur = p;
    }
    if (i < n) ans++;
  }
  printf("%d", ans);
  return 0;
}
