#include<iostream>
#include<string>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   ll n,sum=0;
   cin>>n;
   for(ll i=1;i<=n;i++)
   {
       if((i%3)!=0 && (i%5)!=0)
        sum=sum+i;
   }
   cout<<sum;
   
   
    return 0;
}