#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000 + 10;
bool mark[3][MAX];
int n, k;
char a[3][MAX];
void BFS() {
  queue<pair<pair<int, int>, int> > q;
  q.push({{1, 1}, 0});
  mark[1][1] = true;
  while (!q.empty()) {
    pair<pair<int, int>, int> cur = q.front();
    q.pop();
    int x = cur.first.first;
    int y = cur.first.second;
    int w = cur.second;
    int back = x;
    if (x == 2) {
      x = 0;
    }
    if (x + 1 > n || y + k > n) {
      cout << "YES\n";
      exit(0);
    }
    if (a[x + 1][y + k] != 'X' && mark[x + 1][y + k] == false) {
      mark[x + 1][y + k] = true;
      q.push({{x + 1, y + k}, w + 1});
    }
    x = back;
    if (a[x][y - 1] != 'X' && y - 1 > w + 1 && mark[x][y - 1] == false) {
      mark[x][y - 1] = true;
      q.push({{x, y - 1}, w + 1});
    }
    if (y + 1 > n) {
      cout << "YES\n";
      exit(0);
    }
    if (a[x][y + 1] != 'X' && mark[x][y + 1] == false) {
      mark[x][y + 1] = true;
      q.push({{x, y + 1}, w + 1});
    }
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= 2; i++) {
    string cur;
    cin >> cur;
    for (int j = 0; j < cur.size(); j++) {
      a[i][j + 1] = cur[j];
    }
  }
  BFS();
  cout << "NO\n";
}
