#include <bits/stdc++.h>
using namespace std;
struct node {
  string c;
  long long h, s;
} s[100005];
bool cmp(node a, node b) {
  long long now1 = a.s * b.h;
  long long now2 = a.h * b.s;
  if (now1 != now2) return now1 > now2;
  if (a.s != b.s) return a.s > b.s;
  return a.h < b.h;
}
int main() {
  long long n, k, now, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i].c;
    k = s[i].c.size();
    for (int j = 0; j < k; j++) {
      if (s[i].c[j] == 's')
        s[i].s++;
      else
        s[i].h++;
    }
  }
  sort(s, s + n, cmp);
  string c = "";
  for (int i = 0; i < n; i++) {
    c += s[i].c;
  }
  k = c.size();
  now = 0;
  for (int i = 0; i < k; i++) {
    if (c[i] == 's')
      now++;
    else
      ans += now;
  }
  cout << ans << endl;
}
