#include <bits/stdc++.h>
using namespace std;
bool compare1(pair<long long int, int> p1,
              pair<long long int, long long int> p2) {
  if ((p1.first * p2.second) == (p2.first * p1.second)) {
    return (p1.first > p2.first);
  }
  return (p1.first * p2.second) > (p2.first * p1.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  string str;
  vector<pair<long long int, long long int>> vec;
  long long int ctrs, ctrh;
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> str;
    ctrs = 0;
    ctrh = 0;
    for (long long int j = 0; j < str.size(); j++) {
      if (str[j] == 's') {
        ctrs++;
      } else {
        ctrh++;
        sum += ctrs;
      }
    }
    vec.push_back(make_pair(ctrs, ctrh));
  }
  sort(vec.begin(), vec.end(), compare1);
  long long int s_sum = vec[0].first;
  for (int long long i = 1; i < n; i++) {
    sum = sum + s_sum * vec[i].second;
    s_sum += vec[i].first;
  }
  cout << sum << '\n';
  return 0;
}
