#include <bits/stdc++.h>
using namespace std;
vector<string> grid;
int n, k;
vector<vector<int> > dists;
class state {
 public:
  int ghor;
  int which;
  int tym;
};
bool ok(state x) {
  if (x.ghor < 0) return false;
  if (grid[x.which][x.ghor] == 'X') {
    return false;
  }
  if (x.tym >= x.ghor) {
    return false;
  }
  if (dists[x.which][x.ghor] <= x.tym) {
    return false;
  }
  dists[x.which][x.ghor] = x.tym;
  return true;
}
bool out(state x) {
  if (x.ghor >= grid[0].size()) return true;
  return false;
}
string solve() {
  dists = vector<vector<int> >(2, vector<int>(grid[0].size(), 1023456789));
  dists[0][0] = 0;
  state start;
  start.ghor = 0;
  start.which = 0;
  start.tym = -1;
  queue<state> q;
  q.push(start);
  while (!q.empty()) {
    state cur = q.front();
    q.pop();
    state low;
    state high;
    state other;
    low.ghor = cur.ghor - 1;
    low.which = cur.which;
    low.tym = cur.tym + 1;
    high.ghor = cur.ghor + 1;
    high.which = cur.which;
    high.tym = cur.tym + 1;
    other.ghor = cur.ghor + k;
    other.which = (cur.which + 1) % 2;
    other.tym = cur.tym + 1;
    if (out(high) || out(other)) return "YES";
    if (ok(low)) {
      q.push(low);
    }
    if (ok(high)) {
      q.push(high);
    }
    if (ok(other)) {
      q.push(other);
    }
  }
  return "NO";
}
int main() {
  cin >> n >> k;
  string left = "";
  string right = "";
  cin >> left >> right;
  grid.push_back(left);
  grid.push_back(right);
  string res = solve();
  cout << res << endl;
  return 0;
}
