Help me in solving LPYAS151 problem

My issue

Can you help me to find where is the error located in my code

My code

#include <stdio.h>
int main() {
    int n,sum = 0,temp,digit,count = 0;
    scanf("%d",&n);
    temp = n;
    while (temp != 0) {
        temp /= 10;
        count++;
    }
    temp = n;
    while (temp != 0) {
        digit= temp % 10;
        sum += digit * digit * digit; 
        temp /= 10;
    }
    if (sum ==n)
        printf("Armstrong ");
    else
        printf("Not Armstrong");
    return 0;
}


Learning course: Roadmap to 3*
Problem Link: https://www.codechef.com/learn/course/klu-roadmap-3star/KLURMP300B/problems/LPYAS151