#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;
const int inf=1001001001;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
int main()
{
    ll a,b,c,n,sum=0;
    string s;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	if(i%3!=0&&i%5!=0)sum+=i;
    }
    cout<<sum;
}
