#include<iostream>
#define ll long long
#define MAXN 55
#define mod 998244353
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int n;
    cin>>n;
    int s=0;
    for(int i=0;i<n;i++){

        if(i%3!=0&&i%5!=0){
            s+=i;
        //    cout<<i<<' ';
        }
    }
    cout<<s<<endl;
    return 0;
}
