#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,sum,Fizz,Buzz,FizzBuzz;
    lli i,l,k;
    cin>>n;
    sum=(1+n)*n/2;
    Fizz=n/3;
    Buzz=n/5;
    FizzBuzz=n/15;
    Fizz=3*(1+Fizz)*Fizz/2;
    Buzz=5*(1+Buzz)*Buzz/2;
    FizzBuzz=15*(1+FizzBuzz)*FizzBuzz/2;
    sum+=FizzBuzz-Fizz-Buzz;
    cout<<sum<<endl;
}
