#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int s = n * (n + 1) / 2;
    int m3 = n / 3;
    int m5 = n / 5;
    int m15 = n / 15;
    cout << s - (m3*(m3+1)/2*3 + m5*(m5+1)/2*5 - m15*(m15+1)/2*15);
    return 0;
}