#include <bits/stdc++.h>
using namespace std;
char a[2][500005];
int n, k;
struct node {
  int x, y, cnt;
};
void work() {
  int f = 0;
  queue<node> q;
  node t;
  t.x = 0;
  t.y = 0;
  t.cnt = 0;
  q.push(t);
  while (!q.empty()) {
    node c = q.front();
    q.pop();
    if (c.y >= n) {
      f = 1;
      printf("YES\n");
      break;
    }
    t.x = c.x;
    t.y = c.y + 1;
    t.cnt = c.cnt + 1;
    if (t.y >= 0 && a[t.x][t.y] != 'X') {
      q.push(t);
      a[t.x][t.y] = 'X';
    }
    t.y = c.y - 1;
    if (t.y >= 0 && a[t.x][t.y] != 'X' && t.y >= t.cnt) {
      q.push(t);
      a[t.x][t.y] = 'X';
    }
    t.x = (c.x + 1) % 2;
    t.y = c.y + k;
    if (t.y >= 0 && a[t.x][t.y] != 'X') {
      q.push(t);
      a[t.x][t.y] = 'X';
    }
  }
  if (!f) {
    printf("NO");
  }
}
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s%s", a[0], a[1]);
  work();
  return 0;
}
