#include <bits/stdc++.h>
using namespace std;
long long dp[20][2], id[20][2];
int main() {
  string s;
  cin >> s;
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < (s.size()); i++)
    for (int j = 0; j < (2); j++) {
      if (dp[i][j] == -1) continue;
      int l = (j ? 9 : s[i] - '0');
      for (int k = 0; k < (l + 1); k++) {
        if (dp[i + 1][j || k < l] < dp[i][j] + k) {
          dp[i + 1][j || k < l] = dp[i][j] + k;
          id[i + 1][j || k < l] = id[i][j] * 10 + k;
        } else if (dp[i + 1][j || k < l] == dp[i][j] + k)
          id[i + 1][j || k < l] = max(id[i + 1][j || k < l], id[i][j] * 10 + k);
      }
    }
  if (dp[s.size()][0] < dp[s.size()][1])
    printf("%lld\n", id[s.size()][1]);
  else if (dp[s.size()][0] > dp[s.size()][1])
    printf("%lld\n", id[s.size()][0]);
  else
    printf("%lld\n", max(id[s.size()][0], id[s.size()][1]));
}
