#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mpp make_pair
#define int long long int
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 998244353
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define MAXN 2000000
#define MAXI 10000000000007


signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n, sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
    	if(i%3!=0&&i%5!=0)
    		sum+=i;
    }
    cout<<sum<<endl;
}