#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int vis[2][maxn], h[2][maxn];
int main() {
  int n, k, hw = -1;
  string s[2];
  cin >> n >> k >> s[0] >> s[1];
  int dx[4] = {1, -1, k, k}, dy[4] = {0, 0, -1, 1};
  vis[0][0] = 1;
  queue<pair<int, int> > q;
  q.push(make_pair(0, 0));
  memset(h, -1, sizeof(h));
  if (s[0][0] == 'X') {
    cout << "NO";
    return 0;
  }
  while (!q.empty()) {
    pair<int, int> x = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int nx = x.first + dx[i], ny = x.second + dy[i];
      if (nx > -1 && nx < n && ny > -1 && ny < 2 && vis[ny][nx] == 0 &&
          s[ny][nx] == '-' && x.first > h[x.second][x.first]) {
        q.push(make_pair(nx, ny));
        vis[ny][nx] = 1;
        h[ny][nx] = h[x.second][x.first] + 1;
      }
      if (nx >= n) {
        cout << "YES";
        return 0;
      }
    }
    hw++;
  }
  cout << "NO";
}
