#include <bits/stdc++.h>
using namespace std;
struct T {
  string str;
  int nums;
  int numh;
  float val;
};
struct T t[100005];
bool cmp(T a, T b) { return a.val > b.val; }
int main(int argc, const char* argv[]) {
  int n, i, j;
  scanf("%d", &n);
  long long counth = 0;
  long long sum = 0;
  for (i = 0; i < n; i++) {
    t[i].numh = 0;
    t[i].nums = 0;
    cin >> t[i].str;
    for (j = 0; t[i].str[j] != '\0'; j++) {
      if (t[i].str[j] == 's')
        t[i].nums++;
      else
        t[i].numh++;
    }
    counth += t[i].numh;
    if (t[i].numh == 0)
      t[i].val = 999999999;
    else if (t[i].nums == 0)
      t[i].val = 0;
    else
      t[i].val = (float)t[i].nums / t[i].numh;
  }
  sort(t, t + n, cmp);
  for (i = 0; i < n; i++) {
    for (j = 0; t[i].str[j] != '\0'; j++) {
      if (t[i].str[j] == 's')
        sum += counth;
      else
        counth--;
    }
  }
  printf("%lld\n", sum);
  return 0;
}
