#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
struct node {
  string s;
  double p;
} p[maxn];
bool cmp(node a, node b) { return a.p > b.p; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    cin >> p[i].s;
    int len = p[i].s.length() - 1;
    int a = 0, b = 0;
    for (int j = 0; j <= len; ++j) {
      if (p[i].s[j] == 's') a++;
      if (p[i].s[j] == 'h') b++;
    }
    if (b == 0)
      p[i].p = maxn;
    else
      p[i].p = 1.0 * a / b;
  }
  sort(p + 1, p + 1 + n, cmp);
  long long ans = 0;
  int a = 0;
  int b = 0;
  for (int i = 1; i <= n; ++i) {
    int len = p[i].s.length() - 1;
    for (int j = 0; j <= len; ++j) {
      if (p[i].s[j] == 's') a++;
      if (p[i].s[j] == 'h') {
        ans += 1ll * a;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
