#include <bits/stdc++.h>
long long f(std::string s) {
  long long out = 0, cntS = 0;
  for (char &c : s) {
    if (c == 's') {
      cntS++;
    } else {
      out += cntS;
    }
  }
  return out;
}
int main() {
  int n;
  std::cin >> n;
  std::vector<std::string> a(n);
  for (std::string &s : a) {
    std::cin >> s;
  }
  std::sort(a.begin(), a.end(),
            [&](std::string a, std::string b) { return f(a + b) > f(b + a); });
  std::string v = "";
  for (std::string &s : a) {
    v += s;
  }
  std::cout << f(v) << std::endl;
  return 0;
}
