#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
struct OrzG {
  string s;
  int nums, numh;
} st[maxn];
bool cmp(const OrzG &x1, const OrzG &x2) {
  return (long long)x1.nums * x2.numh > (long long)x2.nums * x1.numh;
}
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> st[i].s;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < st[i].s.size(); j++)
      if (st[i].s[j] == 's')
        st[i].nums++;
      else
        st[i].numh++;
  sort(st, st + n, cmp);
  int cnt = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < st[i].s.size(); j++)
      if (st[i].s[j] == 's')
        cnt++;
      else
        ans += cnt;
  return 0 * printf("%lld\n", ans);
}
