#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int n;
struct node {
  long long si, hi;
};
node sum[maxn];
char sz[maxn];
bool cmp(node n1, node n2) { return n2.hi * n1.si > n1.hi * n2.si; }
int main() {
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", sz + 1);
    long long ss = 0, hh = 0;
    int len = strlen(sz + 1);
    for (int j = 1; j <= len; j++) {
      if (sz[j] == 's')
        ss++;
      else {
        hh++;
        ans += ss;
      }
    }
    sum[i].si = ss;
    sum[i].hi = hh;
  }
  sort(sum + 1, sum + n + 1, cmp);
  long long qian = sum[1].si;
  for (int i = 2; i <= n; i++) {
    ans += (sum[i].hi * qian);
    qian += sum[i].si;
  }
  printf("%lld\n", ans);
  return 0;
}
