#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
using namespace std;
#define MAXH 101
#define MAXW 101
#define INF 1000
#define MAXN 100001

int N, M;



int main(){
    cin >> N;
    long long sum = 0;
    for(int i = 1;i <= N;i++){
        if(i % 5 != 0 && i % 3 != 0){
            sum += i;
        }
    }

    printf("%lld\n", sum);
    
    return 0;
}