#include<bits/stdc++.h>
using namespace std;
int main(){
	int g,w,b,q,x,c,a,n,m,t;
	scanf("%d",&x);
	q=x/1000;
	b=(x/100)%10;
	w=(x/10)%10;
	g=x%10;
	a=(q+5)%10;
	n=(b+5)%10;
	m=(w+5)%10;	
	t=(g+5)%10;
	c=t*1000+m*100+n*10+a;
    printf("%d",c);
}
 
/**************************************************************
	Problem: 1109
	User: xuezihong1
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2076 kb
****************************************************************/