#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 998244353
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;
 
lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a)%M;
        b >>= 1;
        if (!b)
            break;
        a = (a*a)%M;
    }
    return result;
}

int main()
{
    IOS;
    lli n;
    cin>>n;
    lli ans = 0;
    for(lli i = 1; i<n+1; i++)
    {
		if((i%3 != 0) and (i%5 != 0))
		ans += i;
	}
	cout<<ans<<endl;
 /*   string s;
    cin>>s;
    lli dp[3][n+1];
    memset(dp, 0, sizeof(dp));
    for(lli i = 1; i<n+1; i++)
    dp[0][i] = dp[0][i-1] + (s[i-1] == 'R'), dp[1][i] = dp[1][i-1] + (s[i-1] == 'G'), dp[2][i] = dp[2][i-1] + (s[i-1] == 'B');
	lli ans = 0;
    for(lli i = 0; i<n; i++)
    {
		for(lli k = i+3; k<n; k++)
		{
			if(s[i] != s[k])
			{
				if(s[i]!='R' and s[k]!='R')
				{
					ans += dp[0][k] - dp[0][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'R'))
					ans--;
				}
				else if(s[i]!='G' and s[k]!='G')
				{
					ans += dp[1][k] - dp[1][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'G'))
					ans--;
				}
				else
				{
					ans += dp[2][k] - dp[2][i+1];
					if((k-i-1)%2 and (s[(k+i)/2] == 'B'))
					ans--;
				}
			}
		}
	}
	cout<<ans<<endl;*/
}
