#include <bits/stdc++.h>
using namespace std;
int main() {
  long long ar[24];
  for (long long i = 0; i < 24; i++) cin >> ar[i];
  long long c = 0;
  vector<vector<long long>> v;
  int p = 1;
  vector<long long> v2;
  for (long long i = 0; i < 24; i = i + 4) {
    if (ar[i] == ar[i + 1] and ar[i + 1] == ar[i + 2] and
        ar[i + 2] == ar[i + 3]) {
      c++;
      v2.push_back(p);
    } else {
      vector<long long> v1;
      v1.push_back(ar[i]);
      v1.push_back(ar[i + 1]);
      v1.push_back(ar[i + 2]);
      v1.push_back(ar[i + 3]);
      v.push_back(v1);
    }
    p++;
  }
  if (c != 2) {
    cout << "NO";
    return 0;
  } else if ((v2[0] == 1 and v2[1] == 3) or (v2[0] == 2 and v2[1] == 6) or
             (v2[0] == 4 and v2[1] == 5)) {
    vector<pair<long long, long long>> v3;
    for (int i = 0; i < 4; i++) {
      sort(v[i].begin(), v[i].end());
      if (v[i][0] != v[i][1] or v[i][2] != v[i][3]) {
        cout << "NO";
        return 0;
      }
      v3.push_back(make_pair(v[i][0], v[i][2]));
    }
    int k;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (i != j) {
          if (v3[i].first == v3[j].first and v3[i].second == v3[j].second) {
            cout << "NO";
            return 0;
          }
        }
      }
    }
    cout << "YES";
  } else
    cout << "NO";
  return 0;
}
