#include using namespace std; int main(){ int n; cin >> n; long long int ans=1,p; for(int i=0;i> p; if(p==0){cout << 0 << endl; return 0;} ans = (ans * (p%9))%9; } if(ans==0) cout << 9 << endl; else cout << ans << endl; }