#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const long long int INFLL = 1e18 + 10;
const long double EPS = 1e-8;
const long double EPSLD = 1e-14;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
const int MAX_N = 100010;
int n, k;
char ca[MAX_N], cb[MAX_N];
string s[2];
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    que;
int dist[2][MAX_N];
bool ok = false;
int nt, nh, nd;
int main() {
  scanf("%d %d", &n, &k);
  scanf("%s %s", ca, cb);
  s[0] = ca;
  s[1] = cb;
  for (int i = (0); i < (int)(2); i++)
    for (int j = (0); j < (int)(MAX_N); j++) dist[i][j] = INF;
  dist[0][0] = 0;
  que.push(pair<int, pair<int, int> >(0, pair<int, int>(0, 0)));
  while (!que.empty()) {
    int t = que.top().second.first;
    int h = que.top().second.second;
    int d = que.top().first;
    que.pop();
    if (d > dist[t][h]) continue;
    nt = t;
    nh = h + 1;
    nd = d + 1;
    if (nh >= nd && nh < n && s[nt][nh] == '-' && dist[nt][nh] > nd) {
      dist[nt][nh] = nd;
      que.push(pair<int, pair<int, int> >(nd, pair<int, int>(nt, nh)));
    }
    if (nh >= n) ok = true;
    nt = t;
    nh = h - 1;
    if (nh >= nd && nh < n && s[nt][nh] == '-' && dist[nt][nh] > nd) {
      dist[nt][nh] = nd;
      que.push(pair<int, pair<int, int> >(nd, pair<int, int>(nt, nh)));
    }
    if (nh >= n) ok = true;
    nt = 1 - t;
    nh = h + k;
    if (nh >= nd && nh < n && s[nt][nh] == '-' && dist[nt][nh] > nd) {
      dist[nt][nh] = nd;
      que.push(pair<int, pair<int, int> >(nd, pair<int, int>(nt, nh)));
    }
    if (nh >= n) ok = true;
  }
  if (ok)
    puts("YES");
  else
    puts("NO");
  return 0;
}
