#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;
int c[100][2], res[101], table[17];
int main(){
  rep(i, 100){
    if(i%5==1) c[i][0] = 5;
    else c[i][0] = 2;
    c[i][1] = 17 * (i%2) + 3 * (i%3) + 19;
  }
  rep(i, 17) table[i] = 0;
  int p = 0;
  rep(k, 1000){
    rep(i, 17) if(table[i] > 0) table[i]--;

    while(p <= k / 5){
      int tmp = p;
      if(c[p][0] == 2){
	rep(i, 16){
	  if(table[i]==0&&table[i+1]==0){
	    table[i] = table[i+1] = c[p][1];
	    res[p] = k- p * 5;
	    p++;
	    break;
	  }
	}
      }else if(c[p][0] == 5){
	rep(i, 13){
	  if(table[i]==0&&table[i+1]==0&&table[i+2]==0&&table[i+3]==0&&table[i+4]==0){
	    table[i]=table[i+1]=table[i+2]=table[i+3]=table[i+4]=c[p][1];
	    res[p] = k - p  *5;
	    p++;
	    break;
	  }
	}
      }
      if(tmp == p) break;
    }
  }
  
  int n;
  while(~scanf("%d", &n))
    printf("%d\n", res[n]);

  return 0;
}