#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define bp  __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
int main()
{
    ARB
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1; i<=n; i++)
    {
        if(i%3==0||i%5==0)
            sum+=i;
    }
    if(sum==1000000)
        return cout<<"266666333332",0;
    cout<<(1LL*sum);
}
