#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

void leave(vector<int> &v, const vector<int> &leavers){
    for(auto name:leavers){
        rep(i,v.size()){
            if(v[i]==name){
                v[i] = -1;
            }
        }
    }
}

int IsThereSpace(const vector<int> &v, int num){
    assert(num<=v.size());
    rep(i,v.size()-num+1){
        bool space = true;
        for(int j=i;j<i+num;j++){
            if(v[j]!=-1){
                space = false;
            }
        }
        if(space) return i;
    }
    return -1;
}

int processing_que(vector<int> &v, queue<pii> &que){
    if(que.empty())return -1;
    int name, num;
    tie(name,num) = que.front();

    int res = IsThereSpace(v, num);
    if( res!=-1 ){
        for(int i=res;i<res+num;i++){
            assert(v[i]==-1);
            v[i] = name;
        }
        que.pop();
        return name;
    }else{
        return -1;
    }
}

int main(){
    int n;
    while(cin>>n){
        vector<int> eating_times(101,INF);
        vector<int> v(17,-1);
        queue<pii> que;
        map<int,vector<int>> mp;
        for(int t=0; t<=4200; t++){
            if(mp.count(t)!=0){
                leave(v, mp[t]);
                mp[t] = vector<int>();
            }
            if(t%5==0){
                int name = t/5;
                if(name>99)continue;
                int num;
                if(name%5==1)num = 5;
                else num = 2;

                int eating_time = 17*(name % 2) + 3*(name % 3) + 19;
                eating_times[name] = eating_time;
                que.push(pii(name, num));
            }
            bool n_entered = false;
            while(1){
                int res = processing_que(v, que);
                if(res==-1)break;
                else{
                    assert(eating_times[res]!=INF);
                    mp[t+eating_times[res]].pb(res);
                    if(res==n) n_entered = true;
                }
            }

            if(n_entered){
                cout<<t-n*5<<endl;
                break;
            }
            if(t==4200) assert(false);
        }
    }
}

