using namespace std;

#include <cstdint>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

int main(
){
    cin.tie(0);
    ios::sync_with_stdio(false);

    long     N = 0;
    long     n = 0;
    cin >> N;
    long     ans = 0;
    for(n = 1; n<N+1; n++){
        if(n%3 != 0 && n%5 != 0){
            ans = ans + n;
        }
    }
    cout << ans << "\n";
    return 0;
    
}