#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;


int main() {
    int n;
    cin >> n;
    ll res = 0;
    rep(i,n){
        if ((i+1)%3 == 0) continue;
        else if ((i+1)%5 == 0) continue;
        else {
            res += i+1;
        }
    }
    cout << res << endl;
    return 0;
}