#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k;
  string wall[2];
  int water = 0;
  cin >> n >> k;
  cin >> wall[0] >> wall[1];
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    queue<pair<int, int> > next;
    do {
      pair<int, int> pos = q.front();
      q.pop();
      if (pos.second + k >= n) {
        cout << "YES" << endl;
        return 0;
      }
      if (pos.second - 1 > water && wall[pos.first][pos.second - 1] != 'X') {
        wall[pos.first][pos.second - 1] = 'X';
        next.push(make_pair(pos.first, pos.second - 1));
      }
      if (wall[pos.first][pos.second + 1] != 'X') {
        wall[pos.first][pos.second + 1] = 'X';
        next.push(make_pair(pos.first, pos.second + 1));
      }
      if (wall[1 - pos.first][pos.second + k] != 'X') {
        wall[1 - pos.first][pos.second + k] = 'X';
        next.push(make_pair(1 - pos.first, pos.second + k));
      }
    } while (!q.empty());
    ++water;
    q = next;
  }
  cout << "NO" << endl;
}
