#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9, PI = acos(-1.);
const long long LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const int N = 1e5 + 5;
int n;
char t[N];
vector<pair<string, pair<long long, long long> > > v;
string ans;
long long hh[N];
long long x;
int main() {
  scanf("%d", &n);
  while (n--) {
    long long s = 0;
    long long h = 0;
    scanf(" %s", t);
    int sz = strlen(t);
    for (int i = 0; i < sz; i++) {
      s += (t[i] == 's');
      h += (t[i] == 'h');
    }
    v.push_back(make_pair(t, make_pair(s, h)));
  }
  sort(v.begin(), v.end(),
       [](pair<string, pair<long long, long long> > a,
          pair<string, pair<long long, long long> > b) {
         long long u = a.second.first * b.second.second;
         long long v = b.second.first * a.second.second;
         return u > v;
       });
  for (auto p : v) ans += p.first;
  for (int i = ans.size(); i >= 1; i--) hh[i] = hh[i + 1] + (ans[i - 1] == 'h');
  for (int i = 1; i <= ans.size(); i++)
    if (ans[i - 1] == 's') x += hh[i];
  printf("%lld\n", x);
  return 0;
}
