#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double PI = acos(-1);
const double EPS = 1e-8;
int t[2][100000];
int main() {
  int n, k;
  cin >> n >> k;
  string s[2];
  cin >> s[0] >> s[1];
  queue<pair<int, int> > Q;
  memset(t, -1, sizeof(t));
  t[0][0] = 0;
  Q.push(pair<int, int>(0, 0));
  int dx[] = {-1, 1, k};
  while (!Q.empty()) {
    pair<int, int> p = Q.front();
    Q.pop();
    int lr = p.first;
    int pos = p.second;
    int tm = t[lr][pos];
    for (int i = 0; i < (int)3; ++i) {
      int xx = pos + dx[i];
      if (xx < 0) continue;
      if (xx >= n) {
        cout << "YES" << endl;
        return 0;
      }
      if (i == 2) lr = !lr;
      if (s[lr][xx] == 'X') continue;
      if (t[lr][xx] != -1) continue;
      if (xx <= tm) continue;
      t[lr][xx] = tm + 1;
      Q.push(pair<int, int>(lr, xx));
    }
  }
  cout << "NO" << endl;
}
