#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
queue<pair<int, int> > saf;
vector<pair<int, int> > yal[3][maxn];
int mark[3][maxn], h[3][maxn];
int main() {
  int n, k;
  cin >> n >> k;
  string w1, w2;
  cin >> w1 >> w2;
  w1 = 'X' + w1 + '-';
  w2 = 'X' + w2 + '-';
  for (int i = 1; i <= n; i++) {
    if (w1[i] != 'X') {
      if (w1[i + 1] != 'X') {
        yal[1][i].push_back(pair<int, int>(1, i + 1));
      }
      if (w1[i - 1] != 'X') {
        yal[1][i].push_back(pair<int, int>(1, i - 1));
      }
      if (w2[min(n + 1, i + k)] != 'X') {
        yal[1][i].push_back(pair<int, int>(2, min(n + 1, i + k)));
      }
    }
    if (w2[i] != 'X') {
      if (w2[i + 1] != 'X') {
        yal[2][i].push_back(pair<int, int>(2, i + 1));
      }
      if (w2[i - 1] != 'X') {
        yal[2][i].push_back(pair<int, int>(2, i - 1));
      }
      if (w1[min(n + 1, i + k)] != 'X') {
        yal[2][i].push_back(pair<int, int>(1, min(n + 1, i + k)));
      }
    }
  }
  pair<int, int> now = (pair<int, int>(1, 1));
  saf.push(now);
  mark[now.first][now.second] = 1;
  while (!saf.empty()) {
    now = saf.front();
    if (h[now.first][now.second] >= now.second) {
      saf.pop();
      continue;
    }
    for (int i = 0; i < yal[now.first][now.second].size(); i++) {
      pair<int, int> c = yal[now.first][now.second][i];
      if (mark[c.first][c.second]) continue;
      saf.push(c);
      h[c.first][c.second] = h[now.first][now.second] + 1;
      mark[c.first][c.second] = 1;
    }
    saf.pop();
  }
  if (mark[1][n + 1] or mark[2][n + 1]) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
