#include <bits/stdc++.h>
const int m = 1e5 + 5;
const int INf = 0x3f3f3f3f;
using namespace std;
struct p {
  string str;
  long long sn;
  long long hn;
  long long nei;
  float bili;
} v[m];
bool comp(p a, p b) { return a.bili > b.bili; }
int main() {
  int n;
  long long kks = 0;
  long long kkh = 0;
  long long jishu = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].str;
    v[i].sn = 0;
    v[i].hn = 0;
    v[i].nei = 0;
    for (int j = 0; v[i].str[j] != '\0'; j++) {
      if (v[i].str[j] == 's')
        v[i].sn++;
      else {
        v[i].hn++;
        v[i].nei += v[i].sn;
      }
    }
    if (v[i].sn == 0)
      v[i].bili = 0;
    else if (v[i].hn == 0)
      v[i].bili = INf;
    else
      v[i].bili = (float)v[i].sn / v[i].hn;
  }
  sort(v, v + n, comp);
  for (int i = 0; i < n; i++) {
    jishu += kks * v[i].hn;
    kks += v[i].sn;
    jishu += v[i].nei;
  }
  printf("%I64d", jishu);
}
