Help me in solving LPYAS151 problem

My issue

Wrong Answer: Failed on a hidden test case

My code

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
	public static void main (String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int temp = n;
		int sum=0;
		int power = String.valueOf(n).length();
		while(temp > 0)
		{
		    int digit = temp % 10;
		    sum += Math.pow(digit,power);
		    temp = temp/10;
		}
		if(sum == n )
		{
		    System.out.println("Armstrong Number");
		}
		else {
		    System.out.println("Not Armstrong Number");
		}
	}
}

Learning course: Algorithmic Problem Solving
Problem Link: https://www.codechef.com/learn/course/mitwpu-problem-solving/MWPURM201/problems/LPYAS151