#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000000 + 100;
queue<int> que;
int n, k, s, d[Maxn];
bool a[Maxn], bkol;
void input() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    char x;
    cin >> x;
    if (x != 'X') a[i * 2 - 1] = true;
  }
  for (int i = 1; i <= n; i++) {
    char x;
    cin >> x;
    if (x != 'X') a[i * 2] = true;
  }
  return;
}
bool isvalid(int v, int vprim) {
  int mv;
  if (vprim % 2 == 1) {
    mv = (vprim + 1) / 2;
  } else
    mv = vprim / 2;
  if (a[vprim] == true && d[vprim] == -1 && d[v] + 1 < mv && vprim > 0) {
    if (n - mv < k && bkol == false) {
      cout << "YES";
      bkol = true;
    }
    return true;
  } else
    return false;
}
void visvalid(int vprim) {
  int mv;
  if (vprim % 2 == 1) {
    mv = (vprim + 1) / 2;
  } else
    mv = vprim / 2;
  if (n - mv < k && bkol != true) {
    cout << "YES";
    bkol = true;
  }
  return;
}
void bfs() {
  d[s] = 0;
  que.push(s);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (isvalid(u, u - 2)) {
      que.push(u - 2);
      d[u - 2] = d[u] + 1;
    }
    if (isvalid(u, u + 2)) {
      que.push(u + 2);
      d[u + 2] = d[u] + 1;
    }
    int kprim;
    if (u % 2 == 0)
      kprim = k * 2 + u - 1;
    else
      kprim = k * 2 + u + 1;
    if (isvalid(u, kprim)) {
      que.push(kprim);
      d[kprim] = d[u] + 1;
    }
    visvalid(u);
    if (bkol == true) return;
  }
  if (bkol == false) {
    cout << "NO";
  }
}
int main() {
  input();
  s = 1;
  for (int i = 0; i <= 2 * n; i++) {
    d[i] = -1;
  }
  bfs();
}
