Some of my test cases are not passed

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
int count = 0;
int a = 0;
while(n!=0){
a = n%10;
count++;
n=n/10;
}
a=0;

	while(n!=0){
		a = n%10;
		sum = sum + (int)Math.pow(a,count);
		n=n/10;
	}
	if(sum==n){
		System.out.println("true"); 
	}
	else{
		System.out.println("false");
	}

}

}

Hey @mishikasrvastava
logic is fine
Just a Mistake
After this steps n =0;
while (n > 0) {

	n = n/ 10
```ab n is 0
Therefore, store the value of the n in another variable.
correct code : 
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 0;
		int count = 0;
		int a = 0;
		int p = n;
		while (p != 0) {
			a = p % 10;
			count++;
			p = p / 10;
		}
		a = 0;
p=n;
		while (n != 0) {
			a = n % 10;
			sum = sum + (int) Math.pow(a, count);
			n = n / 10;
		}
		if (sum == p) {
			System.out.println("true");
		} else {
			System.out.println("false");
		}
	}
}

I am still not able to understand why we are using p

tum N ko use krke count of digit laa rahe ho then n 0 hojayeag, N lost hogya , so We are using p, p will hold the value of n.

ok
Thank you, sir, for the help