/*author @sushil*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sushil ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() long long t;cin>>t;while(t--)
using namespace std;
int main()
{
    ll n,sum=0,i;
  cin>>n;
  for(i=1;i<=n;i++)
  {
      if((i%3!=0)&&(i%5!=0))
      {
          sum=sum+i;
      }
     
  }
  cout<<sum;
}