#include <bits/stdc++.h>
using namespace std;
const int maxn = int(1.5 * 1e7);
const int inf = ~0U >> 1;
const long long ll_inf = 1e18 + 420;
const double eps = 1e-4;
const int N = 1e6 + 7;
const int MAX = 2e5 + 9;
const int MOD = 1e9 + 7;
const long double pi = 3.14159265359;
int n, k;
bool a[10][N];
string s[10];
void rec(int v, int u, int pos) {
  if (s[v][u] == 'X' || u < pos || a[v][u]) {
    return;
  }
  if (u + k > n) {
    cout << "YES";
    exit(0);
  }
  a[v][u] = 1;
  rec((v + 1) % 2, u + k, pos + 1);
  rec(v, u + 1, pos + 1);
  rec(v, u - 1, pos + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  cin >> s[0] >> s[1];
  rec(0, 0, 0);
  cout << "NO";
}
