#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string s[n];
  pair<double, int> p[n];
  double c, h;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    c = 0;
    h = 0;
    for (int j = 0; j < (int)s[i].size(); j++) {
      if (s[i][j] == 's')
        c++;
      else
        h++;
    }
    p[i].first = c / h;
    p[i].second = i;
  }
  sort(p, p + n);
  long long ans = 0, cc = 0, hh = 0;
  for (int i = n - 1; i >= 0; i--) {
    int t = p[i].second;
    for (int j = 0; j < (int)s[t].size(); j++) {
      if (s[t][j] == 's')
        cc++;
      else {
        ans += cc;
        hh++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
