#include <bits/stdc++.h>
using namespace std;
vector<int> adj[222222];
int q[222222], times[222222], v[222222] = {0};
int solve(int s, int n) {
  int curtime = 0;
  int ed = 0;
  q[ed] = s;
  times[ed++] = 0;
  for (int i = 0; i < ed; i++) {
    int cnode = q[i];
    int ch = cnode >= n ? cnode - n : cnode;
    if (times[i] <= ch) {
      for (int j = 0; j < adj[cnode].size(); j++)
        if (v[adj[cnode][j]] == 0) {
          v[adj[cnode][j]] = 1;
          if (adj[cnode][j] == 2 * n) return true;
          q[ed] = adj[cnode][j];
          times[ed++] = times[i] + 1;
        }
    }
  }
  return false;
}
int main() {
  int n, k;
  string l, r;
  cin >> n >> k >> l >> r;
  for (int i = 0; i < n; i++)
    if (l[i] != 'X') {
      if (i > 0 && l[i - 1] != 'X') adj[i].push_back(i - 1);
      if (i + 1 < n && l[i + 1] != 'X') adj[i].push_back(i + 1);
      if (i + k >= n) adj[i].push_back(2 * n);
      if (i + k < n && r[i + k] != 'X') adj[i].push_back(n + i + k);
    }
  for (int i = 0; i < n; i++)
    if (r[i] != 'X') {
      if (i > 0 && r[i - 1] != 'X') adj[i + n].push_back(i - 1 + n);
      if (i + 1 < n && r[i + 1] != 'X') adj[i + n].push_back(i + 1 + n);
      if (i + k < n && l[i + k] != 'X') adj[i + n].push_back(i + k);
      if (i + k >= n) adj[i + n].push_back(2 * n);
    }
  cout << (solve(0, n) ? "YES" : "NO");
  return 0;
}
