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