#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
const int maxn = 300000 + 10;
const int INF = 1e9 + 7;
bool dp[maxn][2], visit[maxn][3];
string str[2];
int n, k;
int f = 0;
bool dfs(int pos, int idx, int t) {
  if (pos <= 0) return false;
  if (pos > n) {
    f = 1;
    cout << "YES";
    exit(!printf("\n"));
    return true;
  }
  if (t >= pos) return false;
  if (str[idx][pos - 1] == 'X') return false;
  if (dp[pos][idx]) return dp[pos][idx];
  bool t1 = dfs(pos + k, !idx, t + 1);
  bool t2 = dfs(pos + 1, idx, t + 1);
  bool t3 = dfs(pos - 1, idx, t + 1);
  if (t1 == false && t2 == false && t3 == false) {
    dp[pos][idx] = false;
    return false;
  }
  dp[pos][idx] = true;
  return true;
}
inline void solve(void) {
  cin >> n >> k;
  cin >> str[0] >> str[1];
  queue<pair<pair<int, int>, int> > v;
  v.push(pair<pair<int, int>, int>(pair<int, int>(1, 0), 0));
  while (!v.empty()) {
    pair<pair<int, int>, int> f = v.front();
    v.pop();
    int pos = f.first.first, idx = f.first.second, t = f.second;
    if (pos <= 0) continue;
    if (pos > n) {
      cout << "YES\n";
      return;
    }
    if (t >= pos || str[idx][pos - 1] == 'X') continue;
    if (dp[pos][idx]) continue;
    if (!visit[pos + k][!idx]) {
      v.push(pair<pair<int, int>, int>(pair<int, int>(pos + k, !idx), t + 1));
      visit[pos + k][!idx] = true;
    }
    if (!visit[pos + 1][idx]) {
      v.push(pair<pair<int, int>, int>(pair<int, int>(pos + 1, idx), t + 1));
      visit[pos + 1][idx] = true;
    }
    if (!visit[pos - 1][idx]) {
      v.push(pair<pair<int, int>, int>(pair<int, int>(pos - 1, idx), t + 1));
      visit[pos - 1][idx] = true;
    }
  }
  cout << "NO\n";
}
void init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
int main(int argc, const char *argv[]) {
  solve();
  return 0;
}
