#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  int a[n], cnt[6] = {0};
  map<int, int> m = {{4, 0}, {8, 1}, {15, 2}, {16, 3}, {23, 4}, {42, 5}};
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (m[a[i]] == 0)
      cnt[0]++;
    else {
      if (cnt[m[a[i]] - 1]) {
        cnt[m[a[i]] - 1]--;
        cnt[m[a[i]]]++;
      }
    }
  }
  cout << n - cnt[5] * 6 << endl;
}
