#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
char s[2][maxn];
int n, k;
int qx[maxn * 10], qy[maxn * 10];
int f[2][maxn];
void bfs() {
  int head = 0, tail = 0;
  qx[head] = 0, qy[head] = 1;
  f[0][1] = 1;
  while (head <= tail) {
    int sx = qx[head], sy = qy[head];
    head++;
    if (sy > n - k) {
      printf("YES\n");
      exit(0);
    }
    if (sy < n && f[sx][sy + 1] == 0 && s[sx][sy + 1] != 'X') {
      qx[++tail] = sx, qy[tail] = sy + 1;
      f[sx][sy + 1] = f[sx][sy] + 1;
    }
    if (sy > 1 && f[sx][sy - 1] == 0 && s[sx][sy - 1] != 'X' &&
        f[sx][sy] + 1 <= sy - 1) {
      qx[++tail] = sx, qy[tail] = sy - 1;
      f[sx][sy - 1] = f[sx][sy] + 1;
    }
    if (sy + k <= n && f[(sx ^ 1)][sy + k] == 0 && s[(sx ^ 1)][sy + k] != 'X' &&
        f[sx][sy] + 1 <= sy + k) {
      qx[++tail] = (sx ^ 1), qy[tail] = sy + k;
      f[(sx ^ 1)][sy + k] = f[sx][sy] + 1;
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s", s[0] + 1);
  scanf("%s", s[1] + 1);
  bfs();
  printf("NO\n");
  return 0;
}
