#include <bits/stdc++.h>
int64_t count(const std::string& str) {
  int64_t res = 0;
  int64_t s = 0;
  for (size_t i = 0; i < str.size(); ++i) {
    if (str[i] == 'h') res += s;
    if (str[i] == 's') ++s;
  }
  return res;
}
struct cmp {
  bool operator()(const std::pair<int64_t, int64_t>& one,
                  const std::pair<int64_t, int64_t>& two) {
    return one.first * two.second > one.second * two.first;
  }
};
void solve() {
  int n;
  std::cin >> n;
  int64_t res = 0;
  std::vector<std::pair<int64_t, int64_t>> v(n);
  for (int i = 0; i < n; ++i) {
    std::string str;
    std::cin >> str;
    res += count(str);
    int64_t s = 0, h = 0;
    for (size_t j = 0; j < str.size(); ++j) {
      if (str[j] == 's') ++s;
      if (str[j] == 'h') ++h;
    }
    v[i].first = s;
    v[i].second = h;
  }
  std::sort(v.begin(), v.end(), cmp());
  int64_t s = 0;
  for (int i = 0; i < n; ++i) {
    res += s * v[i].second;
    s += v[i].first;
  }
  std::cout << res;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}
