#include <bits/stdc++.h>
using namespace std;
vector<int> v = {2021,420211,1240211,2007321,2021143,2022314,2026140,2029841,2047221,2065521,2084212,2102915,2207281,2330212,2470121,2601213,2702212,2802951,2907921,3209521,4202571,5120421,5521021,6260021,7206921,8202193,8927021,9362021,10234021,11204210,12002214,12020261,12021863,12025131,12028813,12042197,12062151,12082105,12101213,12202212,12302951,12407921,12530221,12670216,12801231,12902221,13202515,14120219,14520271,15250921,16206261,17202183,17920621,18323021,19230321,20007121,20021123,20022213,20026120,20029731,20046321,20065210,20083221,20102814,20120861,20121977,20125416,20129161,20142771,20162517,20182301,20200319,20201877,20205145,20208891,20210709,20211709,20212709,20213709,20214709,20215709,20216709,20217709,20218709,20219709,20221438,20223419,20227164,20230991,20231999,20235519,20239183,20241560,20244091,20247619,20251121,20252211,20256118,20259719,20261682,20264311,20268137,20271243,20272819,20276411,20280156,20281804,20284919,20288511,20291365,20293175,20297019,20302312,20320341,20321880,20325148,20328911,20342251,20362168,20382122,20401521,20420014,20421734,20424571,20428189,20441241,20459721,20478214,20496261,20514921,20521588,20524127,20527801,20536216,20554281,20573121,20592731,20612513,20621442,20623451,20627168,20632713,20652461,20672216,20692161,20712115,20721296,20723106,20726681,20732153,20752107,20771215,20789271,20808021,20821150,20822331,20826147,20829910,20847291,20866201,20884219,20902941,20921004,20922013,20925561,20929188,20942914,20962671,20982417,21002201,21020219,21021858,21025126,21028791,21042192,21062146,21082100,21101121,21202198,21302918,21407421,21530215,21670211,21801216,21902215,22002981,22021008,22022017,22025601,22029192,22042918,22062710,22082431,22102213,22202961,22308021,22430231,22570217,22701241,22802231,22903211,23008215,23021158,23022410,23026155,23029918,23048021,23066217,23084291,23103201,23208213,23330291,23470251,23601321,23702291,23803217,23908231,24012127,24021308,24023118,24026719,24032165,24052119,24071291,24090201,24108219,24230821,24370421,24501921,24602314,24703251,24808291,24937021,25012610,25021458,25023521,25027184,25032810,25052531,25072313,25092177,25135021,25271021,25402014,25502321,25603421,25708821,25840210,25979021,26015281,26021608,26024147,26027910,26037121,26055218,26073321,26092841,26177021,26302021,26402381,26504021,26609211,26740216,26880212,27002100,27020110,27021758,27024711,27028241,27042021,27060321,27079210,27097221,27202081,27302413,27404213,27509217,27640241,27780218,27902106,28002431,28020512,28021908,28025176,28029021,28042413,28062196,28082150,28102104,28202419,28304219,28409251,28540321,28680261,28802112,28902491,29004291,29021058,29022139,29025831,29029413,29044219,29062941,29082714,29102471,29204271,29309421,29440921,29580521,29702118,29802514,29904821,30206421,31202188,31922021,32017521,32021668,32024216,32028123,32039212,32057241,32075721,32094214,32190291,32302152,32402710,32506211,32619021,32755021,32891021,33201241,33720121,34271021,35209215,36202510,37120214,37520221,38250421,39206219,40202178,40920281,41320721,42012216,42021388,42023198,42027114,42032416,42052199,42072153,42092107,42119021,42255021,42391021,42502160,42602718,42706219,42820214,42960210,43270271,44208821,45202419,46092021,46520210,47250219,48206201,49202168,49920216,50320241,51230213,52006231,52021108,52022189,52026105,52029671,52046213,52064251,52082981,52102718,52206219,52320214,52460210,52599021,52702168,52802781,52906291,53208251,54202401,55026021,55452021,56250201,57205291,58202158,58912021,59320212,60226021,61202961,62002170,62020180,62021828,62025061,62028616,62042162,62062116,62081261,62099921,62202168,62302781,62406291,62520241,62660218,62800214,62902176,63202318,64020521,64422021,65242021,66205217,67202148,67828021,68297021,69220521,70202914,71201241,71720121,72013241,72021548,72024015,72027581,72034721,72053214,72072791,72092519,72160218,72300214,72402176,72502815,72607021,72720521,72860281,73020221,73420281,74240281,75205021,76202138,76820721,77290621,78220221,79202851,80201212,80632021,81270271,82012015,82021268,82022971,82026517,82032125,82051821,82070215,82088271,82107021,82220521,82360281,82500241,82602184,82702851,82807215,82924021,83240216,84204271,85202128,85820241,86290231,87220210,88202813,89200521,89620921,90270215,91208251,92002871,92020916,92021988,92025491,92029172,92042817,92062601,92082321,92102184,92202851,92307215,92424021,92560921,92700521,92802192,92902912,93204215,94202118,94820212,95290211,96213021,97202741,98200221,98620261,99268021,100208213,101202318,102000721,102019214,102021708,102024418,102028163,102040261,102058921,102077216,102095281,102200521,102302192,102402912,102507251,102630201,102768021,102901210,103202108,103772021,104284021,105210291,106202712,107200210,107620214,108260721,109207621,110202291,111020221,111420281,112012418,112021428,112023401,112027154,112032618,112052410,112072193,112092147,112130201,112268021,112401210,112502201,112602921,112707621,112830217,112970213,113280321,114210217,115202631,116132021,116592021,117260241,118207231,119202217,120000212,120018241,120021688,120024317,120028143,120039721,120058214,120076261,120094921,120113216,120121542,120124001,120127521,120134281,120153121,120172731,120192513,120201442,120203451,120207168,120210274,120211274,120212274,120213274,120214274,120215274,120216274,120217274,120218274,120219274,120221003,120222012,120225551,120229187,120231564,120234103,120237651,120241125,120242215,120246122,120249751,120251686,120254315,120258141,120261247,120262851,120266415,120270160,120271808,120274951,120278515,120281369,120283179,120287051,120290615,120291930,120295198,120299114,120312516,120321445,120323481,120327171,120332716,120352491,120372219,120392164,120412118,120421299,120423109,120426710,120432156,120452110,120471218,120489321,120508210,120521153,120522361,120526150,120529913,120547521,120566212,120584241,120602971,120621007,120622016,120625591,120629191,120642917,120662701,120682421,120702212,120720241,120721861,120725129,120728811,120742195,120762149,120782103,120801211,120819231,120821715,120824471,120828170,120840621,120859213,120877251,120895821,120914215,120921569,120924108,120927701,120935271,120954021,120972910,120992631,121012413,121021423,121023351,121027149,121032613,121052361,121072188,121092142,121127021,121263021,121400821,121502195,121602915,121707281,121830212,121970121,122014219,122021573,122024112,122027713,122035421,122054211,122072914,122092671,122169021,122301211,122402210,122502931,122607721,122730218,122870214,123001219,123019421,123021723,123024514,123028178,123041211,123059231,123077621,123096213,123201217,123302216,123402991,123508210,123630261,123770221,123901271,124002261,124020315,124021873,124025141,124028851,124042216,124062161,124082115,124101251,124202241,124303212,124408216,124530521,124670281,124801621,124902311,125003221,125021023,125022104,125025661,125029216,125043212,125062771,125082517,125102301,125203218,125308241,125432021,125570721,125702011,125802317,125903281,126008521,126021173,126022471,126026170,126030212,126048241,126066721,126085214,126103261,126208321,126338021,126474021,126602017,126702351,126803721,126909121,127012142,127021323,127023133,127026815,127032180,127052134,127072016,127090261,127108921,127240211,127380021,127502051,127602410,127704210,127809214,127940219,128012671,128021473,128023616,128027199,128032871,128052617,128072401,128092192,128140217,128280213,128402101,128502416,128604216,128709221,128840271,128980231,129016213,129021623,129024162,129027971,129037251,129055821,129074215,129092918,129180219,129302107,129402441,129504241,129609281,129740621,129880291,130182021,130620201,131260291,132010921,132021233,132022801,132026321,132032018,132050281,132069121,132087218,132105321,132210721,132350321,132490261,132602149,132702681,132806121,132916021,133230218,134203218,135202031,135720821,136280251,137210212,138202616,139125021,139542021,140260217,141207216,142002701,142020719,142021953,142025311,142029137,142042621,142062412,142082195,142102149,142202681,142306121,142416021,142552021,142690721,142802157,142902715,143203121,144202011,144720251,145280213,146209521,147202571,148120421,148521021,149260021,150206921,151202193,151927021,152018021,152021673,152024231,152028128,152039217,152057291,152076201,152094219,152190721,152302157,152402715,152506216,152620211,152760021,152896021,153201291,153720213,154276021,155209221,156202515,157120219,157520271,158250921,159206261,160202183,160920621,161323021,162012231,162021393,162023212,162027119,162032431,162052213,162072158,162092112,162120211,162260021,162396021,162502165,162602751,162706261,162820219,162960215,163270521,164209210,165202461,166120201,166520215,167250261,168206214,169202173,169920231,170320291,171230218,172006281,172021113,172022194,172026110,172029711,172046218,172064321,172083210,172102751,172206261,172320219,172460215,172600211,172702173,172802812,172906721,173208321,174202414,175042021,175502021,176250214,177205721,178202163,178920211,179320217,180230121,181203121,182002175,182020185,182021833,182025101,182028631,182042167,182062121,182081421,182100211,182202173,182302812,182406721,182520291,182660251,182800219,182902181,183202351,184021021,184427021,185247021,186205241,187202153,187862021,188320021,189221021,190202919,191201291,191720213,192013291,192021553,192024021,192027612,192035201,192053219,192072813,192092561,192160251,192300219,192402181,192502821,192607212,192721021,192860621,193020271,193420621,194240621,195205212,196202143};
int main() {
int n; cin >> n;
long long count = floor(n/1000) * 1000;
for (long long i = v[floor(n/1000)]; true; i++) {
string s = to_string(i);
vector<char> q = {'1','2','0','2'};
for (auto c : s) if (c == q.back()) q.pop_back();
if (q.empty()) count++;
if (count == n) {
cout << s;
break;
}
}
}