#include using namespace std; template using vec = vector; template using vvec = vector>; int main() { int n; cin >> n; for (int i = 0; i < 100; ++i) { int sum = 0; while (n) { sum += n % 10; n /= 10; } n = sum; } cout << n << endl; }