#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  long long int f[6];
  memset(f, 0, sizeof(f));
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    if (x == 4) f[0]++;
    if (x == 8 && f[0] > f[1]) f[1]++;
    if (x == 15 && f[1] > f[2]) f[2]++;
    if (x == 16 && f[2] > f[3]) f[3]++;
    if (x == 23 && f[3] > f[4]) f[4]++;
    if (x == 42 && f[4] > f[5]) f[5]++;
  }
  cout << n - (f[5] * 6) << "\n";
}
int main() { solve(); }
