#include<stdio.h>
int main(void){
  long n,k,s;
  scanf("%ld",&n);
  k=(n-n%15)/15;
  k=60*k+15*15*(((k+1)*k)/2);
  switch(n%k){
    case 0:k=k;break;   
    case 1:k=k+1;break;  
    case 2:
    case 3:k=k+3;break;
    case 4:
    case 5:
    case 6:k=k+7;break;
    case 7:k=k+14;break;
    case 8:
    case 9:
    case 10:k=k+22;break;
    case 11:
    case 12:k=k+33;break;
    case 13:k=k+46;break;
    default:k=k+60;break;
  }
  printf("%ld",k);
 return 0; 
}
