Only three test cases are passed two are failed please elaborate those ones

import java.util.*;
public class Main
{
public static void main(String args[])
{

	long s=0,a,k;
	Scanner sc=new Scanner(System.in);
	long n=sc.nextLong();
	if(n>=1&&n<=Math.pow(10,18))
	{
		while(n>0)
		{
         a=n%10;
		 if((9-a)<a)
		 s=s*10+(9-a);
		 else
		 s=s*10+a;
		 n=n/10;
		 }
		 k=num(s);
		 System.out.print(k);
	}
 }
 

		 public static long num(long s1)
		 {
			 
			 long rev=0,b;
			 while(s1>0)
			 {
			 b=s1%10;
			 rev=rev*10+b;
			 s1=s1/10;
		 }
		 return rev;
		 }

}