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>
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define IM LLONG_MAX
#define endl "\n"
#define all(v) v.begin(),v.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define deb(x) cout<<"["#x<<":"<<x<<"]"<<"  "<<endl;
#define deb2(x,y) cout<<"["#x<<":"<<x<<" "#y<<":"<<y<<"]"<<endl;
#define out(a) for(auto x:a)cout<<x<<" "; cout<<endl;
#define outyes cout<<"YES"<<endl;
#define outno cout<<"NO"<<endl;
#define mod 1000000007
using namespace std; 

void AKM() 
{
  int x;
  cin >> x;
  cout << (x - 1) % 9 + 1 << endl;
    


    
}

int32_t main()
{
    fastio;
    cout<<fixed;
    cout.precision(16);
    int __TESTCASES=1;
    //cin>>__TESTCASES;
    while(__TESTCASES--){ 
        AKM();
}
}