#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::tuple<int,int,int> T;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N;
int times[100];
int chairs[17];
std::priority_queue<T,std::vector<T>,std::greater<T>> queue1, queue2; // queue1: 入っている人, queue2: 待っている人

// (1) 入れる
// (2) 次の人が入るように追い出す

int position(const T& tuple){
    for(int i=0;i+std::get<1>(tuple)<=17;i++){
        bool can = true;
        REP(j, std::get<1>(tuple)){
            if(chairs[i+j] != -1){can = false; break;}
        }
        if(can){return i;}
    }
    return -1;
}

void enter(const T& tuple, const int& pos, const int& t){
    int index = std::get<2>(tuple);
    REP(i, std::get<1>(tuple)){
        chairs[pos+i] = index;
    }
    queue1.push(std::make_tuple(t+17*(index%2)+3*(index%3)+19, std::get<1>(tuple), index));
}

void leave(const T& tuple){
    REP(i, 17){
        if(chairs[i] == std::get<2>(tuple)){chairs[i] = -1;}
    }
}

void simulate(){
    std::fill(chairs, chairs+17, -1);

    REP(i, 100){
        queue2.push(std::make_tuple(5*i, i%5==1?5:2, i));
    }

    int t = 0;
    while(!queue2.empty()){
        while(!queue1.empty()){
            T tuple = queue1.top();
            if(std::get<0>(tuple) == t){
                // printf("Exit %d %d\n", std::get<2>(tuple), t);
                queue1.pop();
                leave(tuple);
            }else{break;}
        }

        while(!queue2.empty()){
            T tuple = queue2.top();
        
            int pos = position(tuple);
            if(pos != -1 && std::get<0>(tuple) <= t){
                // printf("Enter %d %d\n", std::get<2>(tuple), t);
                queue2.pop();
                enter(tuple, pos, t);
                times[std::get<2>(tuple)] = t - std::get<0>(tuple);
            }else{
                break;
            }
        }

        t += 1;
    }
}

int main(){
    simulate();
    
    while(std::cin >> N, !std::cin.eof()){
        std::cout << times[N] << std::endl;
    }
}