Chewbacca and number error

This is my code and it is showing run time error-

import java.util.Scanner;

public class chewbaccaandnumber {

public static void main(String[] args) {

	Scanner scn=new Scanner(System.in);
	long n=scn.nextInt();
	long ans=0;
	long multiplier=1;
	while(n!=0) {
		long rem=n%10;
		if(rem>=5) {
			if(rem==9&&(n/10)==0) {
				
			}else {
				rem=9-rem;
			}
		}
	ans =ans+(rem*multiplier);
	n=n/10;
	multiplier=multiplier*10;
	}
	System.out.println(ans);
}

}

@Vibhor
long n=scn.nextInt();
Use long n=scn.nextLong();
It will certainly help.
Thankyou