#include using namespace std; #define SZ(x) (int)(x.size()) using ll = long long; using ld = long double; using P = pair; using vi = vector; using vvi = vector>; using vll = vector; using vvll = vector>; const double eps = 1e-10; const int MOD = 1000000007; const int INF = 1000000000; const ll LINF = 1ll<<50; template void printv(const vector& s) { for(int i=0;i<(int)(s.size());++i) { cout << s[i]; if(i == (int)(s.size())-1) cout << endl; else cout << " "; } } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); int n; cin >> n; ll tmp = 0; ll ans = 1; for(int i=0;i> p; while(p >= 10) { while(p > 0) { tmp += p % 10; p /= 10; } p = tmp; tmp = 0; } ans *= p; while(ans >= 10) { while(ans > 0) { tmp += ans % 10; ans /= 10; } ans = tmp; tmp = 0; } } cout << ans << endl; }