#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, i, num;
  int answer = 0;
  int A[6] = {0};
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &num);
    if (num == 4)
      A[0]++;
    else if (num == 8 && A[0] > A[1])
      A[1]++;
    else if (num == 15 && A[1] > A[2])
      A[2]++;
    else if (num == 16 && A[2] > A[3])
      A[3]++;
    else if (num == 23 && A[3] > A[4])
      A[4]++;
    else if (num == 42 && A[4] > A[5])
      A[5]++;
  }
  sort(A, A + 6);
  answer = n - 6 * A[0];
  printf("%d", answer);
}
