#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  int n;
  int x = q;
  int arr[6] = {};
  while (q--) {
    cin >> n;
    switch (n) {
      case 4:
        arr[0]++;
        break;
      case 8:
        if (arr[0] > arr[1]) arr[1]++;
        break;
      case 15:
        if (arr[2] < arr[1]) arr[2]++;
        break;
      case 16:
        if (arr[2] > arr[3]) arr[3]++;
        break;
      case 23:
        if (arr[3] > arr[4]) arr[4]++;
        break;
      case 42:
        if (arr[4] > arr[5]) arr[5]++;
        break;
      default:
        break;
    }
  }
  cout << x - (arr[5] * 6);
}
