#include <bits/stdc++.h>
using namespace std;
int vis[43];
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < (n); i++) {
    int x;
    cin >> x;
    if (x == 4) vis[4]++;
    if (x == 8 && vis[4] > vis[8]) vis[8]++;
    if (x == 15 && vis[8] > vis[15]) vis[15]++;
    if (x == 16 && vis[15] > vis[16]) vis[16]++;
    if (x == 23 && vis[16] > vis[23]) vis[23]++;
    if (x == 42 && vis[23] > vis[42]) vis[42]++;
  }
  if (vis[4] == 0 || vis[15] == 0 || vis[16] == 0 || vis[8] == 0 ||
      vis[23] == 0 || vis[42] == 0) {
    cout << n << endl;
    return 0;
  }
  cout << n - (6 * vis[42]);
  cout << endl;
  return 0;
}
