#include <bits/stdc++.h>
using namespace std;

long long num, now, nex, ans = 0;
string s;
bool naik;
bool turun;

int main () {
	for(long long bil=0; bil<10000000000; bil++) {
		naik = true;
		turun = true;
		num = bil;

		nex = -1;
		while (num > 0) {
			now = num%10;
			if (nex != -1) {
				if (now > nex) naik = false;
				if (now < nex) turun = false;
			}
			nex = now;
			num = num / 10;
		}
		
		if (naik || turun) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}