#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, x;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    if (x == 4) a++;
    if (x == 8 && a > b) b++;
    if (x == 15 && b > c) c++;
    if (x == 16 && c > d) d++;
    if (x == 23 && d > e) e++;
    if (x == 42 && e > f) f++;
  }
  cout << (n - 6 * f) << "\n";
  return 0;
}
