#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
int n, t[24], o[24];
vector<vector<int> > cycles = {
    {1, 3, 5, 7, 9, 11, 24, 22},    {2, 4, 6, 8, 10, 12, 23, 21},
    {3, 4, 17, 19, 10, 9, 16, 14},  {1, 2, 18, 20, 12, 11, 15, 13},
    {13, 14, 5, 6, 17, 18, 21, 22}, {15, 16, 7, 8, 19, 20, 23, 24},
};
bool ok() {
  for (int i = 0; i < 6; i++) {
    bool kk = (t[4 * i] == t[4 * i + 1] && t[4 * i + 1] == t[4 * i + 2] &&
               t[4 * i + 2] == t[4 * i + 3]);
    if (!kk) return false;
  }
  return true;
}
bool move(vector<int> v, int p) {
  for (int i = 0; i < 24; i++) t[i] = o[i];
  for (int i = 0; i < 8; i++) t[v[i]] = o[v[(i + p) % 8]];
  return ok();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < 24; i++) {
    cin >> t[i];
    o[i] = t[i];
  }
  for (auto &x : cycles)
    for (auto &y : x) y--;
  bool ok = 0;
  for (auto &x : cycles) {
    ok |= move(x, 2);
    ok |= move(x, 6);
  }
  cout << (ok ? "YES" : "NO") << "\n";
  return 0;
}
