class Solution
{
  public:
  //Insert one char from stringstream
    void Insert(char ch) {
      str += ch;
      ++hash[ch];
    }
  //return the first appearence once char in current stringstream
    char FirstAppearingOnce() {
      if (str.empty()) {
        return '#';
      }
      
      for (int i = 0; i < str.size(); ++i) {
        if (hash[str[i]] == 1) {
          return str[i];
        }
      }
      
      return '#';
    }
  
  private:
    std::string str;
    std::unordered_map<char, int> hash;
};