import java.io.*;

/**
 * @author Roman V Satyukov
 */
public class lucky_rs implements Runnable {
	private final String problemID = getClass().getName().split("_")[0].toLowerCase();
	private BufferedReader in;
	private PrintWriter out;
	private static final int MAXD = 110;
	private static final int MAXS = 500;
	
	private void check(boolean expr, String message) {
		if (!expr) {
			throw new AssertionError(message);
		}
	}
	
	private boolean[][] can;
	
	private void restore(int num, int sum) {
		if (num == 0) {
			return;
		}
		for (int d = 0; d < 10; d++) {
			int prevSum = d - sum + 2 * MAXS;
			if (prevSum < 0 || prevSum >= can[num].length || !can[num - 1][prevSum]) {
				continue;
			}
			out.print(d);
			restore(num - 1, prevSum);
			return;
		}
	}

	private void solve() throws IOException {
		String ticket = in.readLine();
		int n = ticket.length();
		check((1 <= n) && (n <= 100), "number of digits in ticket number is not in [1..100]");
		int[] seq = new int[n];
		for (int i = 0; i < n; i++) {
			seq[i] = ticket.charAt(i) - '0';
			check((0 <= seq[i]) && (seq[i] <= 9), "not a number");
		}
		can = new boolean[MAXD + 1][2 * MAXS + 2];
		can[0][MAXS] = true;
		for (int i = 0; i < MAXD; i++) {
			for (int j = 0; j < 2 * MAXS + 2; j++) {
				if (!can[i][j]) {
					continue;
				}
				for (int d = 0; d < 10; d++) {
					int newSum = (i % 2 == 0) ? (j + d) : (j - d);
					if (newSum < 0 || newSum >= 2 * MAXS + 2) {
						continue;
					}
					can[i + 1][newSum] = true;
				}
			}
		}
		
		for (int i = n - 1; i >= 0; i--) {
			int sum = 0;
			for (int j = 0; j < i; j++) {
				sum = (j % 2 == 1) ? (sum + seq[j]) : (sum - seq[j]); 
			}
			for (int d = seq[i] + 1; d < 10; d++) {
				int curSum = (i % 2 == 1) ? (sum + d) : (sum - d);
				if (i % 2 == 0) {
					curSum = -curSum;
				}
				if (can[n - 1 - i][curSum + MAXS]) {
					seq[i] = d;
					for (int j = 0; j <= i; j++) {
						out.print(seq[j]);
					}
					restore(n - 1 - i, curSum + MAXS);
					out.println();
					return;
				}
			}
		}
		out.print("1");
		restore(n, 1 + MAXS);
		out.println();
	}
	
	public static void main(String[] args) {
		new Thread(new lucky_rs()).start();
	}

	public void run() {
		try {
			in = new BufferedReader(new FileReader(new File(problemID + ".in")));
			out = new PrintWriter(new File(problemID + ".out"));
			solve();
			in.close();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}
