#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int wtime[100] ={};
  deque<int> deq;  
  int seat[17]={};
  int members[17];
  for(int t = 0; t <= 99*5 || !deq.empty(); t++){
    REP(i,17)if(seat[i] > 0)seat[i]--;
    if(t%5 == 0 && t <= 99*5) deq.push_back(t/5);
    while(!deq.empty()){
      int mem = deq.front();
      int nop = (mem%5==1)?5:2;
      int sitable = -1;
      for(int i = 0, con = 0; i < 17; i++){
        if(seat[i]==0)con++;
        else con = 0;
        if(con == nop){
          sitable = i + 1 - nop;
          break;
        }
      }
      if(sitable >= 0){
        deq.pop_front();
        REP(i,nop){
          seat[sitable+i] = 17*(mem%2)+3*(mem%3)+19;
          members[sitable+i] = mem;
        }
      }else{
        break;
      }
    }
    REP(i,deq.size())wtime[deq[i]]++;
    /*
    printf("%d:",t);
    REP(i,17)cout<< ((seat[i])?members[i]:0) <<" ";
    cout<<endl;
    */
  }
  int n;
  while(cin>>n)cout<<wtime[n]<<endl;
  return 0;
}