#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-6;

struct group{
	int num;
	int eatTime;
	int idx;
};

void checkTable(int table[17],queue<group>& que,int time,map<int,int>& waitTime){
	for(int i=0;i<17;i++){
		table[i] -= table[i]>=1 ? 1 : 0;
	}

	for(int i=0;i<17;i++){
		for(int j=i;j<17;j++){
			if(table[j] > 0) break;
			if(que.empty()) goto end;

			if(j-i+1 == que.front().num && que.front().idx * 5 <= time){
				waitTime[que.front().idx] = abs(time - que.front().idx * 5);
				int num = que.front().num;
				int eat = que.front().eatTime;
				que.pop();
				for(int k=i;k<=j;k++){
					table[k] = eat;
				}
			}
		}
	}
end:;
}

int main(){
	int n;
	int table[17];
	memset(table,0,sizeof(table));
	queue<group> que;
	map<int,int> waitTime;

	for(int i=0;i<100;i++){
		int num = i % 5 == 1 ? 5 : 2;
		int eat = 17*(i%2)+3*(i%3)+19;
		group g;
		g.eatTime = eat;
		g.idx = i;
		g.num = num;
		que.push(g);		
	}

	for(int i=0;i<1000000;i++){
		checkTable(table,que,i,waitTime);
	}

	while(~scanf("%d",&n)){
		cout << waitTime[n] << endl;
	}
}