#include <bits/stdc++.h>
//#include <iostream>

using namespace std;

int main(){
    long long n=0,ans=0;
    //char s[200];
    bool flag = false;
    //vector<int> a(N,0);

    cin >> n;

    for(int i=0;i<n;i++){
        if(((i+1)%3 != 0) && ((i+1)%5 != 0)){
            ans += i+1;
        }
    }


    

    cout << ans << endl;
    //cout << ( (flag) ? "Yes" : "No" ) << endl;
}