#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5;
vector<int> adj[maxn];
int dist[maxn];
bool vis[maxn];
int n, k;
void add(int a, int b) {
  adj[a].push_back(b);
  adj[b].push_back(a);
}
void bfs(int v) {
  queue<int> verts;
  verts.push(v);
  dist[v] = 0;
  while (!verts.empty()) {
    v = verts.front();
    verts.pop();
    for (int u : adj[v]) {
      int agua;
      if (u < n)
        agua = u + 1;
      else
        agua = u + 1 - n;
      if (dist[u] > dist[v] + 1 && dist[v] + 1 < agua) {
        dist[u] = dist[v] + 1;
        verts.push(u);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(dist, 0x3f, sizeof dist);
  cin >> n >> k;
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = 0; i < n; i++) {
    if (s1[i] == 'X') continue;
    if (i > 0) {
      if (s1[i - 1] == '-') add(i, i - 1);
    }
    if (i < n - 1) {
      if (s1[i + 1] == '-') add(i, i + 1);
    }
    if (i + k < n) {
      if (s2[i + k] == '-') add(i, n + i + k);
    }
  }
  for (int i = 0; i < n; i++) {
    if (s2[i] == 'X') continue;
    if (i > 0) {
      if (s2[i - 1] == '-') add(n + i, n + i - 1);
    }
    if (i < n - 1) {
      if (s2[i + 1] == '-') add(n + i, n + i + 1);
    }
    if (i + k < n) {
      if (s1[i + k] == '-') add(n + i, i + k);
    }
  }
  bfs(0);
  bool can = 0;
  for (int i = n - 1; i >= n - k; i--) {
    if (dist[i] < i + 1) can = 1;
  }
  for (int i = 2 * n - 1; i >= 2 * n - k; i--) {
    if (dist[i] < i - n + 1) can = 1;
  }
  if (can)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
