#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

struct Chair{
	int group_id,rest_time;
};

struct Info{
	int group_id,num,wait_sum,before_go;
	bool fixed;
};


int main(){

	int ans[100];

	Chair chair[17];
	for(int i = 0; i < 17; i++)chair[i].group_id = -1;
	Info info[100];
	for(int i = 0; i <= 99; i++){
		info[i].group_id = i;
		info[i].before_go = 5*i;
		info[i].wait_sum = 0;
		if(i%5==1){
			info[i].num = 5;
		}else{
			info[i].num = 2;
		}
		info[i].fixed = false;
	}

	int count;
	int FLG,tmp_num;
	bool isOK,waitFLG;

	while(true){

		for(int i = 0; i < 17; i++){
			if(chair[i].group_id != -1){
				chair[i].rest_time--;
				if(chair[i].rest_time <= 0){
					chair[i].group_id = -1;
				}
			}
		}

		waitFLG = false;
		count = 0;
		for(int i = 0; i < 100; i++){
			if(info[i].fixed)continue;
			if(waitFLG == false &&info[i].before_go == 0){
				FLG = -1;
				tmp_num = info[i].num;

				for(int k = 0; k <= 17-tmp_num;k++){
					isOK = true;
					for(int p = 0; p < tmp_num; p++){
						if(chair[k+p].group_id != -1){
							isOK = false;
							break;
						}
					}
					if(isOK){
						FLG = k;
						break;
					}
				}
				if(FLG != -1){
					for(int k = FLG; k < FLG + tmp_num;k++){
						chair[k].group_id = info[i].group_id;
						chair[k].rest_time = 17*(i%2)+3*(i%3)+19;
						info[i].fixed = true;
					}
				}else{
					waitFLG = true;
					info[i].wait_sum++;
					count++;
				}
			}else{
				if(info[i].before_go == 0){
					info[i].wait_sum++;
				}else{
					info[i].before_go--;
				}
				count++;
			}
		}
		if(count == 0)break;
	}

	for(int i = 0; i <= 99; i++){
		ans[i] = info[i].wait_sum;
	}

	int N;

	while(scanf("%d",&N) != EOF){
		printf("%d\n",ans[N]);
	}

    return 0;
}