#include <bits/stdc++.h>
using std::sort;
int n;
char s[100000 + 1];
struct SH {
  unsigned int s, h;
};
struct SH cnt[100000 + 1];
unsigned long long ans;
void read() {
  scanf("%d", &n);
  ans = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s);
    int l = strlen(s);
    unsigned int sum = 0;
    for (int j = 0; j < l; ++j)
      if (s[j] == 's')
        ++sum;
      else
        ans += sum;
    cnt[i].s = sum;
    cnt[i].h = l - sum;
  }
}
bool compareSH(struct SH &x, struct SH &y) { return x.s * y.h > y.s * x.h; }
void chief() {
  sort(&cnt[1], &cnt[n] + 1, compareSH);
  unsigned int sum = 0;
  for (int i = 1; i <= n; ++i) {
    ans += (unsigned long long)sum * cnt[i].h;
    sum += cnt[i].s;
  }
}
void write() { printf("%I64u\n", ans); }
int main() {
  read();
  chief();
  write();
  return 0;
}
