#include <bits/stdc++.h>
using namespace std;
queue<int> q;
int n, k, d[5][100005];
string c[2];
inline bool ok(int t, int x, int y) { return (c[y][x] == '-' && x > t); }
int main() {
  cin >> n >> k;
  cin >> c[0] >> c[1];
  q.push(0);
  q.push(0);
  q.push(-1);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    int y = q.front();
    q.pop();
    if (d[y][x] != 0) {
      q.pop();
      continue;
    }
    d[y][x] = 1;
    if (x + k >= n) {
      cout << "YES";
      return 0;
    }
    q.front()++;
    if (ok(q.front(), x + k, abs(y - 1)))
      q.push(x + k), q.push(abs(y - 1)), q.push(q.front());
    if (ok(q.front(), x - 1, y)) q.push(x - 1), q.push(y), q.push(q.front());
    if (ok(q.front(), x + 1, y)) q.push(x + 1), q.push(y), q.push(q.front());
    q.pop();
  }
  cout << "NO";
  return 0;
}
