//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

vi runrun_hundred = {
    1, 887, 4454, 8789, 21123, 33323, 45443, 56777, 76676, 88889, 110112, 123210, 221123, 233323, 323321, 343212, 432333, 444445, 456565, 545677, 565567, 655544, 667656, 765433, 776776, 788998, 887766, 987778, 1001100, 1101112, 1122112, 1212234, 1232233, 2110000, 2122321, 2221011, 2233212, 2323210, 2334545, 3210123, 3223221, 3234556, 3332333, 3344445, 3434344, 3445678, 4321223, 4333345, 4345543, 4443212, 4454554, 4544444, 4556556, 4567898, 5443432, 5455544, 5545434, 5556776, 5654445, 5666565, 5678765, 6545676, 6565566, 6655543, 6667655, 6765432, 6776767, 6788989, 7665443, 7676778, 7766776, 7778898, 7877667, 7889988, 8767677, 8787676, 8877876, 8898876, 8998888, 9887665, 9987677, 10000122, 10101010, 10121232, 11010112, 11111000, 11123222, 11221221, 11233343, 12111210, 12123345, 12222123, 12234322, 12323456, 12343433, 21010011, 21110110, 21122344, 21221121, 21233321, 22111110, 22123323, 22222101, 22233444, 22323434, 22343333, 23211232, 23223445, 23321221, 23333343, 23345455, 23443210, 23454544, 32110011, 32122332, 32221101, 32233223, 32323221, 32334556, 33211010, 33223232, 33234567, 33332344, 33344456, 33434433, 33454323, 34321234, 34333434, 34345554, 34443223, 34454565, 34544455, 34556567, 43210001, 43222322, 43234443, 43332212, 43344332, 43433445, 43445565, 44321110, 44333232, 44344566, 44434543, 44454433, 44544323, 44555665, 44567777, 45443233, 45454567, 45544543, 45556655, 45654332, 45665666, 45677787, 54323433, 54343332, 54433223, 54444565, 54456677, 54554345, 54566543, 55433443, 55445555, 55543223, 55554565, 55566677, 55656654, 55676545, 56544321, 56555655, 56567767, 56665444, 56676787, 56766777, 56778899, 65433233, 65444567, 65456765, 65554433, 65566545, 65655666, 65667778, 66543333, 66555445, 66566787, 66656678, 66676655, 66766567, 66778767, 67654544, 67666656, 67678778, 67776554, 67788767, 67878889, 67899988, 76554454, 76566566, 76656543, 76667877, 76765654, 76777767, 77654323, 77665665, 77677778, 77767776, 77787767, 77877889, 77898889, 78767899, 78787898, 78878877, 78899889, 78999988, 87665565, 87677678, 87767676, 87787667, 87877789, 87898789, 88767877, 88787876, 88878777, 88898999, 88999887, 89887787, 89987877, 98765667, 98777788, 98876566, 98888787, 98988877, 99877777, 99898777, 99998789, 100012111, 100112123, 101000101, 101100121, 101121211, 101212112, 101232111, 110001121, 110101211, 110122211, 111011111, 111111123, 111123344, 111222122, 111234321, 112112111, 112210010, 112222323, 112234444, 112332221, 112344333, 121011010, 121111101, 121123322, 121222100, 121233443, 122111232, 122123445, 122222223, 122234344, 122332121, 122343455, 123212211, 123232210, 123322122, 123334321, 123345655, 123443332, 123455444, 210011010, 210111101, 210123322, 211012223, 211112321, 211211011, 211223233, 212100000, 212121012, 212211221, 212223434, 212321210, 212333332, 212345444, 221012123, 221112221, 221210121, 221223211, 221234554, 222112344, 222211121, 222223334, 222321110, 222333232, 222344566, 223221121, 223233321, 223323233, 223343210, 223432323, 223444443, 223456555, 232112123, 232210101, 232222343, 232234456, 232332233, 232344345, 233212323, 233232322, 233322234, 233334433, 233432110, 233443444, 233455556, 234323332, 234343223, 234432344, 234444456, 234456654, 234554322, 234565656, 321010100, 321110112, 321123210, 321221123, 321233323, 322111112, 322123333, 322222111, 322233454, 322323444, 322343343, 323211234, 323223455, 323321223, 323333345, 323345543, 323443212, 323454554, 332110100, 332122334, 332221111, 332233233, 332323223, 332334566, 333211012, 333223234, 333321001, 333333210, 333344544, 333434443, 333454333, 334322101, 334333444, 334345556, 334443233, 334454567, 334544543, 334556655, 343210011, 343222332, 343234445, 343332222, 343344334, 343433455, 343445567, 344321112, 344333234, 344345432, 344434545, 344454443, 344544333, 344555667, 344567787, 345443321, 345455433, 345544545, 345556665, 345654334, 345665676, 345677789, 432111234, 432123455, 432222233, 432234432, 432332123, 432344321, 433212221, 433232212, 433322210, 433334323, 433345665, 433443334, 433455454, 434323222, 434334565, 434432234, 434444432, 434456544, 434545656, 434565554, 443211232, 443223445, 443321221, 443333343, 443345455, 443443210, 443454544, 444322234, 444334433, 444432110, 444443444, 444455556, 444545454, 444556788, 445432322, 445444434, 445456554, 445545666, 445565556, 445655455, 445666789, 445678998, 454332343, 454344455, 454434432, 454454322, 454543434, 454555554, 454567666, 455434566, 455454456, 455544432, 455556544, 455567878, 455665555, 455677676, 456545444, 456556778, 456654455, 456666567, 456678767, 456776543, 456787899, 543221011, 543233212, 543323210, 543334545, 543432222, 543444334, 543455676, 544323444, 544343343, 544433234, 544445432, 544456766, 544554434, 544566554, 545433454, 545445566, 545543234, 545555432, 545566766, 545656665, 545676556, 554322210, 554334323, 554345665, 554443334, 554455454, 554544566, 554556678, 555432212, 555444332, 555455666, 555545556, 555565454, 555654567, 555666765, 555678887, 556554432, 556566544, 556655665, 556667777, 556765554, 556777667, 556789988, 565443344, 565455456, 565545432, 565556766, 565654443, 565666555, 565677898, 566545666, 566565556, 566655455, 566666789, 566678998, 566776765, 566788987, 567665433, 567676776, 567766766, 567778888, 567877665, 567889899, 654323323, 654343222, 654432343, 654444455, 654456567, 654554321, 654565655, 655433333, 655445445, 655456787, 655554455, 655566567, 655656544, 655667878, 656543433, 656555545, 656567665, 656656778, 656676677, 656766667, 656778789, 665432345, 665444543, 665456655, 665554323, 665565665, 665655556, 665667676, 666543223, 666554565, 666566677, 666656654, 666676545, 666766543, 666777878, 667654434, 667666554, 667677889, 667767887, 667787878, 667878787, 667899877, 676554344, 676565678, 676655655, 676667767, 676765544, 676777665, 676789899, 677665555, 677677676, 677767666, 677787665, 677877787, 677898787, 678767789, 678787788, 678878767, 678898989, 678999877, 765443234, 765455432, 765544544, 765556656, 765654333, 765665667, 765677788, 766545556, 766565454, 766654567, 766666765, 766678887, 766776655, 766788876, 767656767, 767676666, 767766656, 767778778, 767876777, 767888999, 776544565, 776556677, 776654432, 776666544, 776677887, 776767877, 776787876, 777656554, 777667888, 777765665, 777777778, 777876556, 777888777, 778766566, 778778766, 778876765, 778888987, 778988999, 787655676, 787667788, 787765565, 787777678, 787789999, 787887898, 788766544, 788777887, 788876665, 788888878, 788988898, 789877876, 789898876, 789998888, 876545676, 876565566, 876655543, 876667655, 876765432, 876776767, 876788989, 877665443, 877676778, 877766776, 877778898, 877877667, 877889988, 878767677, 878787676, 878877876, 878898876, 878998888, 887656787, 887676678, 887766676, 887778876, 887876789, 887889887, 888767655, 888787654, 888877776, 888898776, 888998788, 889878989, 889987655, 898765445, 898776788, 898789878, 898887778, 898987876, 899876777, 899888999, 899989887, 987656544, 987667878, 987765655, 987777776, 987876554, 987888767, 988766556, 988777899, 988876677, 988888898, 988988989, 989877888, 989898888, 989998987, 998776545, 998788766, 998878888, 998899987, 998999999, 999887898, 999988767, 1000001232, 1000110001, 1000122322, 1001011222, 1001111234, 1001123455, 1001222233, 1001234432, 1010012222, 1010112234, 1011001010, 1011101101, 1011122101, 1011212223, 1011232222, 1012101232, 1012122232, 1012221000, 1012232345, 1012322343, 1012334456, 1100000112, 1100101000, 1100121222, 1101010110, 1101110122, 1101123212, 1101221211, 1101233333, 1110011122, 1110111212, 1110123433, 1111012334, 1111121000, 1111211123, 1111223344, 1112100112, 1112121210, 1112212111, 1112232110, 1112322100, 1112333443, 1112345555, 1121012234, 1121112332, 1121211101, 1121223322, 1122100011, 1122121110, 1122211232, 1122223445, 1122321221, 1122333343, 1122345455, 1123221232, 1123233432, 1123323344, 1123343321, 1123433212, 1123444554, 1123456666, 1210012234, 1210112332, 1211001101, 1211101121, 1211122121, 1211212321, 1211232234, 1212110001, 1212122322, 1212221012, 1212233221, 1212323211, 1212334554, 1221001000, 1221101012, 1221121234, 1221212221, 1221232212, 1222101222, 1222122222, 1222212344, 1222232343, 1222322333, 1222334454, 1223210110, 1223222344, 1223234543, 1223332234, 1223344432, 1223434323, 1223445665, 1232101000, 1232121222, 1232212123, 1232232122, 1232322112, 1232333455, 1232345567, 1233222123, 1233234322, 1233323456, 1233343433, 1233433332, 1233445444, 1233456778, 1234332333, 1234344445, 1234434344, 1234445678, 1234543432, 1234555544, 1234567656, 2100012122, 2100112212, 2101000112, 2101101000, 2101121222, 2101212123, 2101232122, 2110001210, 2110101222, 2110122222, 2111011122, 2111111212, 2111123433, 2111222211, 2111234332, 2112112122, 2112210100, 2112222334, 2112234455, 2112332232, 2112344344, 2121011100, 2121111112, 2121123333, 2121222111, 2121233454, 2122112100, 2122123456, 2122222234, 2122234433, 2122332210, 2122344322, 2123212222, 2123232221, 2123322211, 2123334332, 2123345666, 2123443343, 2123455455, 2210011100, 2210111112, 2210123333, 2211012234, 2211112332, 2211211101, 2211223322, 2212100011, 2212121110, 2212211232, 2212223445, 2212321221, 2212333343, 2212345455, 2221012212, 2221112232, 2221211000, 2221223222, 2221234565, 2222121001, 2222211210, 2222223345, 2222321121, 2222333321, 2222345433, 2223221210, 2223233332, 2223323322, 2223343221, 2223432334, 2223444454, 2223456566, 2232112212, 2232210112, 2232223210, 2232234545, 2232332322, 2232344434, 2233212334, 2233232333, 2233322323, 2233334444, 2233432121, 2233443455, 2233455567, 2234323343, 2234343234, 2234433211, 2234444545, 2234456665, 2234554333, 2234565667, 2321010111, 2321110123, 2321123221, 2321221212, 2321233334, 2322111123, 2322123344, 2322222122, 2322234321, 2322323455, 2322343432, 2323212110, 2323232101, 2323321234, 2323333434, 2323345554, 2323443223, 2323454565, 2332110111, 2332122345, 2332221122, 2332233322, 2332323234, 2332343211, 2333211110, 2333223323, 2333321012, 2333333221, 2333344555, 2333434454, 2333454344, 2334322112, 2334333455, 2334345567, 2334443322, 2334455434, 2334544554, 2334556666, 2343210101, 2343222343, 2343234456, 2343332233, 2343344345, 2343434322, 2343445656, 2344321123, 2344333323, 2344345443, 2344434556, 2344454454, 2344544344, 2344555678, 2344567876, 2345443332, 2345455444, 2345544556, 2345556676, 2345654345, 2345666543, 2345677878, 3210012110, 3210112122, 3211000100, 3211100112, 3211121210, 3211212111, 3211232110, 3212101112, 3212122112, 3212212234, 3212232233, 3212322223, 3212334344, 3212345678, 3221100011, 3221121110, 3221211232, 3221223445, 3222101011, 3222121233, 3222212212, 3222232211, 3222322123, 3222334322, 3222345656, 3223222212, 3223234333, 3223332110, 3223343444, 3223433343, 3223445455, 3223456789, 3232121011, 3232211212, 3232223433, 3232321123, 3232333323, 3232345443, 3233221212, 3233233334, 3233323332, 3233343223, 3233432344, 3233444456, 3233456654, 3234332123, 3234344321, 3234433434, 3234445554, 3234543222, 3234554556};

bool is_runrun(int i){
    int savei = i;
    int d = i % 10;
    while (i){
        if (abs(d-(i%10)) > 1) return false;
        d = i % 10;
        i /= 10;
    }
    return true;
}

signed main(){
    int n;
    cin >> n;
    n--;
    int ret = runrun_hundred[n/100];
    n %= 100;
    while(n){
        ret++;
        if (is_runrun(ret)) n--;
    }
    cout << ret << endl;
}

Measured memory_bytes: 256