#include <stdio.h> int Balala(int a); int main(void) { int n, ans; scanf("%d", &n); ans = Balala(n); printf("%d", ans); return 0; } int Balala(int a) { int m[10] = {0}; int i, ans = 0; if(a % 10 == a) return a; else { i = 0; while(a % 10 != a) { m[i] = a % 10; a = a / 10; i++; } for(i = 0; i < 10; i++) { ans = ans + m [i]; } ans += a; ans = Balala (ans); return ans; } }