#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef pair<int, int> pii;

int main() {
	int ans[100];
	vector<pii> seats; //group_num count
	seats.push_back(pii(-1, 17));
	priority_queue<pii, vector<pii>, greater<pii> > pq; //taisyutu:time, group_num
	queue<int> que; //mati:group_num
	
	
	int cnt = 0, t = 0;
	while (cnt < 100) {
		while (!pq.empty()) {
			pii now = pq.top();
			if (now.first != t) break;
			pq.pop();
			REP(i, seats.size()) if (seats[i].first == now.second) seats[i].first = -1;
		}
		REP(i, seats.size() - 1) {
			if (seats[i].first == seats[i + 1].first) {
				seats[i].second += seats[i + 1].second;
				seats.erase(seats.begin() + i + 1);
				i--;
			}
		}
		
		if (t % 5 == 0 && t / 5 < 100) que.push(t / 5);
		
		while (!que.empty()) {
			int now = que.front();
			int count = now % 5 == 1 ? 5 : 2;
			bool flag = true;
			REP(i, seats.size()) {
				if (seats[i].first == -1 && seats[i].second >= count) {
					if (seats[i].second - count > 0)
						seats.insert(seats.begin() + i + 1, pii(-1, seats[i].second - count));
					seats[i] = pii(now, count);
					pq.push(pii(t + 17*(now % 2) + 3*(now % 3) + 19, now));
					
					ans[now] = t - now * 5;
					cnt++;
					que.pop();
					flag = false;
					break;
				}
			}
			if (flag) break;
		}
		
		t++;
	}
	
	
	int n;
	while (cin >> n) cout << ans[n] << endl;
	return 0;
}