#include <iostream>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
	long long N;
	cin >> N;
	long long result = 0;
	
	for(long long i = 1;i<=N;i++){
		if(i % 3 != 0 && i % 5 != 0){
			result += i;
		}
		
	}
	
	std::cout << result << endl; 	
	return 0;
	
}

#include<bits/stdc++.h>
using namespace std;

int main(){
    int64_t N;
    cin >> N;
    cout << (N / 1 * 1 * (N / 1 + 1) - N / 3 * 3 * (N / 3 + 1) - N / 5 * 5 * (N / 5 + 1) + N / 15 * 15 * (N / 15 + 1)) / 2 << endl;
}