/* http://projecteuler.net/
 *
 * Problem 112
 * Find the least number for which the proportion of bouncy numbers is
 * exactly 99%.
 *
 * Solution by Melkor (Filip Niksic, fniksic@gmail.com)
 *
 **/

#include <iostream>
#include <cstdlib>

using namespace std;

bool bouncy(int n) {
    bool inc = false, dec = false;
    div_t d = div(n, 10);
    int z = d.rem;
    n = d.quot;
    while (n > 0 && !(inc && dec)) {
	d = div(n, 10);
	if (d.rem > z)
	    dec = true;
	else if (d.rem < z)
	    inc = true;
	else
	    ;
	z = d.rem;
	n = d.quot;
    }
    return inc && dec;
}   
	
int main() {
    int bnc = 0, total = 1;
    while (bnc * 100 != total * 99) {
	++total;
	if (bouncy(total))
	    ++bnc;
    }
    cout << total << endl;
    return 0;
}

