#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++){
        if(0==i%3||0==i%5){
            continue;
        }else{
            sum+=i;
        }
    }
    cout<<sum;
    return 0;
}