#include <bits/stdc++.h>
using namespace std;
int a[25];
bool cmp(int u, int v, int w, int x) {
  if (a[u] == a[v] && a[v] == a[w] && a[v] == a[x]) return true;
  return false;
}
int main() {
  for (int i = 1; i <= 24; i++) scanf("%d", &a[i]);
  bool pos = false;
  if (cmp(1, 3, 6, 8) && cmp(5, 7, 10, 12),
      cmp(9, 11, 21, 23) && cmp(2, 4, 22, 24) && cmp(13, 14, 15, 16) &&
          cmp(17, 18, 19, 20))
    pos = true;
  else if (cmp(2, 4, 5, 7) && cmp(6, 8, 9, 11) && cmp(10, 12, 22, 24) &&
           cmp(1, 3, 21, 23) && cmp(13, 14, 15, 16) && cmp(17, 18, 19, 20))
    pos = true;
  else if (cmp(13, 14, 7, 8) && cmp(5, 6, 19, 20) && cmp(17, 18, 23, 24) &&
           cmp(21, 22, 15, 16) && cmp(1, 2, 3, 4) && cmp(9, 10, 11, 12))
    pos = true;
  else if (cmp(15, 16, 5, 6) && cmp(7, 8, 17, 18) && cmp(19, 20, 21, 22) &&
           cmp(23, 24, 13, 14) && cmp(1, 2, 3, 4) && cmp(9, 10, 11, 12))
    pos = true;
  else if (cmp(1, 2, 17, 19) && cmp(18, 20, 9, 10) && cmp(11, 12, 14, 16) &&
           cmp(13, 15, 3, 4) && cmp(5, 6, 7, 8) && cmp(21, 22, 23, 24))
    pos = true;
  else if (cmp(1, 2, 14, 16) && cmp(13, 15, 9, 10) && cmp(11, 12, 17, 19) &&
           cmp(18, 20, 3, 4) && cmp(5, 6, 7, 8) && cmp(21, 22, 23, 24))
    pos = true;
  if (pos)
    printf("YES\n");
  else
    printf("NO\n");
}
