#include <bits/stdc++.h>
using namespace std;
struct nd {
  string s;
};
bool operator<(nd a, nd b) {
  string s = a.s + b.s;
  long long ans1 = 0, ans2 = 0, tmp1;
  tmp1 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 's') {
      ++tmp1;
    } else {
      ans1 += tmp1;
    }
  }
  s = b.s + a.s;
  tmp1 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 's') {
      ++tmp1;
    } else {
      ans2 += tmp1;
    }
  }
  return ans1 > ans2;
}
nd a[100010];
int main() {
  int n, tmp1, tmp2;
  string s;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      cin >> s;
      a[i].s = s;
    }
    sort(a, a + n);
    long long tmp1 = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < a[i].s.size(); ++j) {
        if (a[i].s[j] == 's')
          ++tmp1;
        else
          ans += tmp1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
