#include <bits/stdc++.h>
using namespace std;
int n, k, x, y, a[2][100100], water;
string s;
bool vis[2][100100];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < 2; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == 'X') a[i][j] = 1;
    }
  }
  queue<pair<pair<int, int>, int> > q;
  q.push(make_pair(make_pair(0, 0), -1));
  vis[0][0] = 1;
  while (!q.empty()) {
    y = q.front().first.first;
    x = q.front().first.second;
    water = q.front().second;
    q.pop();
    if (x + 1 == n || x + k >= n) {
      cout << "YES" << endl;
      return 0;
    }
    if (x > 0 && a[y][x - 1] == 0 && water + 1 < x - 1 && !vis[y][x - 1]) {
      q.push(make_pair(make_pair(y, x - 1), water + 1));
      vis[y][x - 1] = 1;
    }
    if (a[y][x + 1] == 0 && !vis[y][x + 1]) {
      q.push(make_pair(make_pair(y, x + 1), water + 1));
      vis[y][x + 1] = 1;
    }
    if (a[1 - y][x + k] == 0 && !vis[1 - y][x + k]) {
      q.push(make_pair(make_pair(1 - y, x + k), water + 1));
      vis[1 - y][x + k] = 1;
    }
  }
  cout << "NO" << endl;
  return 0;
}
