#include <iostream>
#include <cstdio>
#include <algorithm>
typedef long long ll;
using namespace std;
const int maxn = 100009;
int k;
ll sum;
int main(){
    scanf("%d",&k);
    for(int i = 1; i <= k; i++){
        if(i%3 != 0 && i%5 != 0)sum += i;
    }
    printf("%lld",sum);
    return 0;
}