#include <bits/stdc++.h>
using namespace std;
int di[] = {1, 0, -1, 0};
int dj[] = {0, 1, 0, -1};
bool vis[500009][2];
struct state {
  int i, water;
  bool left;
  state() {}
  state(int _i, int _water, bool _left) : i(_i), water(_water), left(_left) {}
  bool operator<(const state& other) const { return water > other.water; }
};
int main() {
  int n, k;
  cin >> n >> k;
  string a, b;
  cin >> a >> b;
  priority_queue<state> Q;
  Q.push(state(0, 0, 1));
  while (!Q.empty()) {
    int i = Q.top().i;
    int water = Q.top().water;
    bool left = Q.top().left;
    Q.pop();
    if (vis[i][left]) continue;
    vis[i][left] = 1;
    if (i + 1 >= n || i + k >= n) return cout << "YES", 0;
    if (left) {
      if (a[i + 1] == '-' && !vis[i + 1][1]) Q.push(state(i + 1, water + 1, 1));
      if (b[i + k] == '-' && !vis[i + k][0]) Q.push(state(i + k, water + 1, 0));
      if (i - 1 >= 0 && a[i - 1] == '-' && i - 1 > water && !vis[i - 1][1])
        Q.push(state(i - 1, water + 1, 1));
    } else {
      if (b[i + 1] == '-' && !vis[i + 1][0]) Q.push(state(i + 1, water + 1, 0));
      if (a[i + k] == '-' && !vis[i + k][1]) Q.push(state(i + k, water + 1, 1));
      if (i - 1 >= 0 && b[i - 1] == '-' && i - 1 > water && !vis[i - 1][0])
        Q.push(state(i - 1, water + 1, 0));
    }
  }
  cout << "NO";
  return 0;
}
