#include <bits/stdc++.h>
using namespace std;
long long int dp[50];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  map<long long int, long long int> mp;
  mp[4] = 1;
  mp[8] = 2;
  mp[15] = 3;
  mp[16] = 4;
  mp[23] = 5;
  mp[42] = 6;
  long long int n;
  cin >> n;
  long long int a[n + 1];
  for (long long int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] = mp[a[i]];
  }
  dp[0] = n;
  for (long long int i = 1; i <= n; ++i) {
    if (dp[a[i] - 1]) {
      dp[a[i]]++;
      dp[a[i] - 1]--;
    }
  }
  cout << n - dp[6] * 6 << "\n";
  return 0;
}
