Code not working

int main() {

stack<char> s;

string str;
cin >> str;

for(int i=0;i<str.length();i++) {
	char ch = str[i];
	if(ch == '(') {
		s.push(ch);
	} else if(ch == ')'){
		if(s.top() == '(') {
			s.pop();
		} else {
			cout << "Not Balanced";
			return 0;
		}
	}
}
if(s.size() == 0) cout << "Balanced";
else cout << "Not Balanced";
return 0;

}

This is should give Not Balanced for string ()) .
It is crashing unexpectedly.Why?

Before performing s.pop() or s.top() you must ensure that the stack is empty.
Try to correct that.
You can save your code on ide.codingblocks.com and then share its link.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.