#include <bits/stdc++.h>
using namespace std;
const int maxint = -1u >> 1;
const double pi = 3.14159265358979323;
const double eps = 1e-8;
int n, k;
string s[2];
int f[101000][2];
bool vis[101000][2];
bool spfa() {
  memset(vis, false, sizeof(vis));
  for (int i = (0); i < (n + 5); i++) f[i][0] = f[i][1] = maxint;
  f[0][0] = 0;
  queue<pair<int, int> > que;
  que.push(make_pair(0, 0));
  while (!que.empty()) {
    pair<int, int> now = que.front();
    que.pop();
    int p = now.first, id = now.second;
    vis[p][id] = false;
    if (p + 1 >= n ||
        (p + 1 < n && s[id][p + 1] != 'X' && f[p][id] + 1 <= p + 1)) {
      if (p + 1 >= n) return true;
      if (f[p + 1][id] > f[p][id] + 1) {
        f[p + 1][id] = f[p][id] + 1;
        if (!vis[p + 1][id]) {
          vis[p + 1][id] = true;
          que.push(make_pair(p + 1, id));
        }
      }
    }
    if (p - 1 >= 0 && s[id][p - 1] != 'X' && f[p][id] + 1 <= p - 1) {
      if (f[p - 1][id] > f[p][id] + 1) {
        f[p - 1][id] = f[p][id] + 1;
        if (!vis[p - 1][id]) {
          vis[p - 1][id] = true;
          que.push(make_pair(p - 1, id));
        }
      }
    }
    if (p + k >= n ||
        (p + k < n && s[id ^ 1][p + k] != 'X' && f[p][id] + 1 <= p + k)) {
      if (p + k >= n) return true;
      if (f[p + k][id ^ 1] > f[p][id] + 1) {
        f[p + k][id ^ 1] = f[p][id] + 1;
        if (!vis[p + k][id ^ 1]) {
          vis[p + k][id ^ 1] = true;
          que.push(make_pair(p + k, id ^ 1));
        }
      }
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  cin >> s[0];
  cin >> s[1];
  s[0] += "-";
  s[1] += "-";
  bool ans = spfa();
  if (ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
