#include <bits/stdc++.h>
const int N = 100000 + 10;
struct node {
  int id, h;
};
int vis[2][N];
char a[2][N];
int len, K;
std::queue<node> Q;
bool work() {
  if (a[0][0] == 'X') return false;
  memset(vis, 0, sizeof vis);
  vis[0][0] = 1;
  Q.push((node){0, 0});
  int nid, nh, wh;
  while (!Q.empty()) {
    node u = Q.front();
    Q.pop();
    int ns = vis[u.id][u.h] + 1;
    wh = vis[u.id][u.h] - 1;
    nid = u.id;
    nh = u.h + 1;
    if (nh >= len) nh = len;
    if (wh < nh && vis[nid][nh] == 0) {
      if (a[nid][nh] != 'X') {
        vis[nid][nh] = ns;
        Q.push((node){nid, nh});
      }
    }
    nid = 1 - u.id;
    nh = u.h + K;
    if (nh >= len) nh = len;
    if (wh < nh && vis[nid][nh] == 0) {
      if (a[nid][nh] != 'X') {
        vis[nid][nh] = ns;
        Q.push((node){nid, nh});
      }
    }
    nid = u.id;
    nh = u.h - 1;
    if (wh < nh && nh >= 0 && vis[nid][nh] == 0) {
      if (a[nid][nh] != 'X') {
        vis[nid][nh] = ns;
        Q.push((node){nid, nh});
      }
    }
  }
  bool f = false;
  if (vis[0][len] || vis[1][len]) f = true;
  return f;
}
int main() {
  scanf("%d%d", &len, &K);
  scanf("%s%s", a[0], a[1]);
  if (work())
    puts("YES");
  else
    puts("NO");
  return 0;
}
