#include<stdio.h> #include<vector> using namespace std; int main(){ int n; while (scanf("%d", &n) != EOF){ while (n >= 10){ vector<int>vec; int k; while (n != 0){ k = n % 10; vec.push_back(k); n = n / 10; } for (int i = 0; i < vec.size(); i++){ n = n + vec[i]; } } printf("%d\n", n); } }