#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <queue>
#include <iomanip>
using namespace std;

int seat[17], countdown[17];
int arrival[100], sit[100];

int main() {
    memset(seat, -1, sizeof seat);
    memset(countdown, 0, sizeof countdown);
    queue<int> q;
    for (int m=0; m<1000; ++m) {
        if (m%5 == 0 && m/5 < 100) {
            q.push(m/5);
            arrival[m/5] = m;
        }
        for (int i=0; i<17; ++i) {
            if (countdown[i]) {
                --countdown[i];
                if (countdown[i] == 0) {
                    seat[i] = -1;
                }
            }
        }
        while ( ! q.empty()) {
            bool change = false;
            int num = (q.front()%5 == 1 ? 5 : 2);
            int time = 17*(q.front()%2) + 3*(q.front()%3) + 19;
            for (int i=0; i+num-1<17; ++i) {
                bool ok = true;
                for (int j=i; j<=i+num-1; ++j) {
                    if (0 <= seat[j]) ok = false;
                }
                if (ok) {
                    change = true;
                    for (int j=i; j<=i+num-1; ++j) {
                        seat[j] = q.front();
                        countdown[j] = time;
                    }
                    sit[q.front()] = m;
                    q.pop();
                    break;
                }
            }
            if ( ! change) break;
        }
    }
    int n;
    while (cin >> n) {
        cout << sit[n] - arrival[n] << endl;
    }
    return 0;
}