#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

ll gcd(ll a, ll b) {
    while(true) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}

ll gcd(ll a, ll b, ll c) {
    ll x = gcd(a, b);
    ll y = gcd(b, c);
    return gcd(x, y);
}

int main() {
    // // int K;
    // // cin >> K;
    // for (int K = 1; K <= 200; ++K) {
    //     ll ans = 0;
    //     for (int a = 1; a <= K; ++a) {
    //         for (int b = 1; b <= K; ++b) {
    //             for (int c = 1; c <= K; ++c) {
    //                 ans += gcd(a, b, c);
    //             }
    //         }
    //     }
    //     cout << "v[" << K << "]" << " = " << ans << endl;
    // }
    vector<int> v(205);
v[1] = 1;
v[2] = 9;
v[3] = 30;
v[4] = 76;
v[5] = 141;
v[6] = 267;
v[7] = 400;
v[8] = 624;
v[9] = 885;
v[10] = 1249;
v[11] = 1590;
v[12] = 2208;
v[13] = 2689;
v[14] = 3411;
v[15] = 4248;
v[16] = 5248;
v[17] = 6081;
v[18] = 7485;
v[19] = 8530;
v[20] = 10248;
v[21] = 11889;
v[22] = 13687;
v[23] = 15228;
v[24] = 17988;
v[25] = 20053;
v[26] = 22569;
v[27] = 25242;
v[28] = 28588;
v[29] = 31053;
v[30] = 35463;
v[31] = 38284;
v[32] = 42540;
v[33] = 46581;
v[34] = 50893;
v[35] = 55362;
v[36] = 61824;
v[37] = 65857;
v[38] = 71247;
v[39] = 76884;
v[40] = 84388;
v[41] = 89349;
v[42] = 97881;
v[43] = 103342;
v[44] = 111528;
v[45] = 120141;
v[46] = 128047;
v[47] = 134580;
v[48] = 146316;
v[49] = 154177;
v[50] = 164817;
v[51] = 174438;
v[52] = 185836;
v[53] = 194157;
v[54] = 207927;
v[55] = 218812;
v[56] = 233268;
v[57] = 245277;
v[58] = 257857;
v[59] = 268182;
v[60] = 288216;
v[61] = 299257;
v[62] = 313635;
v[63] = 330204;
v[64] = 347836;
v[65] = 362973;
v[66] = 383709;
v[67] = 397042;
v[68] = 416448;
v[69] = 434025;
v[70] = 456967;
v[71] = 471948;
v[72] = 499740;
v[73] = 515581;
v[74] = 536073;
v[75] = 559758;
v[76] = 583960;
v[77] = 604833;
v[78] = 633651;
v[79] = 652216;
v[80] = 683712;
v[81] = 709065;
v[82] = 734233;
v[83] = 754734;
v[84] = 793188;
v[85] = 818917;
v[86] = 846603;
v[87] = 874512;
v[88] = 909496;
v[89] = 933081;
v[90] = 977145;
v[91] = 1006126;
v[92] = 1041504;
v[93] = 1073385;
v[94] = 1106467;
v[95] = 1138536;
v[96] = 1187112;
v[97] = 1215145;
v[98] = 1255101;
v[99] = 1295142;
v[100] = 1342852;
v[101] = 1373253;
v[102] = 1422195;
v[103] = 1453816;
v[104] = 1502376;
v[105] = 1553361;
v[106] = 1595437;
v[107] = 1629570;
v[108] = 1691292;
v[109] = 1726717;
v[110] = 1782111;
v[111] = 1827492;
v[112] = 1887772;
v[113] = 1925853;
v[114] = 1986837;
v[115] = 2033674;
v[116] = 2089776;
v[117] = 2145333;
v[118] = 2197483;
v[119] = 2246640;
v[120] = 2332104;
v[121] = 2379085;
v[122] = 2434833;
v[123] = 2490534;
v[124] = 2554600;
v[125] = 2609625;
v[126] = 2693919;
v[127] = 2742052;
v[128] = 2813988;
v[129] = 2875245;
v[130] = 2952085;
v[131] = 3003306;
v[132] = 3096024;
v[133] = 3157249;
v[134] = 3224511;
v[135] = 3306240;
v[136] = 3388576;
v[137] = 3444609;
v[138] = 3533637;
v[139] = 3591322;
v[140] = 3693924;
v[141] = 3767085;
v[142] = 3842623;
v[143] = 3912324;
v[144] = 4027884;
v[145] = 4102093;
v[146] = 4181949;
v[147] = 4270422;
v[148] = 4361548;
v[149] = 4427853;
v[150] = 4548003;
v[151] = 4616104;
v[152] = 4718640;
v[153] = 4812789;
v[154] = 4918561;
v[155] = 5003286;
v[156] = 5131848;
v[157] = 5205481;
v[158] = 5299011;
v[159] = 5392008;
v[160] = 5521384;
v[161] = 5610705;
v[162] = 5739009;
v[163] = 5818390;
v[164] = 5930196;
v[165] = 6052893;
v[166] = 6156139;
v[167] = 6239472;
v[168] = 6402720;
v[169] = 6493681;
v[170] = 6623853;
v[171] = 6741078;
v[172] = 6864016;
v[173] = 6953457;
v[174] = 7094451;
v[175] = 7215016;
v[176] = 7359936;
v[177] = 7475145;
v[178] = 7593865;
v[179] = 7689630;
v[180] = 7886244;
v[181] = 7984165;
v[182] = 8130747;
v[183] = 8253888;
v[184] = 8403448;
v[185] = 8523897;
v[186] = 8684853;
v[187] = 8802826;
v[188] = 8949612;
v[189] = 9105537;
v[190] = 9267595;
v[191] = 9376656;
v[192] = 9574704;
v[193] = 9686065;
v[194] = 9827097;
v[195] = 9997134;
v[196] = 10174780;
v[197] = 10290813;
v[198] = 10493367;
v[199] = 10611772;
v[200] = 10813692;
int K;
cin >> K;
cout << v[K] << endl;
    return 0;
}


Measured memory_bytes: 3636