#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
int n;
pair<long long, long long> p[N];
long long answ;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first * b.second < a.second * b.first) return true;
  if (a.first * b.second > a.second * b.first) return false;
  return a.first > b.first;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    long long ss = 0, hh = 0;
    for (int i = (int)s.size() - 1; i >= 0; i--) {
      if (s[i] == 's') {
        ss++;
        answ += hh;
      } else
        hh++;
    }
    p[i] = {-ss, hh};
  }
  sort(p + 1, p + n + 1, cmp);
  long long S = 0;
  for (int i = 1; i <= n; i++) {
    answ += S * p[i].second;
    S -= p[i].first;
  }
  cout << answ << endl;
  return 0;
}
