#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long int ll; //#include using namespace std; int main() { int Q; Q = 1; //cin >> Q; while (Q--) { int n; cin >> n; for (int i = 0; i < 100; i++) { int t = n; int a = 0; while (t) { a += t % 10; t /= 10; } n = a; } cout << n << endl; } return 0; }