#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
int n, k, dist[2][MAXN];
char c[2][MAXN];
queue<pair<int, int> > q;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < 2; i++) {
    scanf("%s", c[i]);
    for (int j = 0; j < n; j++) {
      dist[i][j] = -1;
    }
  }
  dist[0][0] = 0;
  q.push({0, 0});
  while (!q.empty()) {
    int vx = q.front().first;
    int vy = q.front().second;
    int d = dist[vx][vy];
    q.pop();
    if (vy + k >= n) {
      puts("YES");
      exit(0);
    }
    if (vy > 0 && d + 1 <= vy - 1 && c[vx][vy - 1] != 'X' &&
        dist[vx][vy - 1] == -1) {
      dist[vx][vy - 1] = d + 1;
      q.push({vx, vy - 1});
    }
    if (c[vx][vy + 1] != 'X' && dist[vx][vy + 1] == -1) {
      dist[vx][vy + 1] = d + 1;
      q.push({vx, vy + 1});
    }
    if (c[1 - vx][vy + k] != 'X' && dist[1 - vx][vy + k] == -1) {
      dist[1 - vx][vy + k] = d + 1;
      q.push({1 - vx, vy + k});
    }
  }
  puts("NO");
  return 0;
}
