#include <bits/stdc++.h>
using namespace std;
bool BFS(vector<vector<char>>& walls, long long n, long long k) {
  queue<pair<long long, long long>> q;
  q.push({0, 0});
  vector<vector<long long>> water(2, vector<long long>(n + 1, 1000000007));
  water[0][0] = 0;
  while (!q.empty()) {
    long long zone = q.front().first;
    long long wall = q.front().second;
    q.pop();
    if (zone == n) return true;
    if (zone > 0 && water[wall][zone] < zone - 1 &&
        water[wall][zone - 1] == 1000000007 && walls[wall][zone - 1] != 'X') {
      water[wall][zone - 1] = water[wall][zone] + 1;
      q.push({zone - 1, wall});
    }
    if (zone + 1 <= n && walls[wall][zone + 1] != 'X' &&
        water[wall][zone + 1] == 1000000007) {
      water[wall][zone + 1] = water[wall][zone] + 1;
      q.push({zone + 1, wall});
    }
    if (zone + k < n && walls[(wall + 1) % 2][zone + k] != 'X' &&
        water[(wall + 1) % 2][zone + k] == 1000000007) {
      water[(wall + 1) % 2][zone + k] = water[wall][zone] + 1;
      q.push({zone + k, (wall + 1) % 2});
    }
    if (zone + k >= n) {
      return true;
    }
  }
  if (water[0][n] != 1000000007 || water[1][n] != 1000000007) return true;
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<vector<char>> walls(2, vector<char>(n));
  vector<char> wall2(n);
  for (long long i = 0; i < n; i++) {
    cin >> walls[0][i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> walls[1][i];
  }
  bool ans = BFS(walls, n, k);
  if (ans)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
  return 0;
}
