#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cstring>
#include <map>
#include <cmath>
#define ios ios::sync_with_stdio(false);cin.tie(0);
#define N 1010
#define ll long long
#define mx INT_MAX
using namespace std;
bool isbracket(string s)
{
stack<char> st;
for(int i=0;i<s.length();i++)
{
if(s[i]=='('||s[i]=='['||s[i]=='{'||s[i]=='<')
st.push(s[i]); // 如果遇到左括号就入栈
else if(!st.empty() && s[i]==')'&&st.top()=='(') st.pop();
else if(!st.empty() && s[i]==']'&&st.top()=='[') st.pop();
else if(!st.empty() && s[i]=='}'&&st.top()=='{') st.pop();
else if(!st.empty() && s[i]=='>'&&st.top()=='<') st.pop();
}
if(st.empty()) return true;
else return false;
}
int main()
{
ios
string s;
cin>>s;
if(isbracket(s)) cout<<"YES"<<endl;
else cout<<"N0"<<endl;
return 0;
}