#include <bits/stdc++.h>
int pos[200][3];
int main() {
  int n, m, i, j;
  scanf("%d%d", &n, &m);
  char a[n][m];
  for (i = 0; i < n; i++) scanf("%s", &a[i][0]);
  for (i = 0; i < n; i++) {
    int first = 0;
    for (j = 0; j < m; j++) {
      if (a[i][j] == 'W') {
        pos[i][2]++;
        pos[i][1] = j;
        if (first == 0) {
          pos[i][0] = j;
          first = 1;
        }
      }
    }
  }
  int no_of_weeds = 0;
  for (i = 0; i < n; i++) no_of_weeds += pos[i][2];
  int ans = 0, curr_pos = pos[0][1];
  if (pos[0][2] > 0) ans += pos[0][1];
  no_of_weeds -= pos[0][2];
  if (no_of_weeds == 0) {
    printf("%d", ans);
    return 0;
  }
  for (i = 1; i < n; i++) {
    if (i % 2) {
      if (pos[i][1] < curr_pos) {
        if (pos[i][2] > 0) {
          ans += curr_pos - pos[i][0] + 1;
          curr_pos = pos[i][0];
        } else
          ans += 1;
      } else {
        if (pos[i][2] > 0) {
          ans += pos[i][1] - pos[i][0] + pos[i][1] - curr_pos + 1;
          curr_pos = pos[i][0];
        } else
          ans += 1;
      }
    } else {
      if (pos[i][0] > curr_pos) {
        if (pos[i][2] > 0) {
          ans += pos[i][1] - curr_pos + 1;
          curr_pos = pos[i][1];
        } else
          ans += 1;
      } else {
        if (pos[i][2] > 0) {
          ans += pos[i][1] - pos[i][0] + curr_pos - pos[i][0] + 1;
          curr_pos = pos[i][1];
        } else
          ans += 1;
      }
    }
    no_of_weeds -= pos[i][2];
    if (no_of_weeds == 0) break;
  }
  printf("%d", ans);
  return 0;
}
