#include <bits/stdc++.h>
using namespace std;
int sdig(long long int n, int i) {
  int sum = 0;
  int count = 0;
  while (n != 0) {
    if (count >= i) {
      sum += n % 10;
    }
    n = n / 10;
    count++;
  }
  return sum;
}
void show(long long int n, int i) {
  std::vector<int> v;
  int j;
  while (n != 0) {
    v.push_back(n % 10);
    n = n / 10;
  }
  for (j = v.size() - 1; j >= i + 1; j--) {
    cout << v[j];
  }
  if (i == v.size() - 1 && v[i] != 1) cout << v[j] - 1;
  if (i != v.size() - 1) cout << v[j] - 1;
}
int main() {
  long long int n, k;
  cin >> n;
  int sum = sdig(n, 0);
  int temp = 0;
  int ans = 0, i = 1, p = 0;
  k = n;
  while (k != 0) {
    temp++;
    k = k / 10;
  }
  while (i != temp) {
    if (sdig(n, i) - sdig(n, i + 1) == 0) {
      i++;
      continue;
    }
    sum = max(sum, sdig(n, i) - 1 + i * 9);
    i++;
  }
  if (sum == sdig(n, 0)) {
    cout << n << endl;
    return 0;
  }
  i = 1;
  while (i != temp) {
    if (sdig(n, i) - sdig(n, i + 1) == 0) {
      i++;
      continue;
    }
    if (sum == sdig(n, i) - 1 + i * 9) {
      show(n, i);
      for (p = 0; p < i; p++) {
        cout << 9;
      }
      break;
      return 0;
    }
    i++;
  }
}
