#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-4;
int dis[100200][2];
string path[2];
int n, k;
int done() {
  memset(dis, -1, sizeof(dis));
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  dis[0][0] = 0;
  while (!q.empty()) {
    int h = q.front().first;
    int d = q.front().second;
    q.pop();
    int t = dis[h][d];
    if (h > 0 && t + 1 < h) {
      if (path[d][h - 1] != 'X') {
        if (dis[h - 1][d] == -1 || dis[h][d] + 1 < dis[h - 1][d]) {
          dis[h - 1][d] = dis[h][d] + 1;
          q.push(make_pair(h - 1, d));
        }
      }
    }
    if (h + 1 >= n) return 1;
    if (path[d][h + 1] != 'X') {
      if (dis[h + 1][d] == -1 || dis[h][d] + 1 < dis[h + 1][d]) {
        dis[h + 1][d] = dis[h][d] + 1;
        q.push(make_pair(h + 1, d));
      }
    }
    if (h + k >= n) return 1;
    if (path[d ^ 1][h + k] != 'X') {
      if (dis[h + k][d ^ 1] == -1 || dis[h][d] + 1 < dis[h + k][d ^ 1]) {
        dis[h + k][d ^ 1] = dis[h][d] + 1;
        q.push(make_pair(h + k, d ^ 1));
      }
    }
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < 2; ++i) {
    cin >> path[i];
  }
  if (done())
    printf("YES\n");
  else
    printf("NO\n");
}
