#include int main() { int t=0 ; long int n; cin >> n; while (n>9){ int t=0; while(n>0){ t+=n%10; n/=10; } n=t; } cout << n << endl; }