#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, i, j, k, q;
void solve() {
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long res[] = {4, 8, 15, 16, 23, 42};
  long long ans[6] = {0};
  long long x = 0;
  for (long long i = 0; i < n; i++) {
    long long j = 0;
    for (j = 0; j < 6; j++) {
      if (arr[i] == res[j]) {
        break;
      }
    }
    if (j > 0) {
      if (ans[j - 1] > ans[j]) {
        ans[j]++;
      }
    } else
      ans[j]++;
  }
  x = ans[5];
  cout << n - (x * 6);
}
signed main() {
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
