#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, k, d[2][N];
char s[2][N];
bool bfs() {
  int x, y, tx, ty;
  queue<pair<int, int> > q;
  memset(d, -1, sizeof(d));
  d[0][0] = 0;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    x = q.front().first;
    y = q.front().second;
    q.pop();
    tx = x, ty = y + 1;
    if (ty >= n) return 1;
    if (s[tx][ty] != 'X' && d[tx][ty] == -1) {
      d[tx][ty] = d[x][y] + 1;
      q.push(make_pair(tx, ty));
    }
    tx = x, ty = y - 1;
    if (ty > d[x][y] && s[tx][ty] != 'X' && d[tx][ty] == -1) {
      d[tx][ty] = d[x][y] + 1;
      q.push(make_pair(tx, ty));
    }
    tx = x ^ 1, ty = y + k;
    if (ty >= n) return 1;
    if (s[tx][ty] != 'X' && d[tx][ty] == -1) {
      d[tx][ty] = d[x][y] + 1;
      q.push(make_pair(tx, ty));
    }
  }
  return 0;
}
int main() {
  scanf("%d%d%s%s", &n, &k, s[0], s[1]);
  printf(bfs() ? "YES" : "NO");
  return 0;
}
