#include <bits/stdc++.h>
using namespace std;
enum actions { JUMP1, UP1, DOWN1, JUMP2, UP2, DOWN2, NONE };
int n, x;
vector<vector<int> > v(6);
bool wut(int state, int i, actions last, int water) {
  if (water - 1 >= i) return false;
  if (state == 1) {
    if (n < 50000) {
      if (v[JUMP1][i] == 1) {
        bool isTrue = wut(2, i + x, JUMP1, water + 1);
        if (isTrue == false)
          v[JUMP1][i] = 0;
        else
          return true;
      } else if (v[JUMP1][i] == 2)
        return true;
    }
    if (v[UP1][i] == 1 && last != DOWN1) {
      bool isTrue = wut(state, i + 1, UP1, water + 1);
      if (isTrue == false)
        v[UP1][i] = 0;
      else
        return true;
    } else if (v[UP1][i] == 2)
      return true;
    if (v[DOWN1][i] == 1 && last != UP1) {
      bool isTrue = wut(state, i - 1, DOWN1, water + 1);
      if (isTrue == false)
        v[DOWN1][i] = 0;
      else
        return true;
    }
    if (n >= 50000) {
      if (v[JUMP1][i] == 1) {
        bool isTrue = wut(2, i + x, JUMP1, water + 1);
        if (isTrue == false)
          v[JUMP1][i] = 0;
        else
          return true;
      } else if (v[JUMP1][i] == 2)
        return true;
    }
  } else {
    if (n < 50000) {
      if (v[JUMP2][i] == 1) {
        bool isTrue = wut(1, i + x, JUMP2, water + 1);
        if (isTrue == false)
          v[JUMP2][i] = 0;
        else
          return true;
      } else if (v[JUMP2][i] == 2)
        return true;
    }
    if (v[UP2][i] == 1 && last != DOWN2) {
      bool isTrue = wut(state, i + 1, UP2, water + 1);
      if (isTrue == false)
        v[UP2][i] = 0;
      else
        return true;
    } else if (v[UP2][i] == 2)
      return true;
    if (v[DOWN2][i] == 1 && last != UP2) {
      bool isTrue = wut(state, i - 1, DOWN2, water + 1);
      if (isTrue == false)
        v[DOWN2][i] = 0;
      else
        return true;
    }
    if (n >= 50000) {
      if (v[JUMP2][i] == 1) {
        bool isTrue = wut(1, i + x, JUMP2, water + 1);
        if (isTrue == false)
          v[JUMP2][i] = 0;
        else
          return true;
      } else if (v[JUMP2][i] == 2)
        return true;
    }
  }
  return false;
}
int main() {
  cin >> n >> x;
  string first;
  string second;
  cin >> first;
  cin >> second;
  for (int i = 0; i < 6; i++) v[i].assign(n, 0);
  for (int i = 0; i < first.size(); i++) {
    if (first[i] != 'X') {
      if (i != first.size() - 1 && first[i + 1] != 'X') v[UP1][i] = 1;
      if (i > 0 && first[i - 1] != 'X') v[DOWN1][i] = 1;
      if (i + x < first.size() && second[i + x] != 'X') v[JUMP1][i] = 1;
      if (i == first.size() - 1) v[UP1][i] = 2;
      if (i + x >= first.size()) v[JUMP1][i] = 2;
    }
    if (second[i] != 'X') {
      if (i != second.size() - 1 && second[i + 1] != 'X') v[UP2][i] = 1;
      if (i > 0 && second[i - 1] != 'X') v[DOWN2][i] = 1;
      if (i + x < second.size() && first[i + x] != 'X') v[JUMP2][i] = 1;
      if (i == second.size() - 1) v[UP2][i] = 2;
      if (i + x >= second.size()) v[JUMP2][i] = 2;
    }
  }
  if (wut(1, 0, NONE, 0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
