#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int n, k, vis[300005] = {0}, d[300005] = {0};
string lft, rgt;
queue<long long int> q;
vector<long long int> v[300005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, x, y;
  cin >> n >> k;
  cin >> lft;
  cin >> rgt;
  if (k < n && rgt[k] == '-') v[1].push_back(k + 1 + n);
  for (i = 1; i < n; i++) {
    if (lft[i] == 'X') continue;
    if (lft[i - 1] != 'X') {
      v[i + 1].push_back(i);
      v[i].push_back(i + 1);
    }
    if (i + k < n && rgt[i + k] == '-') v[i + 1].push_back(i + k + 1 + n);
  }
  if (k < n && lft[k] == '-') v[n + 1].push_back(k + 1);
  for (i = 1; i < n; i++) {
    if (rgt[i] == 'X') continue;
    if (rgt[i - 1] != 'X') {
      v[i + n + 1].push_back(i + n);
      v[i + n].push_back(i + n + 1);
    }
    if (i + k < n && lft[i + k] == '-') v[i + n + 1].push_back(i + k + 1);
  }
  q.push(1);
  d[1] = 0;
  vis[1] = 1;
  while (!q.empty()) {
    long long int i, s = q.front();
    q.pop();
    for (i = 0; i < v[s].size(); i++) {
      if (!vis[v[s][i]]) {
        if ((v[s][i] >= 1 && v[s][i] <= n && d[s] + 1 < v[s][i]) ||
            (v[s][i] >= n + 1 && v[s][i] <= 2 * n && d[s] + 1 < v[s][i] - n)) {
          vis[v[s][i]] = 1;
          d[v[s][i]] = d[s] + 1;
          q.push(v[s][i]);
        }
      }
    }
  }
  if (vis[n] || vis[2 * n]) {
    cout << "YES";
    return 0;
  }
  for (i = n; i >= n - k; i--) {
    if (vis[i] && (rgt[i + k - 1] == '-' || i + k + n > 2 * n)) {
      cout << "YES";
      return 0;
    }
  }
  for (i = 2 * n; i >= n + n - k; i--) {
    if (vis[i] && (lft[i + k - 1 - n] == '-' || i + k - n > n)) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
