#include <bits/stdc++.h>
using namespace std;
const int INFI = (1 << 30);
const long long INFL = (1LL << 62);
struct wll {
  wll(int a, int b, int c) : i(a), j(b), ds(c) {}
  wll() : i(0), j(0), ds(0) {}
  int i, j, ds;
};
struct cmp {
  bool operator()(const wll &w1, const wll &w2) { return w1.ds < w2.ds; }
};
int main() {
  int n, k;
  cin >> n >> k;
  bool w[2][100001] = {};
  for (int i = 0; i < 2; i++)
    for (int j = 1; j <= n; j++) {
      char ch;
      cin >> ch;
      w[i][j] = (ch == 'X');
    }
  int d[2][1000001];
  queue<wll> pq;
  pq.push(wll(0, 1, 0));
  for (int i = 0; i < 2; i++)
    for (int j = 1; j <= n; j++) d[i][j] = INFI;
  d[0][1] = 1;
  while (!pq.empty()) {
    int i = pq.front().i;
    int j = pq.front().j;
    int tm = pq.front().ds;
    pq.pop();
    if (j - 1 > tm + 1 && !w[i][j - 1] && d[i][j - 1] > tm + 1) {
      d[i][j - 1] = tm + 1;
      pq.push(wll(i, j - 1, d[i][j - 1]));
    }
    if (!w[i][j + 1] && d[i][j + 1] > tm + 1) {
      d[i][j + 1] = tm + 1;
      pq.push(wll(i, j + 1, d[i][j + 1]));
    }
    if (j + k > n) {
      cout << "YES";
      return 0;
    }
    if (!w[!i][j + k] && d[!i][j + k] > tm + 1) {
      d[!i][j + k] = tm + 1;
      pq.push(wll(!i, j + k, d[!i][j + k]));
    }
  }
  cout << "NO";
  return 0;
}
