Problem: Many people are aware of DMCA – Digital Millennium Copyright Act. But another recently proposed DMCA – Digital Millennium Calculation Act – is much less known.

In this problem you need to find a root of a number according to this new DMCA law.

Input

The input contains a single integer a (1 ≤ a ≤ 1000000).

Output

Output the result – an integer number.

Examples

Input


1


Output


1


Input


81


Output


9

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pii pair <int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846

const int N = 200005;
const int mod = 1e9 + 7;

int main() {
    io;
    int n, m = 0, g = 0;
    cin >> n;
    m = n;
    vector <int> v;
    while(n / 10 != 0){
    g=0;
    while(n > 0){
       g +=(n % 10);
        n /= 10;
    }
    n = g;
    }

    cout << n;
}