#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
struct str {
  long long cnt, sol;
  string s;
  str(){};
  str(string _s) {
    cnt = sol = 0;
    s = _s;
    for (int i = (0); i < ((int)s.size()); ++i) {
      if (s[i] == 's')
        ++cnt;
      else
        sol += cnt;
    }
  };
  friend bool operator<(const str A, const str B) {
    return A.sol + A.cnt * ((long long)B.s.size() - B.cnt) + B.sol >
           B.sol + B.cnt * ((long long)A.s.size() - A.cnt) + A.sol;
  }
};
str a[MAXN];
long long n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    string k;
    cin >> k;
    a[i] = str(k);
  }
  sort(a, a + n);
  long long sol = 0;
  long long cnt = 0;
  for (int i = (0); i < (n); ++i) {
    sol += ((long long)a[i].s.size() - a[i].cnt) * cnt;
    sol += a[i].sol;
    cnt += a[i].cnt;
  }
  cout << sol;
}
