#include <bits/stdc++.h>
using namespace std;
const int MOD(1000000007);
const int INF((1 << 30) - 1);
const int MAXN(155);
int n, m;
string a[MAXN];
int getlastrow() {
  for (int i = n - 1; i >= 0; i--)
    for (int j = 0; j < m; j++)
      if (a[i][j] == 'W') return i;
  return -1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) cin >> a[i];
  int lastrow = getlastrow(), nowcol = 0;
  if (lastrow == -1) {
    printf("0");
    return 0;
  }
  int Move = 0;
  for (int i = 0; i < lastrow; i++) {
    if (i % 2 == 0) {
      for (int j = m - 1; j >= nowcol; j--)
        if (a[i][j] == 'W' || a[i + 1][j] == 'W') {
          Move += (j - nowcol);
          nowcol = j;
          break;
        }
    } else {
      for (int j = 0; j <= nowcol; j++)
        if (a[i][j] == 'W' || a[i + 1][j] == 'W') {
          Move += (nowcol - j);
          nowcol = j;
          break;
        }
    }
    Move++;
  }
  if (lastrow % 2 == 0) {
    for (int j = m - 1; j >= nowcol; j--)
      if (a[lastrow][j] == 'W') {
        Move += (j - nowcol);
        break;
      }
  } else {
    for (int j = 0; j <= nowcol; j++)
      if (a[lastrow][j] == 'W') {
        Move += (nowcol - j);
        break;
      }
  }
  printf("%d", Move);
}
