#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long int

int main(){
  ll n;
  scanf("%lld",&n);

  ll ans=n*(n+1)/2;
  ans -= 3*(n/3)*(n/3+1)/2;
  ans -= 5*(n/5)*(n/5+1)/2;
  ans += 15*(n/15)*(n/15+1)/2;

  printf("%lld\n",ans);
  
  return 0;
}
