#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct group {
	int id;
	int num;
	int time;
};

int cansit(const vector<int>&seats, int num) {
	for (int i = 0; i < 17 - num; ++i) {
		bool ok = true;
		for (int j = i; j < i + num; ++j) {
			if (seats[j] != -1) {
				ok = false;
			}
		}
		if (ok)return i;
	}
	return -1;
}
void dosit(vector<int>&seats, int num, int place,int leavetime) {
	for (int i = place; i < place + num; ++i) {
		seats[i] = leavetime;
	}
}

int main() {
	int N;
	while (cin >> N) {
		queue<group>waiting;
		vector<int>seats(17,-1);
		vector<int>anss(100);
		for (int t = 0; (t<=1000||!waiting.empty()); ++t) {
			for (int i = 0; i < 17; ++i) {
				if (t == seats[i])seats[i] = -1;
			}
			if (!(t % 5)) {
				const int id = t / 5;
				if (id < 100) {

					const int num = id % 5 == 1 ? 5 : 2;
					const int time = 17 * (id % 2) + 3 * (id % 3) + 19;
					waiting.push(group{ id,num,time });
				}
			}
			while (!waiting.empty()) {
				group atop(waiting.front());
				int place = cansit(seats, atop.num);
				if (place != -1) {
					dosit(seats, atop.num, place,atop.time+t);
					anss[atop.id] = t - atop.id * 5;
					waiting.pop();
				}
				else {
					break;
				}
			}
		}

		cout << anss[N] << endl;
	}
	return 0;
}