#include <bits/stdc++.h>
const int MAXN = 500000;
using namespace std;
int n, k;
char s[2][MAXN];
int q[MAXN], d[MAXN];
void out(string verdict) {
  cout << verdict << endl;
  exit(0);
}
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s%s", s[0], s[1]);
  q[0] = 0;
  memset(d, -1, sizeof(d));
  d[0] = 0;
  for (int l = 0, r = 1; l < r; l++) {
    int u = q[l] >> 1, v = q[l] & 1;
    if (d[q[l]] > u) continue;
    if (u + k >= n) out("YES");
    if (d[(u + 1) * 2 + v] == -1 && s[v][u + 1] != 'X') {
      d[(u + 1) * 2 + v] = d[q[l]] + 1;
      q[r++] = (u + 1) * 2 + v;
    }
    if (u && d[(u - 1) * 2 + v] == -1 && s[v][u - 1] != 'X') {
      d[(u - 1) * 2 + v] = d[q[l]] + 1;
      q[r++] = (u - 1) * 2 + v;
    }
    if (d[(u + k) * 2 + (v ^ 1)] == -1 && s[v ^ 1][u + k] != 'X') {
      d[(u + k) * 2 + (v ^ 1)] = d[q[l]] + 1;
      q[r++] = (u + k) * 2 + (v ^ 1);
    }
  }
  out("NO");
  return 0;
}
