#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <vector>

#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DV_NUM (100000007)

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

 const int MAX_N = 1000000;

int main()
{
    int N;
    cin >> N;

    long sum = 0;

    FOR(i,0,N){
     if ( (i % 3 != 0 ) && (i % 5 != 0 )){
         sum += i;
     }
    
    }

    cout << sum << endl;
 
    return 0;
 
}