#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n)
	{
		vector<int> seat(17);
		queue<P> que;
		int time = 0;
		int num = 0;
		while (true)
		{
			if (time % 5 == 0)
			{
				que.push(P(num, time));
				++num;
			}
			for (int i = 0; i < 17; ++i)
			{
				if (seat[i] > 0)
				{
					--seat[i];
				}
			}
			bool update = true;
			while (!que.empty() && update)
			{
				update = false;
				if (que.front().first % 5 == 1)
				{
					for (int i = 0; i + 4 < 17; ++i)
					{
						if (seat[i] == 0 && seat[i + 1] == 0 && seat[i + 2] == 0 && seat[i + 3] == 0 && seat[i + 4] == 0)
						{
							seat[i] = seat[i + 1] = seat[i + 2] = seat[i + 3] = seat[i + 4] = 17 * (que.front().first % 2) + 3 * (que.front().first % 3) + 19;
							if (que.front().first == n)
							{
								cout << time - que.front().second << endl;
								goto END;
							}
							que.pop();
							update = true;
							break;
						}
					}
				}
				else
				{
					for (int i = 0; i + 1 < 17; ++i)
					{
						if (seat[i] == 0 && seat[i + 1] == 0)
						{
							seat[i] = seat[i + 1] = 17 * (que.front().first % 2) + 3 * (que.front().first % 3) + 19;
							if (que.front().first == n)
							{
								cout << time - que.front().second << endl;
								goto END;
							}
							que.pop();
							update = true;
							break;
						}
					}
				}
			}
			++time;
		}
	END:
		;
	}
}

int main()
{
	solve();
	return(0);
}