#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:214721677")
using namespace std;
template <class T>
T sqr(T a) {
  return (a) * (a);
}
template <class T>
T abs(T a) {
  return (a < 0) ? -(a) : (a);
}
const double Pi = acos(-1.0);
const double eps = 1e-10;
const int INF = 1000 * 1000 * 1000 + 7;
const double phi = 0.5 + sqrt(1.25);
int main() {
  int n, k;
  string s[2];
  scanf("%d%d\n", &n, &k);
  getline(cin, s[0]);
  getline(cin, s[1]);
  vector<int> a[2];
  a[0].resize(n);
  a[1].resize(n);
  for (int i = 0, _n = (n)-1; i <= _n; ++i) {
    a[0][i] = INF;
    a[1][i] = INF;
  }
  a[0][0] = 0;
  deque<pair<int, int> > q;
  q.push_back(make_pair(0, 0));
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    if (a[x][y] > y && a[x][y] < INF) {
      q.pop_front();
      continue;
    }
    if (y + 1 >= n || y + k >= n) {
      printf("YES\n");
      return 0;
    }
    if (s[x][y + 1] == '-')
      if (a[x][y] + 1 < a[x][y + 1]) {
        a[x][y + 1] = a[x][y] + 1;
        q.push_back(make_pair(x, y + 1));
      }
    if (s[1 - x][y + k] == '-')
      if (a[x][y] + 1 < a[1 - x][y + k]) {
        a[1 - x][y + k] = a[x][y] + 1;
        q.push_back(make_pair(1 - x, y + k));
      }
    if (y - 1 >= 0 && s[x][y - 1] == '-')
      if (a[x][y] + 1 < a[x][y - 1]) {
        a[x][y - 1] = a[x][y] + 1;
        q.push_back(make_pair(x, y - 1));
      }
    q.pop_front();
  }
  printf("NO\n");
  return 0;
}
