/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    ll n, sum = 0;
    cin >> n;
    for (int i = 1; i<= n; i++){
        if ((i%3 != 0)&&(i%5 != 0)){
            sum += i;
        }
    }
    cout << sum;
    return 0;
}


