#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/

int main()
{
  ll n;cin>>n;
  ll a=n/3,b=n/5,c=n/15;
  a=3*a*(a+1)/2;
  b=5*b*(b+1)/2;
  c=15*c*(c+1)/2;
  n=n*(n+1)/2;
  cout<<n-a-b+c<<endl;
  return 0;
}
