#include <bits/stdc++.h>
using namespace std;
vector<int> v = {2021,12021,20021,20121,20201,20210,20211,20212,20213,20214,20215,20216,20217,20218,20219,20221,20231,20241,20251,20261,20271,20281,20291,20321,20421,20521,20621,20721,20821,20921,21021,22021,23021,24021,25021,26021,27021,28021,29021,32021,42021,52021,62021,72021,82021,92021,102021,112021,120021,120121,120201,120210,120211,120212,120213,120214,120215,120216,120217,120218,120219,120221,120231,120241,120251,120261,120271,120281,120291,120321,120421,120521,120621,120721,120821,120921,121021,122021,123021,124021,125021,126021,127021,128021,129021,132021,142021,152021,162021,172021,182021,192021,200021,200121,200201,200210,200211,200212,200213,200214,200215,200216,200217,200218,200219,200221,200231,200241,200251,200261,200271,200281,200291,200321,200421,200521,200621,200721,200821,200921,201021,201121,201201,201210,201211,201212,201213,201214,201215,201216,201217,201218,201219,201221,201231,201241,201251,201261,201271,201281,201291,201321,201421,201521,201621,201721,201821,201921,202001,202010,202011,202012,202013,202014,202015,202016,202017,202018,202019,202021,202031,202041,202051,202061,202071,202081,202091,202100,202101,202102,202103,202104,202105,202106,202107,202108,202109,202110,202111,202112,202113,202114,202115,202116,202117,202118,202119,202120,202121,202122,202123,202124,202125,202126,202127,202128,202129,202130,202131,202132,202133,202134,202135,202136,202137,202138,202139,202140,202141,202142,202143,202144,202145,202146,202147,202148,202149,202150,202151,202152,202153,202154,202155,202156,202157,202158,202159,202160,202161,202162,202163,202164,202165,202166,202167,202168,202169,202170,202171,202172,202173,202174,202175,202176,202177,202178,202179,202180,202181,202182,202183,202184,202185,202186,202187,202188,202189,202190,202191,202192,202193,202194,202195,202196,202197,202198,202199,202201,202210,202211,202212,202213,202214,202215,202216,202217,202218,202219,202221,202231,202241,202251,202261,202271,202281,202291,202301,202310,202311,202312,202313,202314,202315,202316,202317,202318,202319,202321,202331,202341,202351,202361,202371,202381,202391,202401,202410,202411,202412,202413,202414,202415,202416,202417,202418,202419,202421,202431,202441,202451,202461,202471,202481,202491,202501,202510,202511,202512,202513,202514,202515,202516,202517,202518,202519,202521,202531,202541,202551,202561,202571,202581,202591,202601,202610,202611,202612,202613,202614,202615,202616,202617,202618,202619,202621,202631,202641,202651,202661,202671,202681,202691,202701,202710,202711,202712,202713,202714,202715,202716,202717,202718,202719,202721,202731,202741,202751,202761,202771,202781,202791,202801,202810,202811,202812,202813,202814,202815,202816,202817,202818,202819,202821,202831,202841,202851,202861,202871,202881,202891,202901,202910,202911,202912,202913,202914,202915,202916,202917,202918,202919,202921,202931,202941,202951,202961,202971,202981,202991,203021,203121,203201,203210,203211,203212,203213,203214,203215,203216,203217,203218,203219,203221,203231,203241,203251,203261,203271,203281,203291,203321,203421,203521,203621,203721,203821,203921,204021,204121,204201,204210,204211,204212,204213,204214,204215,204216,204217,204218,204219,204221,204231,204241,204251,204261,204271,204281,204291,204321,204421,204521,204621,204721,204821,204921,205021,205121,205201,205210,205211,205212,205213,205214,205215,205216,205217,205218,205219,205221,205231,205241,205251,205261,205271,205281,205291,205321,205421,205521,205621,205721,205821,205921,206021,206121,206201,206210,206211,206212,206213,206214,206215,206216,206217,206218,206219,206221,206231,206241,206251,206261,206271,206281,206291,206321,206421,206521,206621,206721,206821,206921,207021,207121,207201,207210,207211,207212,207213,207214,207215,207216,207217,207218,207219,207221,207231,207241,207251,207261,207271,207281,207291,207321,207421,207521,207621,207721,207821,207921,208021,208121,208201,208210,208211,208212,208213,208214,208215,208216,208217,208218,208219,208221,208231,208241,208251,208261,208271,208281,208291,208321,208421,208521,208621,208721,208821,208921,209021,209121,209201,209210,209211,209212,209213,209214,209215,209216,209217,209218,209219,209221,209231,209241,209251,209261,209271,209281,209291,209321,209421,209521,209621,209721,209821,209921,210021,210121,210201,210210,210211,210212,210213,210214,210215,210216,210217,210218,210219,210221,210231,210241,210251,210261,210271,210281,210291,210321,210421,210521,210621,210721,210821,210921,211021,212021,213021,214021,215021,216021,217021,218021,219021,220021,220121,220201,220210,220211,220212,220213,220214,220215,220216,220217,220218,220219,220221,220231,220241,220251,220261,220271,220281,220291,220321,220421,220521,220621,220721,220821,220921,221021,222021,223021,224021,225021,226021,227021,228021,229021,230021,230121,230201,230210,230211,230212,230213,230214,230215,230216,230217,230218,230219,230221,230231,230241,230251,230261,230271,230281,230291,230321,230421,230521,230621,230721,230821,230921,231021,232021,233021,234021,235021,236021,237021,238021,239021,240021,240121,240201,240210,240211,240212,240213,240214,240215,240216,240217,240218,240219,240221,240231,240241,240251,240261,240271,240281,240291,240321,240421,240521,240621,240721,240821,240921,241021,242021,243021,244021,245021,246021,247021,248021,249021,250021,250121,250201,250210,250211,250212,250213,250214,250215,250216,250217,250218,250219,250221,250231,250241,250251,250261,250271,250281,250291,250321,250421,250521,250621,250721,250821,250921,251021,252021,253021,254021,255021,256021,257021,258021,259021,260021,260121,260201,260210,260211,260212,260213,260214,260215,260216,260217,260218,260219,260221,260231,260241,260251,260261,260271,260281,260291,260321,260421,260521,260621,260721,260821,260921,261021,262021,263021,264021,265021,266021,267021,268021,269021,270021,270121,270201,270210,270211,270212,270213,270214,270215,270216,270217,270218,270219,270221,270231,270241,270251,270261,270271,270281,270291,270321,270421,270521,270621,270721,270821,270921,271021,272021,273021,274021,275021,276021,277021,278021,279021,280021,280121,280201,280210,280211,280212,280213,280214,280215,280216,280217,280218,280219,280221,280231,280241,280251,280261,280271,280281,280291,280321,280421,280521,280621,280721,280821,280921,281021,282021,283021,284021,285021,286021,287021,288021,289021,290021,290121,290201,290210,290211,290212,290213,290214,290215,290216,290217,290218,290219,290221,290231,290241,290251,290261,290271,290281,290291,290321,290421,290521,290621,290721,290821,290921,291021,292021,293021,294021,295021,296021,297021,298021,299021,302021,312021,320021,320121,320201,320210,320211,320212,320213,320214,320215,320216,320217,320218,320219,320221,320231,320241,320251,320261,320271,320281,320291,320321,320421,320521,320621,320721,320821,320921,321021,322021,323021,324021,325021,326021,327021,328021,329021,332021,342021,352021,362021,372021,382021,392021,402021,412021,420021,420121,420201,420210,420211,420212,420213,420214,420215,420216,420217,420218,420219,420221,420231,420241,420251,420261,420271,420281,420291,420321,420421,420521,420621,420721,420821,420921,421021,422021,423021,424021,425021,426021,427021,428021,429021,432021,442021,452021,462021,472021,482021,492021,502021,512021,520021,520121,520201,520210,520211,520212,520213,520214,520215,520216,520217,520218,520219,520221,520231,520241,520251,520261,520271,520281,520291,520321,520421,520521,520621,520721,520821,520921,521021,522021,523021,524021,525021,526021,527021,528021,529021,532021,542021,552021,562021,572021,582021,592021,602021,612021,620021,620121,620201,620210,620211,620212,620213,620214,620215,620216,620217,620218,620219,620221,620231,620241,620251,620261,620271,620281,620291,620321,620421,620521,620621,620721,620821,620921,621021,622021,623021,624021,625021,626021,627021,628021,629021,632021,642021,652021,662021,672021,682021,692021,702021,712021,720021,720121,720201,720210,720211,720212,720213,720214,720215,720216,720217,720218,720219,720221,720231,720241,720251,720261,720271,720281,720291,720321,720421,720521,720621,720721,720821,720921,721021,722021,723021,724021,725021,726021,727021,728021,729021,732021,742021,752021,762021,772021,782021,792021,802021,812021,820021,820121,820201,820210,820211,820212,820213,820214,820215,820216,820217,820218,820219,820221,820231,820241,820251,820261,820271,820281,820291,820321,820421,820521,820621,820721,820821,820921,821021,822021,823021,824021,825021,826021,827021,828021,829021,832021,842021,852021,862021,872021,882021,892021,902021,912021,920021,920121,920201,920210,920211,920212,920213,920214,920215,920216,920217,920218,920219,920221,920231,920241,920251,920261,920271,920281,920291,920321,920421,920521,920621,920721,920821,920921,921021,922021,923021,924021,925021,926021,927021,928021,929021,932021,942021,952021,962021,972021,982021,992021};
int main() {
int n; cin >> n;
cout << v[n-1] << "\n";
}