import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a;
		int sum =0;
		if(N/100==1) {
			a = N-100;
			sum+=900;
			if(a/10==1) {
				a = a-10;
				sum+=90;
				if(a/1==1) {
					sum+=9;
				}
				else if(a/9==1) {
					sum+=1;
				}
			}
			else if(a/10==9) {
				a = a-90;
				sum+=10;
				if(a/1==1) {
					sum+=9;
				}
				else if(a/1==9) {
					sum+=1;			
				}
			}
		}
		if(N/100==9) {
			a = N-900;
			sum+=100;
			if(a/10==1) {
				a = a-10;
				sum+=90;
				if(a/1==1) {
					sum+=9;
				}
				else if(a/9==1) {
					sum+=1;
				}
			}
			else if(a/10==9) {
				a = a-90;
				sum+=10;
				if(a/1==1) {
					sum+=9;
				}
				else if(a/1==9) {
					sum+=1;				
				}
			}
		}
		System.out.println(sum);
	}
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz