#include <bits/stdc++.h>
using namespace std;
int n;
int k;
char lw[100001];
char rw[100001];
bool get(int l, int r, int level) {
  bool ret = false;
  if (l >= 0) {
    if (l >= n) {
      ret = true;
    } else {
      if (lw[l] != 'X' && l >= level) {
        lw[l] = 'X';
        ++level;
        if (!ret) {
          ret = get(-1, l + k, level);
        }
        if (!ret) {
          ret = get(l + 1, -1, level);
        }
        if (!ret) {
          ret = get(l - 1, -1, level);
        }
      }
    }
  } else if (r >= 0) {
    if (r >= n) {
      ret = true;
    } else {
      if (rw[r] != 'X' && r >= level) {
        rw[r] = 'X';
        ++level;
        if (!ret) {
          ret = get(r + k, -1, level);
        }
        if (!ret) {
          ret = get(-1, r + 1, level);
        }
        if (!ret) {
          ret = get(-1, r - 1, level);
        }
      }
    }
  }
  return ret;
}
int main() {
  cin >> n;
  cin >> k;
  for (int i = 0; i < n; i++) {
    cin >> lw[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> rw[i];
  }
  bool res = get(0, -1, 0);
  cout << (res ? "YES" : "NO") << endl;
  return 0;
}
