#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<long long, long long>, int> > v;
int cmp(pair<pair<long long, long long>, int> p1,
        pair<pair<long long, long long>, int> p2) {
  return p1.first.first * p2.first.second > p2.first.first * p1.first.second;
}
long long findsh(string str) {
  long long s = 0;
  long long h = 0;
  long long ans = 0;
  for (int i = 0; i < str.length(); i++) {
    if (str[i] == 's')
      s++;
    else
      ans = ans + s;
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  while (n--) {
    string s;
    cin >> s;
    int cs = 0;
    int ch = 0;
    int sz = s.length();
    for (int i = 0; i < sz; i++) {
      if (s[i] == 's')
        cs++;
      else
        ch++;
    }
    v.push_back(make_pair(make_pair(cs, ch), findsh(s)));
  }
  sort(v.begin(), v.end(), cmp);
  long long s = 0;
  long long h = 0;
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) {
    ans = ans + s * v[i].first.second;
    s = s + v[i].first.first;
    ans = ans + v[i].second;
  }
  cout << ans << endl;
  return 0;
}
