#include <bits/stdc++.h>
using namespace std;
int main() {
  queue<pair<int, int> > que;
  int n, k;
  vector<string> cnt;
  cin >> n >> k;
  int mp[2][100000];
  int dx[4] = {0, 0, -1, 1};
  int dy[4] = {1, -1, k, k};
  for (int i = 0; i < 2; i++) {
    string a;
    cin >> a;
    cnt.push_back(a);
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 100000; j++) {
      mp[i][j] = 10000000;
    }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < cnt[0].size(); j++) {
      if (cnt[i][j] == 'X') mp[i][j] = 100000000;
    }
  }
  int sx = 0, sy = 0;
  mp[sx][sy] = 0;
  que.push(pair<int, int>(sx, sy));
  while (!que.empty()) {
    pair<int, int> p = que.front();
    que.pop();
    int water = mp[p.first][p.second];
    if (water > p.second) {
      continue;
    }
    if (p.second + k >= n) {
      cout << "YES" << endl;
      return 0;
    }
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (((ny >= n) && (nx >= 0) && (nx < 2)) ||
          (nx >= 0 && nx < 2 && ny >= 0 && ny < n && mp[nx][ny] == 10000000)) {
        mp[nx][ny] = mp[p.first][p.second] + 1;
        que.push(pair<int, int>(nx, ny));
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
