#include <bits/stdc++.h>
using namespace std;
int n, k, vis[200010][2];
string s[2];
bool rec(int w, int wl, int h) {
  if (h < 0) return false;
  if (h >= n) return true;
  if (wl >= h) return false;
  if (s[w][h] == 'X') return false;
  if (vis[h][w]) return false;
  vis[h][w] = 1;
  return (rec(w, wl + 1, h - 1) || rec(w ^ 1, wl + 1, h + k) ||
          rec(w, wl + 1, h + 1));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(vis, 0, sizeof vis);
  cin >> n >> k >> s[0] >> s[1];
  if (rec(0, -1, 0)) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
