#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  vector<int> a[1000];
  int seat[17], in[100], out[100];
  queue<int> Q;
  fill_n((int*)seat, 17, -1);
  for (int i = 0; i < 1000; i++) {
    if (i < 500 && i % 5 == 0) {
      Q.emplace(i / 5);
      in[i / 5] = i;
    }
    for (int j : a[i]) {
      for (int k = 0; k < 17; k++) {
        if (seat[k] == j) seat[k] = -1;
      }
    }
    while (!Q.empty()) {
      int num = Q.front() % 5 == 1 ? 5 : 2;
      int l = 0, r = 0, flag = 0;
      while (l < 17) {
        while (l < 17 && seat[l] != -1) l++, r++;
        while (r < 17 && seat[r] == -1) r++;
        if (r - l >= num) {
          int group = Q.front();
          Q.pop();
          out[group] = i;
          a[out[group] + 17 * (group % 2) + 3 * (group % 3) + 19].emplace_back(group);
          for (int j = 0; j < num; j++) {
            seat[j + l] = group;
          }
          flag = 1;
          break;
        }
        l = r;
      }
      if (!flag) break;
    }
  }
  int n;
  while (cin >> n) {
    cout << out[n] - in[n] << endl;
  }

  return 0;
}
