#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	ll sum=0;
	sum=n*(n+1)/2;
	ll n1=n/3;
	sum-=3*(n1+1)*n1/2;
	n1=n/5;
	sum-=5*(n1+1)*n1/2;
	n1=n/15;
	sum+=15*(n1+1)*n1/2;
	printf("%lld",sum);
}