#include using namespace std; int main() { int n; cin >> n; int d = 0; while(n != 0) {d++; n /= 10;} cout << 9 * (d + 1) << endl; }