#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[100004];
string s[100004];
int main() {
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    int now = 0;
    for (char c : s[i]) {
      if (c == 's')
        now++, a[i].first++;
      else
        ans += now, a[i].second++;
    }
  }
  sort(a, a + n, [](pair<int, int> a, pair<int, int> b) {
    return a.first * (long long)b.second > b.first * (long long)a.second;
  });
  int sum = 0;
  for (int i = 0; i < n; i++) {
    ans += sum * (long long)a[i].second;
    sum += a[i].first;
  }
  cout << ans;
}
