#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<char> > m(2, vector<char>(n));
  for (int i = 0; i < n; i++) cin >> m[0][i];
  for (int i = 0; i < n; i++) cin >> m[1][i];
  vector<vector<bool> > v(2, vector<bool>(n, false));
  bool ha_arribat = false;
  stack<pair<int, int> > q;
  stack<int> q2;
  q.push(pair<int, int>(0, 0));
  q2.push(0);
  while (!ha_arribat && !q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int c = p.first;
    int a = p.second;
    int w = q2.top();
    q2.pop();
    if (a + k >= n) {
      ha_arribat = true;
      continue;
    }
    v[c][a] = true;
    if (a - 1 >= w + 1) {
      if (!v[c][a - 1] && m[c][a - 1] != 'X') {
        q.push(pair<int, int>(c, a - 1));
        q2.push(w + 1);
      }
    }
    if (!v[c][a + 1] && m[c][a + 1] != 'X') {
      q.push(pair<int, int>(c, a + 1));
      q2.push(w + 1);
    }
    if (!v[1 - c][a + k] && m[1 - c][a + k] != 'X') {
      q.push(pair<int, int>(1 - c, a + k));
      q2.push(w + 1);
    }
  }
  if (ha_arribat)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
