#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int a;
    int r = 0;
    cin >> a;
    for(int i=0;i<=a;i++){
        if(!(i % 3 == 0 || i % 5 == 0)){r+=i;}
    }
    cout << r << endl;
}