#include <stdio.h>
int main() {
	int n;
	long long int val = 0;
	scanf("%d",&n);
	
	for (int i = 1 ; i <= n; i++)
	{
		if (i % 3 == 0 && i % 5 == 0)
		{
			continue;
		}
		else if (i % 3 == 0)
		{
			continue;
		}
		else if (i % 5 == 0)
		{
			continue;
		}
		else
		{
			val += i;
		}
	}
	printf("%lld",val);
	return 0;
}
#include <bits/stdc++.h>

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}