#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
template <typename T>
T setbit(T mask, T pos) {
  return mask |= (1 << pos);
}
template <typename T>
T resetbit(T mask, T pos) {
  return mask &= ~(1 << pos);
}
template <typename T>
T togglebit(T mask, T pos) {
  return mask ^= (1 << pos);
}
template <typename T>
T checkbit(T mask, T pos) {
  return (bool)(mask & (1 << pos));
}
template <typename T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <typename T>
T modu(T a, T b) {
  return (a < b ? a : a % b);
}
template <typename T>
T mod_neg(T a, T b) {
  a = 1000000007(a, b);
  if (a < 0) {
    a += b;
  }
  return a;
}
template <typename T>
T expo(T e, T n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T mod_inverse(T a, T n) {
  T x, y;
  T d = extended_euclid(a, n, x, y);
  return (d > 1 ? -1 : mod_neg(x, n));
}
template <typename T>
T power(T e, T n, T m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = 1000000007(x * p, m);
    p = 1000000007(p * p, m);
    n >>= 1;
  }
  return x;
}
template <typename T>
T powerL(T e, T n, T m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mulmod(x, p, m);
    p = mulmod(p, p, m);
    n >>= 1;
  }
  return x;
}
bool Pow2(int n) { return n && (!(n & (n - 1))); }
void printc(vector<char>& result) {
  for (auto r : result) cout << r << " ";
  cout << '\n';
}
void printl(vector<long long>& result) {
  for (auto r : result) cout << r << " ";
  cout << '\n';
}
void print(vector<int>& result) {
  for (auto r : result) cout << r << " ";
  cout << '\n';
}
int binpow(int a, int b) {
  if (b == 0) return a;
  int res = binpow(a, b / 2);
  if (b % 2)
    return res * res * a;
  else
    return res * res;
}
long long pow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long modpow(long long a, long long b, long long m) {
  a = a % m;
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans % m * a % m) % m;
    b /= 2;
    a = (a % m * a % m) % m;
  }
  return ans;
}
long long ncr(long long n, long long k) {
  long long res = 1;
  if (k > n - k) k = n - k;
  for (long long i = 0; i < k; ++i) {
    res = res * (n - i);
    res /= (i + 1);
  }
  return res;
}
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int find(int a, vector<int>& par) {
  if (par[a] == a) return a;
  return par[a] = find(par[a], par);
}
void merge(int a, int b, vector<int>& par, int& count, vector<int>& size) {
  a = find(a, par);
  b = find(b, par);
  if (a == b) return;
  count++;
  if (size[a] > size[b]) {
    size[a] += size[b];
    par[b] = a;
  } else {
    size[b] += size[a];
    par[a] = b;
  }
}
vector<int> factor(int a) {
  vector<int> f;
  for (int i = 1; i * i <= a; i++) {
    if (a % i == 0) {
      f.push_back(i);
      if (a / i != i) f.push_back(a / i);
    }
  }
  sort((f).begin(), (f).end());
  return f;
}
bool comp(string& a, string& b) { return (a.size() < b.size()); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test;
  test = 1;
  while (test--) {
    long long n;
    cin >> n;
    long long temp = n;
    vector<int> v;
    v.push_back(temp % 10);
    long long sum = temp % 10;
    temp /= 10;
    while (temp) {
      sum += temp % 10;
      if (temp % 10 != 0) {
        long long count = (temp % 10) - 1;
        count += 9 * (v.size());
        if (count > sum) {
          for (int(i) = 0; (i) < (int)(v.size()); ++(i)) v[i] = 9;
          v.push_back((temp % 10) - 1);
          sum = count;
        } else {
          v.push_back(temp % 10);
        }
      } else
        v.push_back(temp % 10);
      temp /= 10;
    }
    reverse((v).begin(), (v).end());
    long long ans = 0;
    for (int(i) = 0; (i) < (int)(v.size()); ++(i)) ans = ans * 10 + v[i];
    cout << ans << '\n';
  }
}
