#include<bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;
ll a , b  , cnt , n , m , ans , mn;
int main(){
    cin >> n;
    for( int i = 1;i <= n;i ++ ){
        if( i % 3 != 0 and i % 5 != 0 )
            cnt+=i;
    }
    cout << cnt;
}
/// ab#c ad#c
/// ab## c#d#
