#include <bits/stdc++.h>
using namespace std;
char Map[2][100005];
int vis[2][100005];
struct node {
  int type;
  int t, pos;
  void read(int t1, int t2, int t3) {
    type = t1;
    t = t2;
    pos = t3;
  }
} Q[200005];
int main() {
  int n, m, tp, t, pos;
  while (scanf("%d%d", &n, &m) != -1) {
    scanf("%s%s", Map[0], Map[1]);
    memset(vis, 0, sizeof(vis));
    vis[0][0] = true;
    int st, ed;
    st = ed = 1;
    Q[1].read(0, 0, 0);
    bool flag = false;
    while (st <= ed && !flag) {
      pos = Q[st].pos;
      tp = Q[st].type;
      t = Q[st].t;
      st++;
      if (!vis[tp][pos + 1] && Map[tp][pos + 1] != 'X' && t + 1 <= pos + 1) {
        vis[tp][pos + 1] = true;
        Q[++ed].read(tp, t + 1, pos + 1);
        if (pos + 1 > n - 1) flag = true;
      }
      if (pos - 1 >= 0 && !vis[tp][pos - 1] && Map[tp][pos - 1] != 'X' &&
          t + 1 <= pos - 1) {
        vis[tp][pos - 1] = true;
        Q[++ed].read(tp, t + 1, pos - 1);
      }
      if (pos + m > n - 1 || (!vis[!tp][pos + m] && Map[!tp][pos + m] != 'X' &&
                              t + 1 <= pos + m)) {
        if (pos + m > n - 1) {
          flag = true;
          break;
        }
        vis[!tp][pos + m] = true;
        Q[++ed].read(!tp, t + 1, pos + m);
      }
    }
    if (flag)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
