#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30, N = 1002;
int ax[] = {0, 1, -1, 0, 0};
int ay[] = {0, 0, 0, -1, 1};
char ch[200][200];
int n, m, dp[150][150];
int main() {
  int i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> ch[i];
  }
  int q1;
  for (i = n - 1; i >= 0; i--) {
    for (j = 0; j < m; j++) {
      if (ch[i][j] == 'W') {
        goto l;
      }
    }
    n = i;
  }
l:;
  if (n == 0) {
    cout << 0;
    return 0;
  }
  int x = 0, y = 0, z = 1, res = 0, ans = 0, nx = 0, ny = 0;
  while (true) {
    if (z == 1) {
      int k1 = y;
      for (j = m - 1; j > y; j--)
        if (ch[x][j] == 'W') {
          k1 = j;
          break;
        }
      res += (k1 - y);
      if (x == n - 1) break;
      int kk = -1;
      for (j = m - 1; j > k1; j--)
        if (ch[x + 1][j] == 'W') {
          kk = j;
          break;
        }
      if (kk != -1) {
        res -= (k1 - y);
        res += (kk - y);
        x++;
        res++;
        y = kk;
        z = -1;
      } else {
        res++;
        x++;
        y = k1;
        z = -1;
      }
    } else {
      int k1 = y;
      for (j = 0; j < y; j++)
        if (ch[x][j] == 'W') {
          k1 = j;
          break;
        }
      res += (y - k1);
      if (x == n - 1) break;
      int kk = -1;
      for (j = 0; j < k1; j++)
        if (ch[x + 1][j] == 'W') {
          kk = j;
          break;
        }
      if (kk != -1) {
        res++;
        res -= (y - k1);
        res += (y - kk);
        x++;
        y = kk;
        z = 1;
      } else {
        res++;
        x++;
        y = k1;
        z = 1;
      }
    }
  }
  cout << res;
  return 0;
}
