#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, i, j, k, INF = 1E9, id, x, d;
  bool solved = false;
  string s[2];
  cin >> n >> k >> s[0] >> s[1];
  vector<vector<int>> dp(2, vector<int>(n, INF));
  queue<pair<int, int>> q;
  q.push({0, 0});
  dp[0][0] = 1;
  while (!q.empty()) {
    tie(id, x) = q.front();
    q.pop();
    d = dp[id][x];
    if (x + 1 < d) continue;
    if ((x > 0) && (dp[id][x - 1] > d + 1) && (s[id][x - 1] != 'X')) {
      dp[id][x - 1] = d + 1;
      q.push({id, x - 1});
    }
    if (x + k >= n) {
      solved = true;
      break;
    }
    if ((x < n - 1) && (dp[id][x + 1] > d + 1) && (s[id][x + 1] != 'X')) {
      dp[id][x + 1] = d + 1;
      q.push({id, x + 1});
    }
    if ((x + k < n) && (dp[1 - id][x + k] > d + 1) &&
        (s[1 - id][x + k] != 'X')) {
      dp[1 - id][x + k] = d + 1;
      q.push({1 - id, x + k});
    }
  }
  if (solved)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
