#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const int INF = INT_MAX;

void solve( int n ) {
    int A[n+1], K[n+1], T[n+1];
    int BG[n+1];
    for ( int i = 0; i <= n; ++ i ) {
        A[i] = 5 * i;
    }
    for ( int i = 0; i <= n; ++ i ) {
        K[i] = ( i % 5 == 1 ) ? 5 : 2;
    }
    for ( int i = 0; i <= n; ++ i ) {
        T[i] = 17 * ( i % 2 ) + 3 * ( i % 3 ) + 19;
    }
    int U[17]; 
    fill( U, U+17, -1 );
    queue <int> Q;
    int cnt = 0;
    bool used[n+1];
    fill( used, used+n+1, false );
    for ( int t = 0; cnt <= n; ++ t ) {
        for ( int i = 0; i <= n; ++ i ) {
            if ( A[i] <= t ) {
                Q.push( i );
                A[i] = INF;
                BG[i] = t;
            }
        }
        for ( int i = 0; i < 17; ++ i ) {
            if ( U[i] == -1 ) continue;
            int id = U[i];
            if ( T[id] <= t ) {
                U[i] = -1;
                if ( ! used[id] ) {
                    cnt ++;
                    used[id] = true;
                }
            }
        }
        while ( ! Q.empty() ) {
            int id = Q.front();
            int k = K[id];
            bool flag2 = false;
            for ( int i = 0; i + k - 1 < 17; ++ i ) {
                bool flag = true;
                for ( int j = 0; j < k; ++ j ) {
                    if ( U[i+j] != -1 ) flag = false;
                }
                if ( flag ) {
                    for ( int j = 0; j < k; ++ j ) {
                        U[i+j] = id;
                    }
                    if ( n == id ) {
                        cout << t - BG[id] << endl;
                        return;
                    }
                    T[id] += t;
                    Q.pop();
                    flag2 = true;
                    break;
                }
            }
            if ( ! flag2 ) break;
        }
    }
    cout << endl;
}

int main() {
    int n;
    while ( cin >> n ) solve( n );
    return 0;
}