#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, ans = 0, x;
  cin >> n;
  vector<int> A;
  for (i = 0; i < n; i++) {
    cin >> x;
    A.push_back(x);
  }
  int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
  for (i = 0; i < n; i++) {
    if (A[i] == 4) {
      a++;
    }
    if (A[i] == 8 && a > b) {
      b++;
    }
    if (A[i] == 15 && b > c) {
      c++;
    }
    if (A[i] == 16 && c > d) {
      d++;
    }
    if (A[i] == 23 && d > e) {
      e++;
    }
    if (A[i] == 42 && e > f) {
      f++;
    }
  }
  cout << n - f * 6 << endl;
  return 0;
}
