#include <bits/stdc++.h>
using namespace std;
int n, k;
char l[100005], d[100005];
vector<int> niz[100005 + 100005 + 1];
bool poseceno[100005 + 100005 + 1];
int dub[100005 + 100005 + 1];
queue<int> q;
void bfs() {
  q.push(0);
  while (!q.empty()) {
    int t = q.front();
    if (t == 100005 + 100005) {
      printf("YES");
      exit(0);
    }
    q.pop();
    if (t % n < dub[t]) continue;
    for (int i = 0; i < niz[t].size(); i++) {
      if (!poseceno[niz[t][i]]) q.push(niz[t][i]);
      dub[niz[t][i]] = dub[t] + 1;
      poseceno[niz[t][i]] = true;
    }
  }
}
int main() {
  scanf("%d %d", &n, &k);
  scanf("%s", l);
  scanf("%s", d);
  for (int i = 1; i < n; i++) {
    if (!(l[i] == 'X' || l[i - 1] == 'X')) {
      niz[i].push_back(i - 1);
      niz[i - 1].push_back(i);
    }
    if (!(d[i] == 'X' || d[i - 1] == 'X')) {
      niz[n + i].push_back(n + i - 1);
      niz[n + i - 1].push_back(n + i);
    }
    int s = i - 1;
    if (l[s] != 'X') {
      if (s + k >= n)
        niz[s].push_back(100005 + 100005);
      else if (d[s + k] != 'X')
        niz[s].push_back(n + s + k);
    }
    if (d[s] != 'X') {
      if (s + k >= n)
        niz[n + s].push_back(100005 + 100005);
      else if (l[s + k] != 'X')
        niz[n + s].push_back(s + k);
    }
  }
  if (l[n - 1] != 'X') niz[n - 1].push_back(100005 + 100005);
  if (d[n - 1] != 'X') niz[n + n - 1].push_back(100005 + 100005);
  dub[0] = 0;
  bfs();
  printf("NO");
  return 0;
}
