#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
int mark[2][M];
int h[2][M];
int32_t main() {
  ios_base::sync_with_stdio(false);
  ;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < 2; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++)
      if (s[j] == 'X') mark[i][j] = 1;
  }
  mark[0][0] = 1;
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  while (q.size()) {
    int x = (q.front()).first;
    int y = (q.front()).second;
    if (y >= n) return cout << "YES" << endl, 0;
    int t = h[x][y];
    for (int i = 0; i < 2; i++)
      if (!mark[i][t]) mark[i][t] = 1;
    if (!mark[x][y + 1]) {
      h[x][y + 1] = h[x][y] + 1;
      mark[x][y + 1] = 1;
      q.push(make_pair(x, y + 1));
    }
    if (y > 0 && !mark[x][y - 1]) {
      h[x][y - 1] = h[x][y] + 1;
      mark[x][y - 1] = h[x][y] + 1;
      q.push(make_pair(x, y - 1));
    }
    if (!mark[1 - x][y + k]) {
      h[1 - x][y + k] = h[x][y] + 1;
      mark[1 - x][y + k] = 1;
      q.push(make_pair(1 - x, y + k));
    }
    q.pop();
  }
  return cout << "NO" << endl, 0;
}
