#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <stdlib.h>

int main(){
    
    
    ll n;
    cin >> n;
    ll sum = 0;
    for(ll i=0LL;i < n;i++){
        if(i % 3 == 0LL || i % 5 == 0LL){

        }else {

            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}