#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
const int inf = 1e9;
const double eps = 1e-9;
const double pi = 4 * atan(1.0);
ll solve(ll x) {
  vi v;
  while (x > 0) {
    v.push_back(x % 10);
    x /= 10;
  }
  reverse((v).begin(), (v).end());
  int sum = 9 * (((int)(v).size()) - 1);
  ll ans = 0;
  for (int i = 0; i < ((int)(v).size()) - 1; ++i) {
    ans = ans * 10 + 9;
  }
  ll cur = 0;
  int cur_sum = 0;
  for (int i = 0; i < ((int)(v).size()); ++i) {
    for (int j = (i == 0); j < v[i]; ++j) {
      ll res = cur * 10 + j;
      int res_sum = cur_sum + j;
      for (int z = i + 1; z < ((int)(v).size()); ++z) {
        res = res * 10 + 9;
        res_sum += 9;
      }
      if (res_sum > sum || (res_sum == sum && res > ans)) {
        sum = res_sum;
        ans = res;
      }
    }
    cur = cur * 10 + v[i];
    cur_sum += v[i];
  }
  if (cur_sum > sum || (cur_sum == sum && cur > ans)) {
    sum = cur_sum;
    ans = cur;
  }
  return ans;
}
int main() {
  ll x;
  cin >> x;
  cout << solve(x) << endl;
  return 0;
}
