Its working in coding blocks ide its not working in where assignment needed to be submitted showing scanner error

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();

    int rem=0;
    int ans=0;
    while(n!=0)
    {
      rem=n%10;
      ans=(ans*10)+rem;
      n=n/10;
    }
    System.out.println(ans);
        }

}

Please share the input format. Probably there’s input format mismatch.