#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define bitcnt(n) __builtin_popcountll(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++)cout << c[pos] << " ";
#define PI acos(-1)
const int M = 1000000007;
const int N=3e5 + 7;

#ifdef LOCAL
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__)
#endif

void solve(){
    int i , j , n ;

}
signed main()
{
    int tc , i ,j;
    int n;
    cin >> n;
    int sum=0;
    for(i=1 ; i<=n ; i++)
    {
        if(i%15==0 || i%5==0 || i%3==0){
        }
        else{
            sum+=i;
        }

    }
    cout << sum << endl;

}