#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[209], b[209], e[209], ret[209];
int main() {
	for (int i = 0; i < 200; i++) {
		a[i] = (i % 5 == 1 ? 5 : 2);
		b[i] = 17 * (i % 2) + 3 * (i % 3) + 19;
	}
	int h = 0;
	fill(e, e + 200, -1);
	vector<int> s(17, -1);
	for (int i = 0; i < 1000; i++) {
		for (int j = 0; j < h; j++) {
			if (e[j] + b[j] == i) {
				for (int k = 0; k < 17; k++) {
					if (s[k] == j) s[k] = -1;
				}
			}
		}
		while (h <= i / 5) {
			bool ok = false;
			for (int k = 0; k <= 17 - a[h]; k++) {
				bool flag = true;
				for (int l = k; l < k + a[h]; l++) {
					if (s[l] != -1) flag = false;
				}
				if (flag) {
					fill(s.begin() + k, s.begin() + k + a[h], h);
					ret[h] = i - h * 5;
					e[h++] = i;
					ok = true;
					break;
				}
			}
			if (!ok) break;
		}
	}
	while (cin >> n) cout << ret[n] << endl;
	return 0;
}