#include <bits/stdc++.h>
using namespace std;
template <class T1>
inline void debug(T1 _x) {
  cout << _x << '\n';
}
template <class T1, class T2>
inline void debug(T1 _x, T2 _y) {
  cout << _x << ' ' << _y << '\n';
}
template <class T1, class T2, class T3>
inline void debug(T1 _x, T2 _y, T3 _z) {
  cout << _x << ' ' << _y << ' ' << _z << '\n';
}
template <class T1, class T2, class T3, class T4>
inline void debug(T1 _x, T2 _y, T3 _z, T4 _zz) {
  cout << _x << ' ' << _y << ' ' << _z << ' ' << _zz << '\n';
}
template <class T1>
inline void debug(T1 _array, int _size) {
  cout << "[";
  for (int i = 0; i < _size; ++i) {
    cout << ' ' << _array[i];
  }
  puts(" ]");
}
inline bool CI(int &_x) { return scanf("%d", &_x) == 1; }
inline bool CI(int &_x, int &_y) { return CI(_x) && CI(_y); }
inline bool CI(int &_x, int &_y, int &_z) { return CI(_x) && CI(_y) && CI(_z); }
inline bool CI(int &_x, int &_y, int &_z, int &_zz) {
  return CI(_x) && CI(_y) && CI(_z) && CI(_zz);
}
inline void wait(double seconds) {
  double endtime = clock() + (seconds * CLOCKS_PER_SEC);
  while (clock() < endtime) {
    ;
  }
}
const int mxn = (int)1e5 + 20;
char grid[2][mxn];
int N, K;
inline void read() {
  scanf("%d %d\n", &N, &K);
  gets(grid[0]);
  gets(grid[1]);
}
int water[mxn];
int path[2][mxn];
int vis[2][mxn];
struct NODE {
  int at;
  int pos;
  int tim;
  NODE() {}
  NODE(int at_, int pos_, int tim_) {
    at = at_;
    pos = pos_;
    tim = tim_;
  }
};
inline bool possible(int at) {
  if (!path[at][1]) return false;
  memset(vis, 0, sizeof(vis));
  queue<NODE> q;
  q.push(NODE(at, 1, 0));
  vis[at][1] = 1;
  while (!q.empty()) {
    int cur_pile = q.front().at;
    int cur_pos = q.front().pos;
    int cur_tim = q.front().tim;
    q.pop();
    int nxt_pos = cur_pos + 1;
    int nxt_tim = cur_tim + 1;
    if (nxt_pos > N) return true;
    if (path[cur_pile][nxt_pos] && water[nxt_pos] > nxt_tim &&
        !vis[cur_pile][nxt_pos]) {
      vis[cur_pile][nxt_pos] = 1;
      q.push(NODE(cur_pile, nxt_pos, nxt_tim));
    }
    nxt_pos = cur_pos - 1;
    if (nxt_pos > N) return true;
    if (path[cur_pile][nxt_pos] && water[nxt_pos] > nxt_tim &&
        !vis[cur_pile][nxt_pos]) {
      vis[cur_pile][nxt_pos] = 1;
      q.push(NODE(cur_pile, nxt_pos, nxt_tim));
    }
    nxt_pos = cur_pos + K;
    if (nxt_pos > N) return true;
    if (path[cur_pile ^ 1][nxt_pos] && water[nxt_pos] > nxt_tim &&
        !vis[cur_pile ^ 1][nxt_pos]) {
      vis[cur_pile ^ 1][nxt_pos] = 1;
      q.push(NODE(cur_pile ^ 1, nxt_pos, nxt_tim));
    }
  }
  return false;
}
inline void proc() {
  memset(water, 0, sizeof(water));
  for (int i = 1, j1 = N + 1; i < j1; ++i) {
    water[i] = water[i - 1] + 1;
  }
  memset(path, -1, sizeof(path));
  path[0][0] = path[1][0] = 0;
  for (int i = 1, j1 = N + 1; i < j1; ++i) {
    if (grid[0][i - 1] == 'X') path[0][i] = 0;
    if (grid[1][i - 1] == 'X') path[1][i] = 0;
  }
  int f = possible(0);
  puts((f ? "YES" : "NO"));
}
int main() {
  int kase = 1;
  for (int i = 0, j1 = kase; i < j1; ++i) {
    read();
    proc();
  }
  return 0;
}
