#include <bits/stdc++.h>
using namespace std;
int Q[1000000][2], L, R;
int f[101000][2];
int N, K, i, ans;
char mat[2][101000];
bool mark[101000][2];
void push(int pos, int st, int val) {
  if (pos >= N) {
    ans = 1;
    return;
  }
  if (mat[st][pos] == 'X') return;
  if (f[pos][st] == -1 || val < f[pos][st]) {
    f[pos][st] = val;
    if (!mark[pos][st]) {
      mark[pos][st] = 1;
      Q[R][0] = pos, Q[R][1] = st;
      R++;
    }
  }
}
int main() {
  while (scanf("%d%d", &N, &K) != EOF) {
    scanf("%s%s", mat[0], mat[1]);
    L = 0, R = 0;
    ans = 0;
    for (i = 0; i < N; i++) f[i][0] = f[i][1] = -1, mark[i][0] = mark[i][1] = 0;
    push(0, 0, 0);
    while (L < R && !ans) {
      int pos = Q[L][0], st = Q[L][1];
      mark[pos][st] = 0;
      L++;
      if (pos < f[pos][st] || mat[st][pos] == 'X') continue;
      push(pos + 1, st, f[pos][st] + 1);
      if (pos >= 1) push(pos - 1, st, f[pos][st] + 1);
      push(pos + K, st ^ 1, f[pos][st] + 1);
    }
    printf(ans ? "YES\n" : "NO\n");
  }
}
