#include <bits/stdc++.h>
double inf = 1e12;
using ull = unsigned long long;
int main() {
  int n;
  std::cin >> n;
  std::vector<std::tuple<double, ull, ull>> data;
  ull sum = 0;
  for (auto i = 0; i < n; i++) {
    std::string str;
    std::cin >> str;
    ull s = 0, h = 0;
    for (auto c : str) {
      if (c == 's') {
        s++;
      } else if (c == 'h') {
        sum += s;
        h++;
      }
    }
    if (s != 0)
      data.push_back(std::make_tuple(((double)h) / s, s, h));
    else
      data.push_back(std::make_tuple(inf, s, h));
  }
  std::sort(data.begin(), data.end());
  ull s = 0, h = 0;
  for (auto i : data) {
    sum += s * std::get<2>(i);
    s += std::get<1>(i);
    h += std::get<2>(i);
  }
  std::cout << sum << std::endl;
}
