#include <bits/stdc++.h>
using namespace std;
const int nmax = 200009;
priority_queue<pair<int, int> > Q;
char s[2][nmax];
int F[2][nmax];
void go(int v, int w, int t) {
  if (v > 0 && (F[w][v] == -1 || t < F[w][v]) && s[w][v] != 'X') {
    if (t < v) {
      F[w][v] = t;
      Q.push(make_pair(-t, (v << 1) + w));
    }
  }
}
int n, k;
int main() {
  scanf("%d %d", &n, &k);
  scanf("%s", &s[0][1]);
  scanf("%s", &s[1][1]);
  memset(F, -1, sizeof(F));
  F[0][1] = 0;
  Q.push(make_pair(0, 1 << 1));
  bool ok = false;
  while (!Q.empty()) {
    int v = Q.top().second;
    int w = v & 1;
    v >>= 1;
    int d = -Q.top().first;
    Q.pop();
    if (v > n) {
      ok = true;
      break;
    }
    if (d == F[w][v]) {
      go(v + 1, w, d + 1);
      go(v - 1, w, d + 1);
      go(v + k, 1 - w, d + 1);
    }
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
