#include <bits/stdc++.h>
using namespace std;
bool compare(pair<int, int> a, pair<int, int> b) {
  long long x = 1ll * a.first * b.second;
  long long y = 1ll * a.second * b.first;
  if (x > y) {
    return true;
  } else if (y > x) {
    return false;
  }
  return (a.first + a.second) < (b.first + b.second);
}
pair<int, int> solve(string& s, long long& ans) {
  pair<int, int> p = {0, 0};
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 's') {
      p.first++;
    } else {
      p.second++;
      ans += p.first;
    }
  }
  return p;
}
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(solve(s, ans));
  }
  sort(v.begin(), v.end(), compare);
  int s = v[0].first;
  for (int i = 1; i < v.size(); i++) {
    ans += 1ll * s * v[i].second;
    s += v[i].first;
  }
  cout << ans;
  return 0;
}
