#include <iostream>
#include <cstring>
using namespace std;

int waitTime[ 100 ];
const int NUM_SEATS = 17;

int isVacancy( int* seats, int n )
{
	int empties = 0;
	for( int i = 0; i < NUM_SEATS; ++i ){
		if( seats[ i ] <= 0 ){
			++empties;
			if( empties == n ){
				return i - n + 1;
			}
		}else{
			empties = 0;
		}
	}
	return -1;
}

void pass( int* seats, int* time )
{
	++*time;
	for( int i = 0; i < NUM_SEATS; ++i ){
		--seats[ i ];
	}
}

int main()
{
	int seats[ NUM_SEATS ];
	memset( seats, 0, sizeof(seats) );
	int time = 0;
	for( int i = 0; i < 100; ++i ){
		while( time < i * 5 ){
			pass( seats, &time );
		}
		int numPeople = i % 5 == 1 ? 5 : 2;
		int eatingTime = 17 * ( i % 2 ) + 3 * ( i % 3 ) + 19;
		int emptySeat = 0;
		while( ( emptySeat = isVacancy( seats, numPeople ) ) == -1 ){
			pass( seats, &time );
		}
		for( int j = emptySeat; j < numPeople + emptySeat; ++j ){
			seats[ j ] = eatingTime;
		}
		waitTime[ i ] = time - i * 5;
	}

	int input;
	while( cin >> input ){
		cout << waitTime[ input ] << endl;
	}


	return 0;
}