#include<iostream>

using namespace std;
int main()
{
    int A[100000];
    int N;
    long long sum;
    cin >> N;
    for(int i=0;i<N;i++){
        A[i]=i+1;
    }
    for(int i=0;i<N;i++){
        if(A[i] % 3 == 0 || A[i] % 5 == 0 ){
            continue;
        }else{
            sum += A[i];
        }
    }
    cout << sum;


    
    return 0;
    
}