#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long int, long long int> a,
         pair<long long int, long long int> b) {
  long long int x = a.first * b.second, y = a.second * b.first;
  return x > y;
}
int main() {
  int n;
  long long int ans = 0, now;
  string s;
  pair<long long int, long long int> a[100010];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> s;
    a[i].first = a[i].second = 0;
    now = s.length();
    for (int j = 0; j < now; j++) {
      if (s[j] == 's')
        a[i].first++;
      else {
        ans += a[i].first;
        a[i].second++;
      }
    }
  }
  now = 0;
  sort(a, a + n, cmp);
  for (int i = 0; i < n; i++) {
    ans += now * a[i].second;
    now += a[i].first;
  }
  printf("%lld\n", ans);
}
