#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
struct node {
  long long S, H;
  int id;
  bool operator<(const node& other) const { return S * other.H > other.S * H; }
} no[MAXN];
string s[MAXN];
string t;
int main() {
  int N;
  cin >> N;
  int cntH = 0, cntS = 0, size = 0;
  for (int i = 0; i < N; ++i) {
    cin >> s[i];
    int len = s[i].size();
    size += len;
    no[i].S = no[i].H = 0;
    no[i].id = i;
    for (int j = 0; j < len; ++j)
      if (s[i][j] == 's')
        no[i].S++;
      else
        no[i].H++;
    cntS += no[i].S;
    cntH += no[i].H;
  }
  sort(no, no + N);
  for (int i = 0; i < N; ++i) t += s[no[i].id];
  long long ans = 0;
  for (int i = 0; i < size; ++i) {
    if (t[i] == 's')
      ans += cntH;
    else
      --cntH;
  }
  printf("%lld\n", ans);
  return 0;
}
