#include <bits/stdc++.h>
using namespace std;
void coordinate_compress(long long a[], long long n) {
  long long b[n];
  for (long long i = 0; i < n; i++) b[i] = a[i];
  sort(b, b + n);
  for (long long i = 0; i < n; i++) {
    a[i] = lower_bound(b, b + n, a[i]) - b;
  }
}
pair<long long, long long> count(string s) {
  long long ans = 0;
  long long s_count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 's')
      s_count++;
    else
      ans += s_count;
  }
  return make_pair(ans, s_count);
}
bool less_than(pair<long long, long long> a1, pair<long long, long long> a2) {
  long long s1, h1, s2, h2;
  s1 = a1.first;
  s2 = a2.first;
  h1 = a1.second;
  h2 = a2.second;
  if (s2 * h1 < s1 * h2) return true;
  if (s2 * h1 > s1 * h2) return false;
  return false;
}
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  vector<pair<long long, long long> > pp;
  for (int i = 0; i < n; i++) {
    string k;
    cin >> k;
    pair<long long, long long> anss = count(k);
    ans += anss.first;
    pp.push_back({anss.second, k.size() - anss.second});
  }
  sort(pp.begin(), pp.end(), less_than);
  long long s_count = pp[0].first;
  for (int i = 1; i < pp.size(); i++) {
    ans += pp[i].second * s_count;
    s_count += pp[i].first;
  }
  cout << ans << endl;
}
