A = int(input()) answer = [16396904,16391853,16393092,16395312,16393935,16394415,16393560,16393614,16392543,16391493,16392123,16391409,16395870,16392669,16393836,16391796,16392447,16392198,16393961,16392342,16393530,16392584,16394214,16392060,16389912,16392417,16392090,16395315,16390545,16390263,16393601,16390353,16393977,16395219,16394697,16392762,16392690,16394142,16392753,16392830,16392132,16393347,16390203,16392603,16389549,16392192,16393323,16393476,16391808,16390536,16392258,16395426,16393842,16392972,16391658,16392405,16394148,16392906,16391055,16392603,16391163,16392213,16390008,16392549,16391343,16394304,16393137,16389846,16392687,16390239,16397562,16393371,16394418,16393800,16393986,16397096,16393368,16394310,16392405,16393959,16395540,16394721,16390083,16390563,16392744,16391661,16389978,16392987,16394271,16390407,16393845,16391403,16388562,16392132,16391751,16394721,16392699,16391520,16386219,16394841,16394253,16389546,16393659,16391076,16392636,16393533,16392903,16394175,16393080,16395648,16393239,16394915,16392717,16395393,16393440,16389984,16390242,16391547,16391217,16391919,16392132,16393128,16395501,16393236,16391187,16392657,16393293,16395264,16392702,16393833,16394628,16394118,16391322,16392984,16391562,16392180,16393815,16393473,16393263,16392180,16391073,16393263,16395342,16391118,16393304,16393428,16393587,16395921,16393245,16388514,16394355,16391286,16393602,16389834,16393407,16390857,16391729,16392015,16393380,16391012,16391352,16391817,16392068,16391823,16392672,16390332,16386408,16395723,16391655,16392480,16395066,16395294,16393593,16392597,16391933,16392444,16394895,16394621,16393203,16394442,16393908,16391895,16391718,16392402,16396422,16392813,16394454,16390491,16390869,16394229,16393656,16391343,16392648,16389864,16390770,16393296,16395321,16394223,16392285,16390326,16394730,16394058,16395363,16392498,16393185,16391364,16394832,16390722,16392666,16394211,16392540,16392702,16390989,16391958,16390125,16392495,16392093,16390626,16391910,16392516,16392720,16391874,16395408,16392969,16392561,16392789,16394574,16392879,16392003,16390557,16393866,16394544,16393350,16393287,16392879,16390578,16391916,16392102,16392648,16396224,16394826,16392876,16392381,16394316,16392807,16391835,16393368,16392126,16393824,16390974,16390839,16394493,16393247,16392702,16391070,16391415,16392198,16394463,16391508,16394934,16393983,16392819,16393353,16393317,16393769,16390719,16392909,16391526,16390794,16391757,16391640,16391196,16392978,16393224,16391781,16392321,16391136,16393140,16392897,16393089,16391097,16392306,16391619,16391874,16395075,16393962,16394379,16393683,16391460,16394595,16393500,16395657,16392015,16395396,16391649,16391367,16392825,16391988,16394154,16394313,16391373,16392807,16393791,16394028,16391004,16393371,16394619,16395108,16391520,16392717,16391661,16392012,16390995,16390458,16388271,16393005,16393044,16394184,16393944,16392000,16393203,16394397,16391406,16392384,16393080,16392339,16393755,16390950,16394205,16391031,16392834,16391649,16393527,16391147,16395048,16392756,16393482,16391196,16392075,16392750,16394526,16395429,16394703,16393776,16393101,16390488,16391721,16391844,16392708,16394115,16390485,16389488,16392219,16388829,16393572,16390089,16391601,16394292,16394424,16392807,16393092,16394730,16393203,16393734,16395390,16393869,16394463,16393647,16395864,16391360,16391892,16392315,16389963,16393305,16392912,16393224,16392768,16392627,16393743,16387212,16393071,16391208,16394256,16394442,16393035,16392840,16392453,16391124,16391022,16394316,16395018,16392879,16391592,16393641,16392855,16394739,16393701,16394229,16393116,16393215,16391961,16392192,16394100,16392399,16393080,16393851,16390719,16393956,16394619,16392753,16392204,16392380,16392276,16390179,16392453,16391931,16394904,16391601,16393017,16392285,16389672,16389417,16389945,16393692,16393701,16395387,16391268,16390614,16389834,16392231,16389705,16395714,16391967,16391613,16392879,16393518,16394967,16395735,16392849,16391691,16393737,16395210,16392651,16392558,16390908,16395054,16392366,16389468,16391223,16391994,16392498,16394124,16389582,16392471,16391877,16392261,16393887,16393284,16392177,16392129,16393014,16392024,16392117,16394823,16390818,16392042,16393638,16393767,16392086,16392732,16394040,16394103,16393374,16393680,16393707,16394172,16392024,16393155,16395594,16393383,16391934,16390836,16390647,16395525,16391085,16393452,16391807,16393428,16391238,16393404,16394313,16392783,16394658,16391799,16394235,16390599,16392000,16391925,16390515,16392276,16390467,16390863,16392990,16392627,16394334,16395975,16390977,16389930,16396248,16394205,16394763,16394139,16394334,16395308,16392207,16392873,16394538,16394499,16393776,16391529,16390575,16390293,16392384,16393002,16392624,16395306,16392486,16391604,16392405,16390731,16393149,16392354,16393002,16391058,16391652,16392822,16392108,16393254,16391727,16394181,16393470,16392135,16394631,16392726,16392405,16394715,16394274,16394574,16394802,16391073,16392579,16392891,16393299,16393143,16393632,16393305,16390290,16391760,16392258,16391079,16392423,16392267,16393326,16391901,16394235,16388040,16391283,16392162,16392948,16390548,16390257,16393359,16394097,16394916,16392327,16394730,16395279,16394715,16394481,16393257,16394610,16395555,16393059,16390062,16395471,16391844,16393923,16392903,16390677,16392660,16393257,16390017,16392321,16395441,16394055,16390914,16391121,16389867,16392336,16392075,16391273,16393314,16392408,16390941,16393410,16393341,16390719,16394445,16392375,16393731,16393203,16396167,16393914,16394286,16393335,16392435,16390878,16391106,16393901,16392315,16391811,16392387,16392444,16394787,16391955,16393554,16394838,16396386,16389003,16391916,16395207,16391397,16393443,16389333,16393398,16393734,16393728,16392936,16392240,16389507,16391586,16392987,16394778,16392861,16391826,16392204,16395621,16391064,16394229,16394484,16394685,16390671,16393656,16393713,16392063,16392537,16390806,16393884,16389852,16393173,16390722,16392840,16392099,16395537,16394526,16390974,16392582,16394217,16394826,16393578,16391001,16389723,16395252,16392978,16391349,16394760,16392954,16392795,16391835,16393044,16391037,16394811,16392642,16395063,16393538,16392465,16390329,16391403,16392441,16394538,16392141,16393287,16393860,16393215,16390782,16395381,16390434,16394262,16394763,16393815,16395351,16393482,16391595,16391025,16392321,16394241,16393830,16392837,16393311,16393866,16391679,16394412,16391007,16392426,16391172,16391496,16392366,16391286,16391457,16391529,16387944,16392078,16392996,16394601,16390920,16392423,16394643,16394760,16394127,16391235,16395201,16394829,16392387,16391571,16391967,16392707,16392063,16394562,16392609,16395234,16391739,16391379,16394844,16391163,16395054,16393863,16394058,16391178,16391511,16392018,16390761,16392681,16389978,16391118,16391118,16392306,16392315,16392729,16395075,16391411,16393923,16390542,16392606,16393869,16395783,16391076,16392243,16392276,16393503,16393683,16392195,16391799,16394670,16393035,16394708,16392795,16393389,16392117,16393092,16389663,16394562,16389729,16392393,16390974,16390749,16389900,16391484,16393143,16389984,16394544,16393122,16392885,16393863,16392717,16396134,16393296,16393902,16394613,16394991,16394145,16393269,16391493,16391427,16391502,16393325,16392834,16393539,16393638,16389786,16393182,16391661,16394868,16395231,16393542,16392390,16389387,16394202,16390410,16391433,16393146,16392390,16391901,16391166,16393521,16391361,16391969,16393872,16391223,16392504,16392864,16392525,16395456,16394544,16393257,16389606,16392966,16392780,16394496,16393299,16395303,16393404,16395405,16392594,16393506,16389993,16394706,16393848,16393608,16394241,16393686,16391649,16392288,16388214,16391619,16391478,16392183,16392171,16392570,16393251,16393920,16390977,16391514,16395813,16395441,16393944,16390068,16393509,16395093,16392255,16391880,16393158,16392552,16390977,16394207,16392801,16394610,16394480,16389603,16392618,16394139,16392453,16392603,16394082,16392135,16386921,16392453,16390584,16393722,16392933,16396242,16391904,16391619,16391154,16391523,16394744,16393710,16394259,16392974,16393386,16390788,16392036,16393134,16391517,16389425,16394316,16393137,16392927,16393212,16395279,16393089,16392135,16390371,16393098,16396041,16395330,16392494,16393860,16391232,16393341,16390227,16392552,16395111,16394919,16391934,16391178,16390182,16390842,16392147,16395273,16391523,16391121,16390266,16392084,16392714,16392135,16392651,16393050,16392378,16394715,16392519,16393437,16393893,16394031,16392201,16392276,16394108,16394562,16393512,16391952,16394466,16393965,16392170,16392429,16393800,16393808,16391274,16393986,16393200,16392768,16392765,16390910,16390326,16392057,16394160,16392531,16390446,16394021,16393812,16396059,16392474,16391922,16393686,16393275,16389921,16389348,16391670,16396032,16392417,16392300,16393305,16392279,16394217,16391934,16394673,16392921,16394451,16392081,16391859,16393527,16389120,16394676,16394772,16391445,16391760,16391973,16395096,16392906,16394475,16393677,16392324,16391601,16392381,16393614,16392681,16391223,16390659,16390740,16393047,16391523,16394172,16394340,16392534,16391397,16395891,16392630,16395828,16392954,16395783,16392117,16394832,16388997,16391943,16393041,16392462,16393212,16390944,16392279,16394379,16391835,16391640,16393689,16391151,16392839,16394388,16391985,16391907,16391205,16391406,16391976,16391328,16392570,16390814,16394982,16390428,16393892,16394229,16393791,16392326,16392717,16394073,16393104,16390668,16394076,16395372,16394442,16391796,16390158,16391571,16393677,16392816,16393323,16390950,16391784,16393881,16392507,16393602,16392576,16395651,16389963,16393548,16390062,16392321,16393845,16391136,16392378,16392294,16391916,16393209,16392840,16391058,16394061,16392306,16392726,16393878,16392465,16392957,16393995,16391652,16394031,16390331,16392762,16393428,16392789,16390971,16394337,16393128,16389450,16394307,16392864,16392138,16394943,16393995,16393818,16396566,16392891,16392468,16390293,16391667,16392453,16392300,16392315,16389501,16395780,16391742,16393791,16393371,16392030,16393272,16390545,16393458,16392882,16393521,16393227,16390866,16391943,16391130,16391706,16393218,16393035,16391460,16392579,16392570,16395534,16391511,16394579,16394892,16394829,16392597,16390899,16392909,16396056,16392642,16393725,16391529,16389423,16391952,16392920,16391700,16392591,16393473,16393662,16392429,16391691,16395189,16394853,16395879,16389669,16391799,16390830,16393599,16393461,16394100,16393854,16390659,16394355,16392078,16392237,16392486,16394394,16392819,16392668,16392921,16393485,16393056,16393386,16392993,16390998,16395858,16393596,16393191,16394289,16389222,16394895,16390797,16393572,16390992,16389546,16390554,16391763,16393449,16389798,16391936,16392063,16390512,16396161,16392183,16392792,16395753,16394133,16392705,16394115,16392312,16393710,16396566,16393611,16392753,16392171,16391835,16393728,16395885,16392477,16394136,16391244,16393506,16390278,16391397,16393155,16392099,16390341,16390401,16392981,16391238,16391766,16393281,16390227,16391556,16391157,16391865,16392651,16392891,16395978,16394733,16393773,16392165,16391970,16394619,16396749,16393611,16391880,16393098,16392207,16393515,16393323,16393758,16391418,16393389,16393515,16392939,16391798,16394910,16392327,16392858,16391439,16391043,16394505,16388895,16391889,16389987,16389117,16392291,16394400,16393848,16395687,16394745,16393059,16393434,16393398,16393479,16394646,16394943,16392462,16394247,16393094,16392423,16392060,16393422,16393440,16394943,16392123,16395294,16393617,16392594,16390935,16393503,16390338,16394697,16392186,16392660,16392798,16389567,16391289,16389456,16389873,16393356,16394088,16392441,16391429,16392270,16394352,16394361,16395531,16394604,16394187,16394580,16394229,16393059,16391577,16389279,16391871,16393545,16395834,16391568,16393341,16392741,16392461,16390971,16394385,16395165,16395672,16392960,16391070,16390932,16390101,16390335,16392495,16391103,16391964,16392018,16393263,16391040,16392279,16394757,16392797,16393272,16391160,16394025,16395369,16393488,16391988,16393227,16392597,16391406,16391004,16390341,16394286,16391796,16395615,16392155,16393701,16391928,16392753,16392384,16392726,16396188,16389411,16391910,16391403,16389153,16394247,16391954,16394475,16393644,16390715,16392450,16394043,16391526,16391436,16394451,16394034,16393917,16393722,16392735,16395339,16393503,16392597,16391973,16395261,16391949,16394526,16391766,16392960,16393929,16389885,16394564,16389525,16394334,16394120,16395837,16393191,16390725,16390806,16393956,16392273,16394631,16395420,16394277,16390173,16387488,16389654,16392387,16393368,16393728,16391223,16394445,16392321,16392726,16395705,16393914,16391970,16391064,16392759,16392336,16392174,16393284,16388367,16394817,16391790,16390896,16395123,16394481,16393824,16393392,16393356,16394328,16393770,16394886,16392795,16393287,16390899,16392213,16391523,16389870,16391256,16392558,16390050,16393821,16392501,16393143,16394214,16393842,16393071,16391682,16393587,16392180,16392636,16392648,16394916,16392480,16393470,16393503,16392075,16391124,16392995,16394394,16394445,16392218,16392402,16391385,16393365,16394145,16392522,16390850,16393482,16393254,16392312,16392276,16390767,16391021,16394115,16391181,16391603,16393242,16391862,16394460,16392162,16392345,16394175,16391208,16392546,16390512,16392969,16393434,16391504,16395480,16392984,16391553,16394163,16392207,16392978,16390065,16395675,16391906,16395186,16390635,16391106,16393209,16392684,16393047,16392933,16394529,16395117,16392726,16392858,16388436,16391958,16391436,16392435,16393860,16390503,16393851,16390518,16391133,16394070,16391265,16392699,16395525,16394160,16393143,16392291,16391802,16392057,16394250,16393254,16392930,16396259,16393521,16393800,16393455,16394808,16391712,16391415,16394247,16394289,16393965,16390137,16392252,16390101,16392666,16394904,16392936,16394544,16393716,16390368,16392939,16393101,16393272,16393437,16393020,16390340,16394379,16392996,16391754,16392582,16392306,16394034,16394247,16391337,16395930,16394118,16394817,16391106,16389159,16389849,16397118,16393122,16394922,16390158,16392831,16394433,16393740,16392201,16391403,16392657,16391505,16394148,16390887,16392684,16392405,16390590,16393587,16391034,16390491,16394064,16392876,16393068,16390803,16394586,16392549,16394598,16390239,16388492,16395837,16392771,16392234,16388139,16391547,16394157,16392927,16391472,16396572,16395012,16393566,16392819,16391553,16392015,16394006,16392975,16393182,16395327,16392111,16393860,16395710,16394223,16393914,16389867,16392375,16392240,16394283,16393761,16390599,16392894,16392255,16392573,16390254,16393254,16394052,16391760,16391280,16392411,16392800,16392093,16393446,16395111,16395315,16394379,16391835,16392303,16391979,16393125,16393449,16395519,16395371,16392006,16391193,16393689,16395879,16392870,16394115,16390719,16394133,16392102,16394331,16391184,16392444,16391802,16391382,16391181,16389066,16393992,16395060,16395225,16389306,16391067,16392357,16393419,16394310,16390500,16394400,16395507,16392435,16394580,16394121,16394145,16393749,16394612,16394415,16394820,16392369,16391166,16392840,16394154,16392591,16391673,16393059,16391994,16393533,16389587,16393956,16391073,16390818,16390431,16389939,16390518,16392834,16393182,16388952,16391985,16393506,16392003,16393527,16392930,16392900,16395462,16391748,16393179,16395123,16393431,16395278,16395936,16394856,16394168,16392837,16392804,16395873,16394826,16390029,16393524,16390278,16390965,16391249,16390494,16392090,16390875,16393221,16390896,16392651,16392498,16393248,16392966,16391328,16391610,16392711,16395606,16393137,16390263,16391481,16394481,16393070,16392948,16394787,16393878,16393401,16393254,16391661,16393803,16391577,16390659,16390500,16392306,16391664,16395717,16392357,16392810,16391796,16393533,16390899,16392774,16392516,16391805,16393038,16391547,16392771,16393329,16391550,16394379,16393470,16392441,16391558,16394166,16394169,16392780,16392843,16391001,16395315,16393581,16391172,16394895,16394331,16394985,16392000,16392243,16395846,16392564,16392282,16392924,16394664,16394070,16392447,16390971,16392147,16394463,16393887,16389168,16393287,16387137,16391964,16390608,16393379,16392918,16393176,16391787,16390788,16394646,16391412,16393521,16393716,16392273,16394586,16394721,16392816,16395108,16390824,16390896,16388283,16394853,16394106,16390260,16392993,16393068,16392117,16391295,16391757,16393752,16394817,16394535,16392351,16393053,16391262,16393965,16394601,16388187,16394325,16392645,16395692,16391994,16391802,16393010,16392648,16392237,16392933,16394403,16394079,16392036,16393683,16391925,16392531,16393608,16391121,16389123,16394991,16390719,16393917,16391673,16392072,16390266,16391325,16391439,16393775,16395918,16393320,16393626,16393926,16390329,16394478,16393257,16394658,16392732,16391829,16393200,16389081,16392177,16390464,16395006,16393506,16392837,16390713,16393740,16394988,16393893,16393926,16391592,16394370,16395606,16390893,16394919,16392810,16393746,16392378,16394232,16390458,16395777,16392999,16393773,16388484,16392120,16391409,16394481,16392030,16394064,16393149,16392789,16392321,16391448,16391313,16392459,16392261,16392588,16390173,16392243,16392129,16392945,16394270,16391769,16391280,16392615,16394289,16393497,16391736,16389858,16391526,16394076,16393929,16390296,16393395,16394262,16391817,16396769,16391994,16395732,16393980,16393674,16392204,16395315,16394457,16393389,16393682,16393917,16394229,16394190,16390203,16391634,16390236,16392522,16392255,16393125,16393491,16392519,16394178,16392750,16393782,16392348,16390794,16392291,16394610,16393326,16392459,16388304,16390761,16392531,16395564,16392021,16393242,16393983,16396224,16392507,16393179,16392999,16395123,16389642,16393947,16390362,16392315,16391661,16394028,16390260,16391877,16392678,16394127,16390800,16394265,16391835,16394214,16392264,16393896,16393047,16392960,16392075,16389654,16394946,16392753,16393440,16394319,16391016,16391838,16391625,16395354,16395177,16394376,16390929,16391502,16393032,16393266,16392564,16395558,16392606,16395231,16391697,16387700,16388913,16392045,16392264,16393680,16392774,16391859,16392789,16393236,16391841,16393095,16392498,16391148,16393869,16393140,16393191,16390668,16390647,16391441,16392879,16390554,16391211,16395759,16394034,16393572,16393758,16391895,16394255,16393188,16396692,16394628,16393773,16391859,16392834,16390350,16392996,16393479,16389642,16394097,16392989,16391754,16393986,16392054,16393203,16392999,16393032,16393551,16394517,16395567,16390260,16392219,16389705,16391976,16390626,16392276,16392297,16392063,16392489,16390389,16390881,16393524,16395552,16391130,16393530,16392375,16398081,16394862,16392990,16391949,16394204,16390995,16389375,16394067,16392390,16391070,16393608,16389360,16392714,16394385,16391304,16393926,16392258,16393467,16390812,16392312,16391286,16393008,16391673,16392489,16394298,16393179,16391523,16391475,16394031,16393758,16392267,16391880,16394931,16395066,16391631,16391472,16391457,16392192,16396383,16394925,16392816,16393962,16393473,16394526,16393893,16394091,16393563,16390362,16392066,16390940,16393527,16391706,16390134,16390728,16388412,16392639,16389348,16395051,16391154,16395084,16395942,16391541,16393239,16390167,16393635,16394661,16394529,16390080,16391973,16392717,16392714,16394766,16392921,16393832,16393107,16393089,16393373,16393992,16394865,16393347,16393671,16389813,16392414,16391037,16394475,16388547,16391166,16391877,16390251,16392732,16393374,16395561,16394868,16392138,16394034,16393494,16392741,16392999,16394073,16391964,16394166,16395171,16393467,16392654,16392327,16392087,16390547,16392144,16392516,16395369,16393131,16392576,16392194,16393956,16392339,16392336,16392639,16392768,16394076,16389255,16393119,16392317,16390629,16391598,16389027,16393788,16391682,16394613,16394703,16392357,16393122,16391157,16394547,16391562,16394226,16393284,16390959,16394424,16392978,16390011,16394595,16392828,16392827,16393725,16392717,16395705,16395957,16393119,16391139,16393389,16393026,16390275,16392972,16390545,16390911,16392333,16391409,16393158,16392804,16392585,16393725,16393728,16390446,16393572,16393419,16395813,16391622,16392870,16391730,16394517,16392378,16391067,16394028,16391661,16395204,16391565,16393461,16395201,16393692,16390473,16391634,16393980,16393452,16392690,16390812,16391043,16394415,16391241,16392000,16392615,16392801,16395231,16393767,16393158,16392558,16397805,16392654,16395297,16392645,16392381,16392303,16392462,16394028,16391823,16393179,16392066,16392951,16391880,16394277,16393524,16392750,16395405,16392843,16391469,16394505,16392972,16392318,16395627,16393755,16395378,16392747,16390938,16395213,16393347,16393668,16390569,16395228,16389936,16392906,16392939,16391559,16391649,16394300,16390455,16393902,16393491,16391904,16391139,16391148,16395372,16392468,16393350,16392870,16391421,16393092,16390839,16392429,16394301,16394811,16393368,16391588,16394703,16389558,16395224,16392702,16392267,16396506,16392738,16394541,16388037,16392624,16390989,16392306,16390278,16392888,16397325,16394640,16393644,16392711,16392582,16392213,16391052,16390779,16393536,16392003,16391403,16390440,16393095,16393626,16392348,16390278,16392369,16392903,16394523,16392543,16391718,16392282,16393893,16387473,16393014,16393221,16393323,16392093,16391652,16394400,16391853,16393908,16394517,16393473,16391406,16388874,16393002,16391124,16394718,16390671,16393479,16394151,16393872,16392228,16392570,16392303,16395045,16394118,16391265,16392543,16392234,16396287,16392702,16391760,16392186,16391913,16394439,16389446,16395399,16394853,16394894,16393851,16391496,16395273,16394202,16394217,16394337,16391712,16392144,16391748,16393347,16389975,16391319,16393362,16389360,16391346,16393968,16390938,16394538,16393785,16393107,16392930,16393344,16393782,16391673,16393785,16390518,16388844,16394301,16395105,16390395,16390779,16391613,16392006,16392882,16392966,16395945,16394943,16394634,16394400,16392327,16397358,16392939,16394772,16391745,16393413,16392624,16389588,16393320,16391283,16391544,16387977,16390341,16393014,16392846,16394274,16394040,16394427,16390614,16392675,16393461,16393266,16394619,16393164,16389417,16391907,16390248,16390758,16393455,16391628,16394142,16394874,16391007,16393572,16392015,16392972,16391706,16393791,16391892,16395459,16392627,16392498,16391262,16393047,16388484,16391451,16390326,16393917,16390377,16391763,16392723,16391568,16392501,16393743,16392138,16392423,16393815,16391088,16392849,16392516,16390926,16393779,16394049,16391856,16395861,16394921,16395726,16392993,16391055,16392462,16395075,16393944,16393182,16393110,16392090,16389537,16392135,16392744,16391295,16392480,16391784,16392006,16394592,16393107,16391289,16393275,16392465,16393056,16394955,16392981,16392792,16393053,16389429,16389480,16393008,16392255,16393410,16395078,16393971,16395351,16393407,16392420,16392837,16391973,16395363,16396011,16393200,16393614,16393716,16390434,16392279,16392987,16391184,16392885,16394568,16392273,16393104,16392912,16392579,16391055,16390530,16392498,16395480,16393059,16391166,16392294,16391964,16390509,16391103,16394406,16394247,16392789,16393014,16392276,16392726,16392867,16394565,16393917,16396992,16391403,16396389,16393350,16393053,16392039,16392060,16389939,16393020,16391355,16393800,16389306,16392276,16391385,16392306,16394898,16391832,16391898,16394487,16391778,16390014,16394172,16391568,16391991,16392009,16394364,16393212,16393590,16390236,16394961,16392552,16393344,16392321,16390701,16394652,16393731,16391037,16393680,16393248,16395687,16391367,16395150,16391631,16391880,16393839,16393122,16395453,16392587,16391616,16390797,16392546,16391307,16390182,16395237,16393755,16390383,16392066,16391544,16392705,16392441,16391574,16391445,16392108,16390935,16392684,16391247,16393776,16394361,16395918,16392447,16392219,16392984,16392432,16395081,16392984,16393836,16392000,16395534,16393146,16393938,16392501,16391592,16391472,16391127,16391544,16391421,16392033,16394052,16390407,16392839,16390497,16393713,16391403,16392735,16393065,16392213,16395027,16395336,16394126,16391487,16394067,16391985,16395279,16391934,16392870,16391691,16394067,16391889,16393428,16395297,16388915,16394199,16392795,16392927,16395309,16394727,16393968,16392690,16390032,16391430,16393107,16392630,16391268,16393644,16392012,16391937,16393428,16392933,16393221,16393539,16393872,16394088,16391646,16392540,16392848,16390887,16392807,16391295,16389660,16392657,16393425,16390344,16394151,16395369,16392786,16395789,16394052,16393119,16392660,16393685,16393905,16391121,16391448,16391700,16395120,16393179,16391205,16390074,16391457,16395324,16390965,16392285,16395099,16393140,16391102,16390680,16394022,16395303,16393470,16392945,16389252,16393290,16391256,16393035,16393053,16389642,16393839,16391052,16392432,16394600,16392777,16390659,16393026,16391145,16394712,16392576,16392906,16389723,16395357,16391253,16393524,16395435,16391124,16393443,16390164,16391796,16392882,16395546,16394439,16395195,16391775,16391262,16391853,16393941,16394352,16393788,16391276,16391424,16393344,16391040,16391484,16390869,16392000,16394670,16394268,16392279,16393875,16394286,16392816,16392537,16392471,16394121,16394385,16392108,16392039,16392210,16394517,16394547,16394610,16392642,16393596,16392486,16393791,16389680,16391733,16391424,16394136,16393251,16391736,16392207,16388838,16391865,16392666,16390791,16392177,16389936,16392435,16393704,16390647,16392000,16394220,16394441,16392201,16396842,16391265,16394382,16394010,16391090,16392672,16392708,16392456,16392693,16392183,16394691,16393218,16393710,16393275,16394706,16392777,16393230,16391679,16393197,16392258,16391667,16392648,16394325,16390695,16392003,16392705,16391937,16393278,16390236,16393374,16393557,16393368,16392210,16392642,16392969,16390941,16393644,16393260,16394415,16395495,16391825,16395243,16390428,16392207,16391667,16393692,16393434,16393395,16392855,16391405,16392585,16391880,16393965,16393476,16393551,16395732,16391319,16388595,16391883,16391775,16392351,16393088,16389435,16393425,16391691,16394343,16392336,16393101,16393896,16390530,16393974,16393230,16393899,16392366,16393284,16394115,16391856,16396884,16393695,16395465,16394904,16394160,16393134,16394157,16394106,16390185,16391997,16392399,16393167,16391217,16392603,16388691,16391361,16390068,16391919,16393530,16394565,16391511,16391256,16394322,16391439,16393353,16394835,16392708,16390788,16390944,16392036,16393086,16395006,16392717,16393698,16394982,16391153,16397730,16394622,16395183,16390779,16391613,16392279,16394292,16392132,16392291,16392765,16392138,16391010,16392030,16391256,16396002,16393521,16392891,16394717,16393497,16390707,16389771,16391265,16392252,16393161,16393554,16392243,16393449,16390824,16390413,16394352,16392024,16393710,16395411,16393431,16393050,16393431,16392234,16394238,16393464,16392456,16393086,16393845,16392969,16392675,16391337,16392984,16393578,16388970,16395294,16391859,16391346,16392828,16390083,16391541,16392813,16389819,16392735,16391223,16394682,16393998,16393506,16390917,16393524,16396347,16392573,16396293,16394619,16393137,16393353,16393050,16393551,16394250,16393245,16392306,16392399,16392447,16392552,16394622,16391685,16392288,16390161,16390617,16393647,16394565,16393707,16389357,16390227,16394370,16393047,16393710,16392498,16394553,16395113,16390275,16392195,16392750,16393473,16393101,16392552,16392840,16392348,16394184,16389861,16392693,16392045,16393545,16392234,16392033,16392180,16394670,16391700,16394823,16391400,16392804,16392492,16394712,16393386,16394307,16391571,16391406,16389321,16393671,16391484,16394253,16393305,16395549,16394382,16392978,16391001,16388247,16392630,16392327,16391922,16394001,16394124,16394472,16390740,16390974,16396512,16393068,16393569,16393671,16393140,16390047,16392171,16391544,16395360,16391988,16390956,16392318,16391094,16392219,16390440,16392528,16394193,16391136,16389732,16392759,16392416,16393419,16390173,16391043,16392705,16392777,16395102,16393467,16391985,16392021,16393035,16394064,16388994,16393563,16393440,16393467,16393965,16389306,16393070,16393314,16393935,16392731,16394235,16392150,16391274,16392897,16394703,16392207,16393323,16391844,16393152,16392237,16390794,16391961,16394805,16394211,16392342,16391523,16392933,16391958,16396287,16392048,16393388,16393020,16391712,16394682,16391136,16392321,16392321,16393326,16392546,16389645,16393128,16394844,16394010,16391724,16392309,16392597,16392561,16392729,16393590,16393983,16391103,16392954,16393938,16391904,16391952,16390056,16394067,16393431,16395087,16394241,16393809,16391604,16392597,16392771,16391346,16393731,16395417,16390443,16392912,16394547,16392438,16393821,16388436,16391154,16391616,16394049,16392897,16391145,16395120,16391124,16393278,16393995,16395150,16395357,16395471,16393218,16394136,16389198,16390920,16391598,16390854,16392933,16391718,16391328,16390911,16392270,16391045,16393332,16393080,16394580,16393764,16390998,16391055,16394421,16389906,16391783,16394109,16391559,16393407,16391697,16390440,16391925,16392582,16391685,16392909,16392519,16395117,16394439,16394016,16394430,16390872,16396116,16392543,16393149,16391946,16391352,16391898,16390482,16394739,16392228,16390572,16393350,16390251,16395873,16393359,16393857,16393359,16391589,16392084,16393494,16395129,16391744,16394310,16393101,16390482,16391622,16392897,16391679,16393710,16390851,16391306,16394199,16392699,16393634,16395267,16393038,16388303,16396845,16395777,16394451,16394673,16391745,16392843,16391493,16388760,16392014,16393629,16394394,16393812,16393128,16392135,16390791,16391073,16392660,16393815,16391529,16391220,16393056,16392606,16394526,16393278,16392084,16393374,16393425,16395537,16393791,16393404,16391514,16392318,16392189,16393548,16392783,16393674,16392507,16392243,16393335,16395303,16392624,16393157,16392267,16394091,16391925,16391994,16394220,16392861,16394178,16390830,16395459,16391334,16392981,16392705,16392465,16389561,16392317,16389747,16393344,16393779,16393050,16389078,16393145,16394778,16392096] print(answer[A%3333])