#include <bits/stdc++.h>
using namespace std;
int n, k, wall = 0;
string w[2];
bool vis[2][100005];
queue<pair<pair<int, int>, int> > q;
int main(int argc, const char* argv[]) {
  memset(vis, 0, sizeof(vis));
  cin >> n >> k >> w[0] >> w[1];
  w[0] = " " + w[0];
  w[1] = " " + w[1];
  vis[0][0] = true;
  vis[1][0] = true;
  q.push(make_pair(make_pair(0, 1), 0));
  while (!q.empty()) {
    pair<pair<int, int>, int> cur = q.front();
    q.pop();
    if (cur.second >= cur.first.second) continue;
    if (cur.first.second + k > n) {
      cout << "YES";
      return 0;
    }
    if (w[cur.first.first][cur.first.second + 1] != 'X' &&
        !vis[cur.first.first][cur.first.second + 1]) {
      vis[cur.first.first][cur.first.second + 1] = true;
      q.push(make_pair(make_pair(cur.first.first, cur.first.second + 1),
                       cur.second + 1));
    }
    if (w[cur.first.first][cur.first.second - 1] != 'X' &&
        !vis[cur.first.first][cur.first.second - 1]) {
      vis[cur.first.first][cur.first.second - 1] = true;
      q.push(make_pair(make_pair(cur.first.first, cur.first.second - 1),
                       cur.second + 1));
    }
    if (w[cur.first.first ^ 1][cur.first.second + k] != 'X' &&
        !vis[cur.first.first ^ 1][cur.first.second + k]) {
      vis[cur.first.first ^ 1][cur.first.second + k] = true;
      q.push(make_pair(make_pair(cur.first.first ^ 1, cur.first.second + k),
                       cur.second + 1));
    }
  }
  cout << "NO";
  return 0;
}
