#include <bits/stdc++.h>
using namespace std;
bool vis[2][100005];
char c[2][100005];
int main() {
  queue<pair<int, pair<int, int> > > q;
  bool flag = 0;
  int n, k;
  cin >> n >> k;
  scanf("%s%s", c[0], c[1]);
  q.push(make_pair(0, make_pair(0, 0)));
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second.first,
        de = q.front().second.second;
    q.pop();
    if (y >= n) {
      flag = 1;
      break;
    }
    if (vis[x][y] || de > y) continue;
    vis[x][y] = 1;
    if (y - 1 >= 0 && c[x][y - 1] != 'X' && y - 1 >= de + 1 && !vis[x][y - 1]) {
      q.push(make_pair(x, make_pair(y - 1, de + 1)));
    }
    if (y + 1 >= n || (c[x][y + 1] != 'X' && !vis[x][y + 1])) {
      q.push(make_pair(x, make_pair(y + 1, de + 1)));
    }
    if (y + k >= n || (c[x ^ 1][y + k] != 'X' && !vis[x ^ 1][y + k])) {
      q.push(make_pair(x ^ 1, make_pair(y + k, de + 1)));
    }
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
}
