text: #include <bits/stdc++.h>
  
  using namespace std;
  
  // Macros
  #ifdef D3BUG
      #define cerrd if (D3BUG) cerr
  #else
      #define cerrd if (false) cerr
  #endif
  
  // Types
  template <typename T> using vector1D = vector<T>;
  template <typename T> using vector2D = vector<vector1D<T>>;
  template <typename T> using vector3D = vector<vector2D<T>>;
  
  template<
      // Output stream overload for STL containers with one explicit type parameter.
      template<class> class Range, class T,
      typename = enable_if_t<is_same_v<Range<T>, deque<T>> ||
                             is_same_v<Range<T>, forward_list<T>> ||
                             is_same_v<Range<T>, list<T>> ||
                             is_same_v<Range<T>, multiset<T>> ||
                             is_same_v<Range<T>, set<T>> ||
                             is_same_v<Range<T>, unordered_multiset<T>> ||
                             is_same_v<Range<T>, unordered_set<T>> ||
                             is_same_v<Range<T>, vector<T>>>
  >
  ostream& operator<<(ostream& out, const Range<T>& range) {
      constexpr auto brackets = is_same_v<Range<T>, vector<T>> ? "[]" : "{}";
      out << brackets[0];
      for (auto it = range.begin(); it != range.end(); ++it) {
          out << *it << (next(it) != range.end() ? ", " : "");
      }
      return out << brackets[1];
  }
  
  template<
      // Output stream overload for STL containers with two explicit type parameters.
      template<class, class> class Range, class K, class V,
      typename = enable_if_t<is_same_v<Range<K, V>, map<K, V>> ||
                             is_same_v<Range<K, V>, multimap<K, V>> ||
                             is_same_v<Range<K, V>, unordered_map<K, V>> ||
                             is_same_v<Range<K, V>, unordered_multimap<K, V>>>
  >
  ostream& operator<<(ostream& out, const Range<K, V>& range) {
      out << '{';
      for (auto it = range.begin(); it != range.end(); ++it) {
          out << it->first << ": " << it->second << (next(it) != range.end() ? ", " : "");
      }
      return out << '}';
  }
  
  template <class F, class S>
  ostream& operator<<(ostream& out, const pair<F, S>& duo) {
    return out << '(' << duo.first << ", " << duo.second << ')';
  }
  
  // Hash Template Specializations
  template<class T, class U>
  struct hash<std::pair<T, U>> {
      size_t operator()(const std::pair<T, U>& pair) const noexcept {
          return std::hash<T>{}(pair.first) ^ (std::hash<U>{}(pair.second) << 1);
      }
  };
  
  void solution();
  
  // Initalize the execution environment and call the solution function.
  int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      solution();
  }
  
  // -----------------------------------------------------------------------------
  
  void solution() {
      unordered_set<pair<int, int>> flipped;
      string line;
      while (getline(cin, line) && !line.empty()) {
          int x = 0;
          int y = 0;
          for (int i = 0; i < line.size(); ++i) {
              const char c1 = line[i];
              if (c1 == 'e') {
                  ++x;
                  continue;
              } else if (c1 == 'w') {
                  --x;
                  continue;
              }
              const char c2 = line[++i];
              if (c1 == 'n') {
                  ++y;
              } else if (c1 == 's') {
                  --y;
              }
              if (c1 == 's' && c2 == 'w') {
                  --x;
              } else if (c1 == 'n' && c2 == 'e') {
                  ++x;
              }
          }
          pair<int, int> tile = {x, y};
          if (flipped.find(tile) != flipped.end()) {
              flipped.erase(tile);
          } else {
              flipped.emplace(tile);
          }
      }
      cout << flipped.size() << '\n';
  }
  