#include <bits/stdc++.h>
using namespace std;
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
const int maxn = 1e5 + 10;
int n, k;
char A[2][maxn];
queue<pair<int, int> > q;
void up(int c, int second) {
  if (A[c][second] != 'X') A[c][second] = 'X', q.push(make_pair(c, second));
}
int main() {
  cin >> n >> k >> A[0] >> A[1];
  up(0, 0);
  int qq = 1, pp = 0;
  while (q.size()) {
    pair<int, int> p = q.front();
    q.pop();
    if (--qq == 0) A[0][pp] = A[1][pp] = 'X';
    if (p.second + k >= n) return cout << "YES", 0;
    if (p.second + 1 <= n) up(p.first, p.second + 1);
    if (p.second - 1 >= 0) up(p.first, p.second - 1);
    up(p.first ^ 1, p.second + k);
    if (qq == 0) qq = q.size(), pp++;
  }
  return cout << "NO", 0;
}
