#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;
const long long Max = 1e11;
int n;
struct String {
  double p;
  int num_s, num_h, sum;
  friend bool operator<(const String a, const String b) { return a.p > b.p; }
} st[maxn];
long long get_ans() {
  long long ans = 0, num_s = 0;
  for (int i = 0; i < n; i++) {
    ans += st[i].sum;
    ans += num_s * st[i].num_h;
    num_s += st[i].num_s;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  char s[maxn];
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    int len = strlen(s);
    int num_s = 0, num_h = 0, sum = 0;
    for (int j = 0; j < len; j++) {
      if (s[j] == 's')
        num_s++;
      else {
        sum += num_s;
        num_h++;
      }
    }
    double p;
    if (num_h == 0)
      p = Max;
    else
      p = (double)num_s / (double)num_h;
    st[i].num_s = num_s;
    st[i].num_h = num_h;
    st[i].sum = sum;
    st[i].p = p;
  }
  sort(st, st + n);
  long long ans = get_ans();
  printf("%lld\n", ans);
  return 0;
}
