#include <bits/stdc++.h>
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
template <class T>
T minimize(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T maximize(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long mod = 1e9 + 7, oo = 1e12, N = 2e5 + 5;
using namespace std;
long long n, k;
char str[2][N];
bool color[2][N], flag = false;
void dfs(long long x, long long y, long long water) {
  if (y < water || str[x][y] == 'X' || color[x][y] == true || flag == true)
    return;
  if (y >= n) {
    flag = true;
    return;
  }
  color[x][y] = true;
  dfs((x + 1) % 2, y + k, water + 1);
  dfs(x, y + 1, water + 1);
  dfs(x, y - 1, water + 1);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> k >> str[0] >> str[1];
  dfs(0, 0, 0);
  flag == true ? cout << "YES\n" : cout << "NO\n";
  return 0;
}
