#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
using ll = long long;
const int N = 24;
vector<int> cube(N);
bool check() {
  (void)0x30;
  for (int i = 0; i < N; i += 4) {
    int val = cube[i];
    for (int j = i; j < i + 4; j++) {
      if (val != cube[j]) return false;
    }
  }
  return true;
}
int rotations[8][8] = {
    {2, 3, 16, 18, 9, 8, 15, 13},   {0, 1, 17, 19, 11, 10, 14, 12},
    {1, 3, 5, 7, 9, 11, 22, 20},    {0, 2, 4, 6, 8, 10, 23, 21},
    {12, 13, 4, 5, 16, 17, 20, 21}, {14, 15, 6, 7, 18, 19, 22, 23}};
void rotate90(int rotation[8]) {
  vector<int> values;
  for (int i = 0; i < 8; i++) {
    values.push_back(cube[rotation[i]]);
  }
  std::rotate(values.begin(), values.begin() + 2, values.end());
  for (int i = 0; i < 8; i++) {
    cube[rotation[i]] = values[i];
  }
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  for (int i = 0; i < N; i++) {
    cin >> cube[i];
  }
  for (int i = 0; i < 6; i++) {
    for (int rep = 0; rep < 4; rep++) {
      rotate90(rotations[i]);
      if ((rep % 2 == 0) && check()) {
        cout << "YES\n";
        return 0;
      }
    }
    (void)0x30;
  }
  cout << "NO\n";
}
