#include <bits/stdc++.h>
using namespace std;
int dist[2][210000];
char s[2][210000];
int n, k;
int Vx[] = {-1, 1, k};
int Vy[] = {0, 0, 1};
int bfs() {
  queue<int> Q;
  Q.push(0);
  Q.push(0);
  memset(dist, -1, sizeof dist);
  dist[0][0] = 0;
  while (!Q.empty()) {
    int lado = Q.front();
    Q.pop();
    int x = Q.front();
    Q.pop();
    if (x >= n) return 1;
    if (dist[lado][x] > x) continue;
    for (int i = 0; i < 3; i++) {
      int xx, yy;
      if (i != 2)
        xx = lado ^ Vy[i], yy = x + Vx[i];
      else
        xx = lado ^ Vy[i], yy = x + k;
      if (yy < 0) continue;
      if (s[xx][yy] == 'X') continue;
      if (dist[xx][yy] != -1) continue;
      dist[xx][yy] = dist[lado][x] + 1;
      Q.push(xx);
      Q.push(yy);
    }
  }
  return 0;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < 2; i++) scanf(" %s", s[i]);
  int ans = bfs();
  if (ans)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
