#include <bits/stdc++.h>
using namespace std;
int readint() {
  char c;
  while (c = getchar(), (c < '0' || c > '9') && c != '-')
    ;
  bool flag = (c == '-');
  if (flag) c = getchar();
  int x = 0;
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return flag ? -x : x;
}
inline string tos(int x) {
  string s;
  while (x) s = (char)(x % 10 + '0') + s, x /= 10;
  return s;
}
queue<int> qx, qy, qz;
char c[2][100005];
bool use[2][100005];
int main() {
  ios_base::sync_with_stdio(false);
  int n, k, i, j, x, y, z;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> c[0][i];
  for (i = 1; i <= n; i++) cin >> c[1][i];
  qz.push(0);
  qx.push(0);
  qy.push(1);
  while (!qx.empty()) {
    z = qz.front();
    x = qx.front();
    y = qy.front();
    qz.pop();
    qx.pop();
    qy.pop();
    if (y > n) {
      cout << "YES";
      return 0;
    }
    if (use[x][y]) continue;
    if (c[x][y] == 'X') continue;
    if (z >= y) continue;
    use[x][y] = 1;
    qz.push(z + 1);
    qy.push(y + k);
    qx.push(1 - x);
    qz.push(z + 1);
    qy.push(y + 1);
    qx.push(x);
    qz.push(z + 1);
    qx.push(x);
    qy.push(y - 1);
  }
  cout << "NO";
  return 0;
}
