#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a; i<b; i++)
#define dep(i,a,b) for(int i=a; i>=b; i--)
#define sq(a) (a)*(a)
#define ms(a,v)	memset(a,v,sizeof a)
using namespace std;
const long long INF = 1e18 , MAXN =1e5, MOD = 1e9 + 7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<string, string> mss;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;  cin>>n;
  ll sum=1l*n*(n+1)/2;
  int n1=(n-3)/3+1;
  int n2=(n-5)/5+1;
  int n3=(n-15)/15+1;
  ll sum1=0,sum2=0,sum3=0;

  if (n1>0){
    sum1=1ll*n1*(6+(n1-1)*3)/2;
  }
  if (n2>0){
    sum2=1ll*n2*(10+(n2-1)*5)/2;
  }
  if (n3>0){
    sum3=1ll*n3*(30+(n3-1)*15)/2;
  }
  cout<<sum-sum1-sum2+sum3<<"\n";
    return 0;
}
