Take the following as input. A number A digit Write a function that returns the number of times digit is found in the number. Print the value returned

public static void main(String args[]) {
Scanner sc = new Scanner(System.in);

	int num = sc.nextInt();

	int item = sc.nextInt();

	countDigit(num, item);
}

public static void countDigit(int num, int item) {
	int count = 0;
	
	while(num != 0) {
	int n = num % 10;
	if (n == item) {
		count++;
	}
	
	num /= 10;
	}
	System.out.print(count);
}