#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
template <typename T>
using mxpq = priority_queue<T>;
template <typename T>
using mnpq = priority_queue<T, vector<T>, greater<T>>;
const long long mod = 1e9 + 7;
const long long N = 1e6 + 6;
const long long maxN = 2e5 + 15;
const long long MAX_SIZE = 2e6 + 6;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
long long powerM(long long x, long long y, long long M = mod) {
  long long v = 1;
  x = x % M;
  while (y > 0) {
    if (y & 1) v = (v * x) % M;
    y = y >> 1;
    x = (x * x) % M;
  }
  return v;
}
long long power(long long x, long long y) {
  long long v = 1;
  while (y > 0) {
    if (y & 1) v = v * x;
    y = y >> 1;
    x = x * x;
  }
  return v;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long x;
  cin >> x;
  string num;
  long long xx = x, s1 = 0;
  while (xx > 0) {
    int d = xx % 10;
    s1 += d;
    xx /= 10;
    num = (char)(d + '0') + num;
  }
  long long mans = x, tt = 0;
  string ans = num, temp;
  for (int j = 0; j < num.length(); ++j) {
    int fd = num[j] - '0';
    temp += num[j];
    if (fd == 0) {
      tt *= 10;
      continue;
    }
    fd--;
    long long s = fd;
    long long absn = 0;
    string big = num.substr(0, j);
    for (auto it : big) {
      s += it - '0';
      absn = absn * 10 + (it - '0');
    }
    absn = absn * 10 + (fd);
    if (fd != 0) {
      big += (char)(fd + '0');
    }
    for (int i = j + 1; i < num.length(); ++i) {
      s += 9;
      big = big + '9';
      absn = absn * 10 + (9);
    }
    if (s > s1) {
      s1 = s;
      ans = big;
      mans = absn;
    } else if (s1 == s && absn > mans) {
      ans = big;
      mans = absn;
    }
  }
  cout << ans;
  return 0;
}
