#include<stdio.h>
#include<stdlib.h>
int main(){
  //  int a;
    long long int a,total,total3,total5,total15;
    int x;
    char s[10];
    // 整数の入力
  fgets(s,10,stdin);
  sscanf(s,"%lld\n",&a);
  total = (long long int)((1+a)*a/2);
  
  x = a/3;
  //printf("%d ",x);
  total3 = (long long int)((3+3*x)*x/2);
  x=a/5;
  //printf("%d ",x);
  total5 = (long long int)((5+5*x)*x/2);
  x=a/15;
  //printf("%d ",x);
  total15 = (long long int)((15+15*x)*x/2);
  total = total - total3 - total5 + total15;
  printf("%lld",total);
  
}