  #include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mkp make_pair
  #define pb push_back
  #define inf INT_MAX

  int32_t main()
  { 
  
    #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif
    IOS
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
      if(i%3==0 or i%5==0 or i%15==0)
        continue;
      else sum+=i;
    }
    cout<<sum;
    return 0;
   
}