#include <bits/stdc++.h>
using namespace std;
char s[256][256];
int n, m;
int main(void) {
  int r = 0;
  scanf("%d %d", &n, &m);
  for (int(i) = 0; (i) < ((n)); (i)++) scanf("%s", s[i]);
  for (int i = n - 1; i > 0; i--) {
    int ok = 0;
    for (int(j) = 0; (j) < ((m)); (j)++)
      if (s[i][j] == 'W') ok = 1;
    if (!ok)
      n--;
    else
      break;
  }
  int x = 0;
  for (int(i) = 0; (i) < ((n)); (i)++) {
    int nx = x;
    if (i % 2) {
      for (int j = x; j >= 0; j--) {
        if (s[i][j] == 'W') nx = min(nx, j);
        if (i + 1 >= 0 && s[i + 1][j] == 'W') nx = min(nx, j);
      }
    } else {
      for (int j = x; j < m; j++) {
        if (s[i][j] == 'W') nx = max(nx, j);
        if (i + 1 < n && s[i + 1][j] == 'W') nx = max(nx, j);
      }
    }
    r += abs(x - nx);
    if (i + 1 < n) r++;
    x = nx;
  }
  printf("%d\n", r);
  return (0);
}
