#include <bits/stdc++.h>
using namespace std;
char s[3][100005];
vector<int> g[100005 * 2];
int f, n, k;
set<pair<int, int> > Q;
int dp[100005 * 2];
bool ok(int v, int u) {
  int i = u == f ? n : u % n;
  return (dp[v] < i);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < 2; ++i) scanf("%s", s[i]);
  f = n * 2;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      if (s[i][j] == 'X') continue;
      int v = i * n + j;
      g[v].push_back(j + 1 == n ? f : v + 1);
      if (j > 0) g[v].push_back(v - 1);
      g[v].push_back(j + k >= n ? f : j + k + (!i * n));
    }
  }
  for (int i = 1; i <= f; ++i) dp[i] = int(1e9);
  Q.insert(make_pair(dp[0], 0));
  while (!Q.empty()) {
    int v = Q.begin()->second;
    Q.erase(Q.begin());
    for (int j = 0; j < int((g[v]).size()); ++j) {
      int to = g[v][j];
      if (dp[v] + 1 < dp[to] && ok(v, to)) {
        Q.erase(make_pair(dp[to], to));
        dp[to] = dp[v] + 1;
        Q.insert(make_pair(dp[to], to));
      }
    }
  }
  puts(dp[f] == int(1e9) ? "NO" : "YES");
  return 0;
}
