#include <bits/stdc++.h>
using namespace std;
string s[1000000];
bool cmp(string s1, string s2) {
  long long sa = 0, ha = 0, sb = 0, hb = 0;
  for (char ch : s1) {
    if (ch == 's') {
      sa++;
    } else {
      ha++;
    }
  }
  for (char ch : s2) {
    if (ch == 's') {
      sb++;
    } else {
      hb++;
    }
  }
  return sa * hb > sb * ha;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s, s + n, cmp);
  long long ans = 0, c = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < s[i].size(); j++) {
      if (s[i][j] == 's') {
        c++;
      } else {
        ans += c;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
