#include <bits/stdc++.h>
using namespace std;
long long ninize(long long x);
int sum(long long x);
int main(int argc, const char* argv[]) {
  long long x;
  cin >> x;
  long long n = ninize(x);
  if (sum(x) > sum(n) - 1) {
    n = x;
  }
  cout << n << endl;
  return 0;
}
long long ninize(long long x) {
  vector<long long> v;
  long long a = 0;
  for (; x > 0; x /= 10) {
    v.push_back(x % 10);
  }
  long i = v.size() - 1;
  bool b = 0;
  for (; i > -1; i--) {
    if (v[i] == 9) {
      b = 1;
    }
    if (b && v[i] != 9) {
      break;
    }
  }
  if (b) {
    for (long h = v.size() - 1; h > i; h--) {
      a = a * 10 + v[h];
    }
    a--;
    for (; i > -1; i--) {
      a = a * 10 + 9;
    }
  }
  long long a1 = v[v.size() - 1] - 1;
  for (long h = v.size() - 2; h > -1; h--) {
    a1 = a1 * 10 + 9;
  }
  if (sum(a1) > sum(a)) {
    a = a1;
  }
  return a;
}
int sum(long long x) {
  int z = 0;
  while (x > 0) {
    z += x % 10;
    x /= 10;
  }
  return z;
}
