#include using namespace std; #define int long long typedef pair P; int INF = 1e9+7; int mod = 1e9+7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int N; cin >> N; for(int i = 0; i < 99; i++) { int cnt = 0; while(N) { cnt += N%10; N/=10; } N = cnt; } cout << N << endl; }