#include <iostream>
#include <vector>
using namespace std;
void nextNumber(vector<int>& number, bool& finish) {
static const int n = 13;
finish = false;
int rest = 1;
for (int i = number.size() - 1; i >= 0; --i) {
int val = number[i] + rest;
rest = val / n;
val = val % n;
number[i] = val;
}
if (rest) {
finish = true;
}
}
long long getBeatifulNumbers() {
vector<long> buf(6 * 13, 0);
vector<int> number(6, 0);
bool finish = false;
while (!finish) {
nextNumber(number, finish);
int sum = 0;
for (auto elem: number) {
sum += elem;
}
buf[sum] += 1;
}
long long res = 0;
for (auto elem : buf) {
res += elem * elem;
}
res *= 13;
return res;
}
int main()
{
cout << getBeatifulNumbers() << endl;
}