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 <iostream>
#include <string>
#include <string.h>
#include <cstring>
#include <math.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cctype>
#include <utility>
#include <set>
#include <map>
#include <sstream>
#include <iterator>
#include <limits>
#include <map>
#include <deque>
#include <stack>
#include <queue>
#include <climits>
#include <tuple>
using namespace std;
#define pb push_back
#define ff(i, a, b) for (int i = a; i < b; ++i)
#define ffr(i, b, a) for (int i = b; i >= a; --i)
#define fflr(i, b, a) for (long long i = b; i >= a; --i)
#define ffl(i, a, b) for (long long i = a; i < b; ++i)
#define all(v) v.begin(), v.end()
#define endl '\n'
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define trav(a, x) for (auto &a : x)
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define collect(v, n)          \
    for (ll i = 0; i < n; i++) \
    {                          \
        cin >> v[i];           \
    }
#define X first
#define epsilon -0.0000001f
#define Y second
#define mp make_pair
#define mt make_tuple
typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef std::vector<int> vec;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef std::vector<long long> vecl;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

void FAST()
{ // FAST Input Output, DONT use both scnaf,printf / cin,cout , Use any ONE system
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll md = 1000000007;
#define pi 3.141592653589793238462643383279
const ll inf = 1e18L + 5; // max 1000*inf
const char nl = '\n';
const int N = 200005;

// ll sod(ll x)
// {
//     ll sum = 0;
//     while (x > 0)
//     {
//         sum += x % 10;
//         x = x / 10;
//     }
//     return sum;
// }
// float round1(float var)
// {

//     char str[40];
//     sprintf(str, "%.2f", var);
//     sscanf(str, "%f", &var);

//     return var;
// }
// bool palindrome(string s)
// {
//     int count = 0;
//     int i = 0;
//     int l = s.length();
//     ff(i, 0, l / 2)
//     {
//         if (s[i] != s[l - i - 1])
//             return 0;
//     }
//     return 1;
// }

int main()
{
    //     FAST();
    //     int tt{}, T{};
    //     tt = 1;
    //     cin >> tt;
    //     T = tt;
    //     while (tt--)
    //     {
   ll n;
   cin>>n;
   n=n%9;
   if(n==0)n=9;
  cout<<n;

    return 0;
}