#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

int main(){

	int n;
	map<int,vector<int> > escape;

	int data[100];
	int field[17];
	fill(field,field+17,-1);

	queue<int> waitQueue;
	int group=0;
	int time=0;
	
	vector<int> c;
	while(cin>>n){
		c.push_back(n);
	}
	
	for(int i=0;;i++){
		time=i;
		if(i%5==0){
			waitQueue.push(group);
			group++;
		}
		// Ü¸ÔØêO[vðÈ©çÇ©·
		for(map<int,vector<int> >::iterator it = escape.begin(); it != escape.end(); it++){
			if(it->first==i){
				for(int j = 0; j < 17; j++){
					for(int k = 0; k< it->second.size(); k++){
						if(field[j]==it->second[k]){
							field[j]=-1;
							break;
						}
					}
				}
				it->second.clear();
				break;
			}
		}
		
		bool f=false;
		int prvCand=-1;
		// ·íêé¾¯·íç¹é
		while(1){
			if(waitQueue.size()==0)
				break;
			// ¡ñÀç¹él
			int cand=waitQueue.front();
			if(prvCand==cand)
				break;
			int s;
			int mergen=-1;
			for(int j = 0; j < 17; j++){
				if(field[j]==-1&&j!=16){
					if(mergen==-1){
						s=j;
						mergen=1;
					}
					else{
						mergen++;
					}
				}
				else{
					if(j==16){
						if(field[j]==-1){
							mergen++;
						}
					}

					if(cand%5==1){
						if(mergen>=5){
							// ·íç¹é
							for(int k = s; k < 5+s; k++){
								field[k]=cand;
							}
							//								cout<<cand<<endl;
							
							data[cand]=time-cand*5;
							waitQueue.pop();
							escape[17*(cand%2)+3*(cand%3)+19+i].push_back(cand);
							if(cand==99){
								f=true;
								break;
							}
							break;
						}
						else{
							mergen=-1;
						}
					}
					else{
						if(mergen>=2){
							// ·íç¹é
							for(int k = s; k < 2+s; k++){
								field[k]=cand;
							}
							data[cand]=time-cand*5;
							waitQueue.pop();
							escape[17*(cand%2)+3*(cand%3)+19+i].push_back(cand);
							if(cand==99){
								f=true;
								break;
							}
							break;
						}
						else
							mergen=-1;
					}
				}
				if(f)
					break;
			}
			if(f)
				break;
			prvCand=cand;
		}
		if(f)
			break;
		
	}
	for(int i = 0; i < c.size(); i++){
		// ±±ÅÜ¿Ôð\¦
		cout<<data[c[i]]<<endl;
	}
	//	}
	
	return 0;
}