#include <bits/stdc++.h>
using namespace std;
const int N = 200010, INF = 1000000000;
int n, k, Time[N][3];
char s[3][N];
bool vis[N][3];
bool bfs() {
  for (int i = 0; i <= n + k; i++) Time[i][0] = Time[i][1] = INF;
  queue<pair<int, int> > Q;
  Q.push(make_pair(0, 0)), Time[0][0] = 0;
  while (Q.size()) {
    int pos = Q.front().first;
    bool p = Q.front().second;
    Q.pop();
    if (Time[pos][p] > pos || vis[pos][p]) continue;
    vis[pos][p] = 1;
    if (pos >= n - 1) return true;
    if (Time[pos][p] + 1 < Time[pos + 1][p] &&
        (s[p][pos + 1] != 'X' || pos + 1 > n - 1))
      Q.push(make_pair(pos + 1, p)), Time[pos + 1][p] = Time[pos][p] + 1;
    if (Time[pos][p] + 1 < Time[pos - 1][p] &&
        (s[p][pos - 1] != 'X' || pos - 1 > n - 1) && pos - 1 >= 0)
      Q.push(make_pair(pos - 1, p)), Time[pos - 1][p] = Time[pos][p] + 1;
    if (Time[pos][p] + 1 < Time[pos + k][!p] &&
        (s[!p][pos + k] != 'X' || pos + k > n - 1))
      Q.push(make_pair(pos + k, !p)), Time[pos + k][!p] = Time[pos][p] + 1;
  }
  return false;
}
int main() {
  scanf("%d %d %s %s", &n, &k, s[0], s[1]);
  if (bfs())
    printf("YES");
  else
    printf("NO");
  return 0;
}
