#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using UI = unsigned int;
using UC = unsigned char;
using VI = std::vector<int>;
using SI = std::set<int>;
using PI = std::pair<int, int>;
using PL = std::pair<LL, LL>;
constexpr LL MOD = 1000000009;
constexpr double EXP = 2.7182818284590452;
constexpr double Pi = 3.1415926535;
constexpr long double EPS = 1e-4;
constexpr int INF = 1000 * 1000 * 1001;
constexpr long long INFL = (LL)INF * (LL)INF;
inline LL gcd(LL a, LL b) {
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
inline LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }
LL extgcd(LL a, LL b, LL& x, LL& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  LL x11, y11;
  LL d = extgcd(b % a, a, x11, y11);
  x = y11 - (b / a) * x11;
  y = x11;
  return d;
}
ULL poww(ULL v, ULL p, ULL mod) {
  if (p == 0) return 1;
  if (p & 1) {
    return (poww(v, p - 1, mod) * v) % mod;
  } else {
    ULL t = poww(v, p / 2, mod);
    return (t * t) % mod;
  }
}
constexpr ULL L31018 = 3000000000000000000L;
constexpr ULL L1018 = 1000000000000000000L;
LL n, t;
LL p, sumN, mxS, mxN, curS, curN, num9;
inline size_t digitsSum(LL num) {
  size_t sum = 0;
  while (num) {
    sum += num % 10;
    num /= 10;
  }
  return sum;
}
void accept() {
  cin >> n;
  t = 1;
  p = 0;
  num9 = 0;
  sumN = mxS = digitsSum(n);
  mxN = n;
  while (n) {
    curN = (n % 10) - 1;
    sumN -= curN + 1;
    curS = 9 * p + curN + sumN;
    n /= 10;
    if (curS > mxS) {
      mxN = curN * t + num9 + n * t * 10;
      mxS = curS;
    }
    ++p;
    num9 += 9 * t;
    t *= 10;
  }
  cout << mxN;
}
int main(void) {
  accept();
  return 0;
}
