This program determines whether an input string is properly nested given rules. It has a time complexity of O(N).