#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 17;
int n, cnts[maxn], cnth[maxn], per[maxn];
string s[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string &t = s[i];
    cin >> t;
    for (auto c : t)
      if (c == 's')
        cnts[i]++;
      else
        cnth[i]++;
  }
  iota(per, per + n, 0);
  sort(per, per + n, [](int i, int j) {
    return (long long)cnts[i] * cnth[j] > (long long)cnts[j] * cnth[i];
  });
  long long ans = 0;
  int cs = 0;
  for_each(per, per + n, [&ans, &cs](int i) {
    for (auto c : s[i])
      if (c == 's')
        cs++;
      else
        ans += cs;
  });
  cout << ans << '\n';
  return 0;
}
