#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
map <ll,int> mp;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	ll n;
	cin>>n;
	ll sum=(1+n)*n/2;
	vector <ll> v1;
	ll a=3;
	while(a<=n){
		mp[a]=1;
		sum-=a;
		a=a+3;
	}
	a=5;
	while(a<=n){
		if(!mp[a]) 
		sum-=a;
		a+=5;
	}
	cout<<sum<<endl;
	return 0;
}
