#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int INF = 1e9;
int n, k, dist[N];
string a, b;
vector<int> g[N];
queue<int> q;
int main() {
  cin >> n >> k;
  cin >> a >> b;
  for (int i = 0; i < n; i++) {
    if (a[i] != 'X') {
      if (a[i + 1] != 'X') g[i].push_back(i + 1);
      if (i > 0 && a[i - 1] != 'X') g[i].push_back(i - 1);
      if (i + k < n && b[i + k] != 'X') g[i].push_back(n + i + k);
    }
    if (b[i] != 'X') {
      if (b[i + 1] != 'X') g[n + i].push_back(n + i + 1);
      if (i > 0 && b[i - 1] != 'X') g[n + i].push_back(n + i - 1);
      if (i + k < n && a[i + k] != 'X') g[n + i].push_back(i + k);
    }
  }
  for (int i = 0; i < 2 * n; i++) dist[i] = INF;
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < (int)g[v].size(); i++) {
      int to = g[v][i];
      if (dist[to] == INF && dist[v] + 1 <= to % n) {
        dist[to] = dist[v] + 1;
        q.push(to);
      }
    }
  }
  bool ans = false;
  for (int i = max(0, n - k); i < n; i++)
    ans |= (dist[i] != INF || dist[i + n] != INF);
  cout << (ans ? "YES" : "NO");
  return 0;
}
