#include <bits/stdc++.h>
using namespace std;
void solve() {
  vector<char> x(4);
  vector<char> y(4);
  cin >> x[0] >> x[1] >> x[2] >> x[3];
  cin >> y[0] >> y[1] >> y[2] >> y[3];
  vector<char> xc;
  vector<char> yc;
  for (int i : {0, 1, 3, 2}) {
    if (x[i] != 'X') {
      xc.push_back(x[i]);
    }
    if (y[i] != 'X') {
      yc.push_back(y[i]);
    }
  }
  if (xc[0] == yc[0] && xc[1] == yc[1] && xc[2] == yc[2]) {
    cout << "YES";
    return;
  }
  if (xc[0] == yc[1] && xc[1] == yc[2] && xc[2] == yc[0]) {
    cout << "YES";
    return;
  }
  if (xc[0] == yc[2] && xc[1] == yc[0] && xc[2] == yc[1]) {
    cout << "YES";
    return;
  }
  cout << "NO";
  return;
}
int main() {
  solve();
  int n;
  return 0;
}
