
#include <iostream>
#include <algorithm>
#include < deque >
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int64_t N;
    cin >> N;
    int64_t ans = 0;
    for (int i = 0; i < N; i++) {
    if (i % 3 == 0 || i % 5 == 0)
    {
        
        continue;
    }
    
    else
    {
        ans = ans + i;
        
    }
    }
    cout << ans << endl;
    }