import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	// ??¢?????¶???
	String[] storeSeat = new String[17];
	// ??¢?????¶???????????????
	makeEmptyStore(storeSeat);

	// ???????????°??????????????????????????????????????????
	int[][] waitingTime = fillSeat(storeSeat);

	while (sc.hasNextLine()) {
	    String query = null;
	    query = sc.nextLine();
	    if ("???".equals(query) || query == null) {
		System.exit(0);
	    }

	    System.out.println(waitingTime[Integer.parseInt(query)][1] - waitingTime[Integer.parseInt(query)][0]);
	}
    }

    // ??¨??????????????????????????\??¢??¶???
    private static void makeEmptyStore(String[] storeSeat) {
	for (int i = 0; i < storeSeat.length; i++) {
	    storeSeat[i] = "_";
	}
    }

    private static int[][] fillSeat(String[] storeSeat) {

	// ????????°???????????????
	List<Integer> waitingGroups = new ArrayList<>();

	// ?????°????????????????????????
	int[][] waitingTime = new int[100][2];

	// ???????????¨?????¶??????????????¶??????????????????
	openStore: for (int now = 0;; now++) {

	    // ??°??????????????°????????????????????¶
	    if (now < 500 && now % 5 == 0) {
		waitingTime[now / 5][0] = now;
		waitInLine(waitingGroups, now / 5);
	    }

	    // ?£?????????????????????§????????????
	    for (int i = 0; i < storeSeat.length; i++) {

		if ("_".equals(storeSeat[i])) {
		    continue;
		}

		int groupId = Integer.parseInt(storeSeat[i]);

		// ?????????????????????
		int eatingTime = 17 * (groupId % 2) + 3 * (groupId % 3) + 19;

		if (eatingTime == now - waitingTime[groupId][1]) {
		    storeSeat[i] = "_";
		}
	    }

	    // ??????????????£????????§???
	    int empty = 0;
	    // ??????????????????0??????????????§???????????????
	    cont: while (waitingGroups.size() != 0) {
		// ??°?????????????????°??????
		int members = membersOfGroup(waitingGroups.get(0));
		for (int i = 0; i < storeSeat.length - 1; i++) {
		    for (int j = 0; j < members; j++) {
			// ???????????????????????????????????¬??????
			if (j + i >= 17) {
			    empty = 0;
			    break;
			}
			// ???????????????????????????????????°??£?¶??????????????????§????????´???
			if ("_".equals(storeSeat[i + j])) {
			    empty++;
			} else {
			    empty = 0;
			    break;
			}
			if (empty == membersOfGroup(waitingGroups.get(0))) {
			    empty = 0;
			    int groupId = waitingGroups.get(0);

			    sit(waitingGroups, waitingTime, now, storeSeat, i);

			    // ???????????§??¢?????§??£??????????????????
			    if (groupId == 99) {
				break openStore;
			    }

			    continue cont;
			}

		    }
		}
		// ???????????°??????????????§???????????£????????????
		break;
	    }
	}

	return waitingTime;
    }

    // ????????°????????????
    private static int membersOfGroup(int groupId) {

	if (isFiveGroup(groupId)) {
	    return 5;
	}
	return 2;
    }

    // ????????°?????????????????????
    private static boolean isFiveGroup(int groupId) {
	return groupId % 5 == 1;
    }

    // ????????????????????¶
    private static void waitInLine(List<Integer> waitingGroups, int groupId) {

	int number = membersOfGroup(groupId);

	for (; number > 0; number--) {
	    waitingGroups.add(groupId);
	}
    }

    // ?????????????????????????????\?????????
    private static void sit(List<Integer> waitingGroups, int[][] waitingTime, int now, String[] storeSeat, int seat) {
	int groupId = waitingGroups.get(0);
	int members = membersOfGroup(groupId);
	waitingTime[groupId][1] = now;

	for (int i = 0; i < members; i++) {
	    storeSeat[seat + i] = Integer.toString(groupId);

	    waitingGroups.remove(0);
	}
    }

    // ???????????????????????????????¢????
    private static boolean isAllSeatEmpty(String[] storeSeat) {

	for (String string : storeSeat) {
	    if (!"_".equals(string)) {
		return false;
	    }
	}

	return true;
    }
}

Measured memory_bytes: 27492