#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int N = 100;
const int T = 17;

void check(int cnt[N], P c[T], queue<int> &q, int &l, int &t){
  REP(i, T){
    if(c[i].first == -1) continue;
    int n = c[i].first;
    if(c[i].second + (17 * (n % 2) + 3 * (n % 3) + 19) == t){
      l = max(l, c[i].first);
      c[i] = P(-1, -1);
    }
  }
  while(!q.empty()){
    int n = q.front();
    int m = (n % 5 == 1 ? 5 : 2);
    bool ff = false;
    REP(i, T - m){
      bool f = true;
      REP(j, m) if(c[i + j].first != -1) f = false;
      if(f){
        cnt[n] = t - n * 5;
        REP(j, m) c[i + j] = P(n, t);
        ff = true;
        q.pop();
        break;
      }
    }
    if(!ff) break;
  }
}

int main() {
  int cnt[N], l = -1, t = 0;
  P c[T];
  memset(cnt, 0, sizeof(cnt));
  REP(i, T) c[i] = P(-1, -1);
  queue<int> q;
  while(l < N){
    if(t % 5 == 0) q.push(t / 5);
    check(cnt, c, q, l, t);
    ++t;
  }
  int n;
  while(cin >>n) cout <<cnt[n] <<endl;
  return 0;
}