#include <bits/stdc++.h>
using namespace std;
int n, k, fin, dist[200002];
string sl, sr;
vector<int> g[200002];
queue<int> q;
int main() {
  cin >> n >> k >> sl >> sr;
  fill_n(dist + 2, 2 * n, INT_MAX);
  fin = 2 * n + 1;
  for (int i = 0; i < n; i++) {
    if (sl[i] != 'X') {
      if (i < n - 1 and sl[i + 1] != 'X')
        g[i + 1].push_back(i + 2), g[i + 2].push_back(i + 1);
      if (i + k < n and sr[i + k] != 'X') g[i + 1].push_back(n + i + k + 1);
      if (i >= n - k) g[i + 1].push_back(fin);
    }
    if (sr[i] != 'X') {
      if (i < n - 1 and sr[i + 1] != 'X')
        g[n + i + 1].push_back(n + i + 2), g[n + i + 2].push_back(n + i + 1);
      if (i + k < n and sl[i + k] != 'X') g[n + i + 1].push_back(i + k + 1);
      if (i >= n - k) g[n + i + 1].push_back(fin);
    }
  }
  q.push(1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (dist[u] >= ((u > n) ? u - n : u)) {
      dist[u] = INT_MAX;
      continue;
    }
    for (int v : g[u])
      if (dist[v] == INT_MAX) dist[v] = dist[u] + 1, q.push(v);
  }
  if (dist[fin] != INT_MAX)
    printf("YES");
  else
    printf("NO");
}
