#include <bits/stdc++.h>
using namespace std;
template <class T>
T power(T a, T b) {
  T x;
  if (b == 0)
    x = 1;
  else
    x = a;
  for (size_t i = 1; i < b; i++) x *= a;
  return x;
}
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int n, m, a, b, c, ab, ba, x, y, z, avg, sum;
long long int arr2[100000], arr3[200000], arr4[200001], arr5[100001];
bool f, f1, f2;
string str, s1, s2, s3, s4;
set<int> seto;
double d, d1;
long long int x1, x2, y11, y2;
long long int mini = 100000000000000, maxi = 0;
map<char, long long int> mp;
vector<int> v, v1;
bool dp[100000][2];
void solve(long long int a = 0, long long int b = 0, bool wall = 0) {
  int i = a;
  int x = b;
  if (i >= 0 && i < n) {
    if (!wall) {
      if (s1[i] == 'X' || x > i) return;
      if (!dp[i][0]) {
        dp[i][0] = 1;
        solve(i - 1, x + 1, 0);
        solve(i + m, x + 1, 1);
        solve(i + 1, x + 1, 0);
      }
    } else {
      if (s2[i] == 'X' || x > i) return;
      if (!dp[i][1]) {
        dp[i][1] = 1;
        solve(i - 1, x + 1, 1);
        solve(i + m, x + 1, 0);
        solve(i + 1, x + 1, 1);
      }
    }
  }
  if (i >= n) {
    cout << "YES";
    exit(0);
  }
}
int main() {
  cin >> n >> m;
  cin >> s1 >> s2;
  solve();
  cout << "NO";
}
