#include <bits/stdc++.h>
using namespace std;
int a[50];
int checkFace(int i, int j, int k, int l) {
  if (a[i] == a[j] && a[j] == a[k] && a[k] == a[l])
    return 1;
  else
    return 0;
}
int checkOpp() {
  if (checkFace(1, 2, 3, 4) && checkFace(9, 10, 11, 12))
    return 1;
  else if (checkFace(13, 14, 15, 16) && checkFace(17, 18, 19, 20))
    return 2;
  else if (checkFace(5, 6, 7, 8) && checkFace(21, 22, 23, 24))
    return 3;
  else
    return 0;
}
int equal(int i, int j, int k, int l) {
  if (a[i] == a[j] && a[j] == a[k] && a[k] == a[l])
    return 1;
  else
    return 0;
}
int check2() {
  if (equal(1, 3, 6, 8) && equal(5, 7, 10, 12) && equal(9, 11, 21, 23) &&
      equal(2, 4, 22, 24))
    return 1;
  else if (equal(2, 4, 5, 7) && equal(6, 8, 9, 11) && equal(10, 12, 22, 24) &&
           equal(1, 3, 21, 23))
    return 1;
  else
    return 0;
}
int check1() {
  if (equal(13, 14, 7, 8) && equal(5, 6, 19, 20) && equal(17, 18, 23, 24) &&
      equal(21, 22, 15, 16))
    return 1;
  else if (equal(15, 16, 5, 6) && equal(7, 8, 17, 18) &&
           equal(19, 20, 21, 22) && equal(23, 24, 13, 14))
    return 1;
  else
    return 0;
}
int check3() {
  if (equal(1, 2, 17, 19) && equal(18, 20, 10, 9) && equal(12, 11, 16, 14) &&
      equal(15, 13, 3, 4))
    return 1;
  if (equal(3, 4, 18, 20) && equal(17, 19, 12, 11) && equal(10, 9, 15, 13) &&
      equal(16, 14, 1, 2))
    return 1;
  else
    return 0;
}
int main() {
  int temp;
  for (int i = 1; i <= 24; i++) scanf("%d", &a[i]);
  temp = checkOpp();
  if (temp == 0) {
    printf("NO\n");
    return 0;
  }
  int temp2;
  if (temp == 1)
    temp2 = check1();
  else if (temp == 2)
    temp2 = check2();
  else if (temp == 3)
    temp2 = check3();
  if (temp2 == 1)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
