#include<bits/stdc++.h>
using namespace std;
int a[1000006];
int main()
{
    long long n, i, j, s =0,s1=0;
    cin >> n;
    //cout<<s<<endl;
     for (i = 1;i<=n; i++)
    {
      if(i%3==0)
      {
        a[i]=1;
      }else if(i%5==0)
      {
        a[i]=1;
      }
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            s=s+i;
        }
    }
    cout<<s<<endl;
    return 0;

}