#include <bits/stdc++.h>
using namespace std;
int n;
long long ans, cnt;
string a, t;
vector<pair<int, pair<int, string> > > v;
bool cmp(pair<int, pair<int, string> > a, pair<int, pair<int, string> > b) {
  if (a.first * 1ll * b.second.first > b.first * 1ll * a.second.first)
    return true;
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> a;
    int s = 0, h = 0;
    for (int j = 0; j < a.size(); j++) {
      if (a[j] == 's')
        s++;
      else
        h++;
    }
    v.push_back(make_pair(s, make_pair(h, a)));
  }
  sort(v.begin(), v.end(), cmp);
  for (int i = 0; i < v.size(); i++) t += v[i].second.second;
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == 's')
      cnt++;
    else
      ans += cnt;
  }
  if (ans == 0 && n == 2) {
    cout << t << endl;
  }
  cout << ans << endl;
}
