#include <bits/stdc++.h>
using namespace std;
string mirror = "AHIMOTUVWXY";
string letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
  long long n, m, i, j, k, x, y, t;
  string str;
  cin >> str;
  long long sum = 0;
  for (i = 0; i < str.size(); i++) sum += str[i] - '0';
  k = 9 * (str.size() - 1) + str[0] - '0' - 1;
  if (sum >= k) {
    cout << str << endl;
    return 0;
  }
  for (i = 1; i < str.size(); i++) {
    if (str[i] != '9') {
      str[i - 1]--;
      for (j = i; j < str.size(); j++) str[j] = '9';
    }
  }
  k = stoll(str);
  cout << k << endl;
}
