#include <stdio.h>
int SUM(long int n);
int main (){
  long long int sum;
  int N
  scanf("%d",&N);
  sum = SUM(N)-SUM(N/3)*3-SUM(N/5)*5+SUM(N/15)*15;
  printf("%11d",sum);
  return 0;
}
int SUM(long int n){
  return n*(n+1)/2;
}
