#include <bits/stdc++.h>
using namespace std;
bool compare(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first * b.second > a.second * b.first) return true;
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  long long ans = 0;
  vector<pair<int, int>> vec(n);
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    int cnt1 = 0, cnt2 = 0;
    for (int j = 0; j < x.length(); j++) {
      if (x[j] == 's')
        cnt1++;
      else {
        ans += cnt1;
        cnt2++;
      }
    }
    vec[i].first = cnt1;
    vec[i].second = cnt2;
  }
  sort(vec.begin(), vec.end(), compare);
  long long res = 0;
  for (int i = 0; i < n; i++) {
    ans += (res * vec[i].second);
    res += vec[i].first;
  }
  cout << ans << endl;
}
