#include <bits/stdc++.h>
using namespace std;
int dcmp(double x, double y) {
  return fabs(x - y) <= 1e-9 ? 0 : x < y ? -1 : 1;
}
const int MAX = 9 * 18;
long long memo[20][3][MAX];
long long x, n;
string s;
long long dp(int i, bool f, int sum) {
  if (i == n) {
    return sum;
  }
  long long &ret = memo[i][f][sum];
  if (ret != -1) {
    return ret;
  }
  if (f) {
    for (int j = 0; j <= 9; j++) {
      ret = max(ret, dp(i + 1, f, sum + j));
    }
  } else {
    for (int j = 0; j <= (s[i] - '0'); j++) {
      ret = max(ret, dp(i + 1, j != (s[i] - '0'), sum + j));
    }
  }
  return ret;
}
void print_path(int i, bool f, int sum) {
  if (i == n) {
    return;
  }
  long long &ret = memo[i][f][sum];
  if (f) {
    int maxi = 0;
    for (int j = 0; j <= 9; j++) {
      if (dp(i + 1, f, sum + j) == dp(i, f, sum)) {
        maxi = max(maxi, j);
      }
    }
    if (i != 0 || maxi != 0) cout << maxi;
    print_path(i + 1, f, sum + maxi);
  } else {
    int maxi = 0;
    for (int j = 0; j <= (s[i] - '0'); j++) {
      if (dp(i + 1, j != (s[i] - '0'), sum + j) == dp(i, f, sum)) {
        maxi = max(maxi, j);
      }
    }
    if (i != 0 || maxi != 0) cout << maxi;
    print_path(i + 1, maxi != (s[i] - '0'), sum + maxi);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  memset(memo, -1, sizeof(memo));
  cin >> x;
  s = to_string(x);
  n = s.length();
  int ans = dp(0, false, 0);
  print_path(0, false, 0);
}
