//#include<string>
#include <iostream>

#define T long long

int main(void){
	T result=0;
	T n;
	
	std::cin >> n;
	for(int i=1;i<=n;i++){
		if(((i%5)!=0)&&((i%3)!=0)){
			result+=i;
		}
	}
	std::cout << result <<std::endl;
}
