#include <iostream>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
int MOD = 998244353;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int N;
    cin >> N;
    ll ans = 0;
    int c = 0;
    ll i=1;
    while(1){
        if( i%3 != 0 && i%5 != 0 ) { ans += i; ++c; }
        ++i;
        if( i == N ) break;
    }
    cout << ans;




}
