    #include <stdio.h>
    #include <math.h>
    void main()
    {
      long long int N,th,fiv,fif,ans;
      scanf("%lld", &N);
      th = N / 3;
      fiv = N / 5;
      fif = N / 15;
      ans=(N*(N+1)-3*th*(th+1)-5*fiv*(fiv+1)+15*(fif)*(fif+1))/2;
      printf("%lld", ans);
    }