#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long exp(long long a, long long b, long long m) {
  if (b == 0) return 1;
  if (b == 1) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
long long suf[200100];
struct sla {
  string s;
  long long second, hh;
};
long long cmp(sla a, sla b) { return a.second * b.hh > b.second * a.hh; }
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  vector<sla> v;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long second = 0, hh = 0;
    for (long long j = 0; j < (long long)s.size(); j++) {
      if (s[j] == 's')
        second++;
      else
        hh++;
    }
    sla aux = {s, second, hh};
    v.push_back(aux);
  }
  sort(v.begin(), v.end(), cmp);
  long long tam = 0;
  string t = "";
  for (long long i = 0; i < n; i++) {
    tam += v[i].s.size();
    t += v[i].s;
  }
  suf[tam] = 0;
  for (long long i = tam - 1; i >= 0; i--) {
    suf[i] = suf[i + 1] + (t[i] == 'h');
  }
  long long ans = 0;
  for (long long i = 0; i < tam; i++) {
    if (t[i] == 's') ans += suf[i];
  }
  cout << ans << "\n";
}
