i tried a lot on this error but am not able to solve the problem here is the code
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner in=new Scanner(System.in);
String p=in.next();
char q;
int r;
for(int i=0;i<p.length();i++)
{
q=p.charAt(i);
r=(int)q;
if(9-r<r)
{
p=p.substring(0,i)+r+p.substring(i+1);
}
}
System.out.println(p);
}
}