#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
bool visited[2][maxn];
int d[2][maxn];
string s[2];
int main() {
  int n, k;
  cin >> n >> k;
  cin >> s[0] >> s[1];
  int dx[3] = {0, 0, 1};
  int dy[3] = {1, -1, k};
  queue<pair<bool, int>> q;
  q.push(make_pair(0, 0));
  visited[0][0] = 1;
  while (q.size()) {
    pair<bool, int> k = q.front();
    q.pop();
    bool x = k.first;
    int y = k.second;
    for (int i = 0; i < 3; i++) {
      bool xx = x ^ dx[i];
      int yy = y + dy[i];
      if (yy >= n) {
        cout << "YES" << endl;
        exit(0);
      }
      if (yy >= 0 && s[xx][yy] == '-' && !visited[xx][yy] && yy > d[x][y]) {
        q.push(make_pair(xx, yy));
        visited[xx][yy] = 1;
        d[xx][yy] = d[x][y] + 1;
      }
    }
  }
  cout << "NO" << endl;
}
