#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n; cin>>n;
	ll son_3 = n/3 * 3;
	if(son_3) son_3 = (3 + son_3) * (son_3/3) / 2;
	ll son_5 = n/5 * 5;
	if(son_5) son_5 = (5 + son_5) * (son_5/5) / 2;
	ll son_15 = n/15 * 15;
	if(son_15) son_15 = (15 + son_15) * (son_15/15) / 2;
	cout<< n * (n+1) / 2 - son_3 - son_5 + son_15;
}
