#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	ll n;
	cin >>n;

	ll n3=n/3,n5=n/5,n15=n/15;
	ll ret=n*(n+1)/2;
	ret-=3*n3*(n3+1)/2;
	ret-=5*n5*(n5+1)/2;
	ret+=15*n15*(n15+1)/2;

	cout<< ret<< endl;
	return 0;
}
