#include <bits/stdc++.h>
using namespace std;
int n;
string s, a[100005];
int cmp(string a, string b) {
  long long h1 = 0, h2 = 0, l1 = a.size(), l2 = b.size();
  for (int i = 0; i < l1; i++) h1 += a[i] == 'h';
  for (int i = 0; i < l2; i++) h2 += b[i] == 'h';
  return ((l1 - h1) * h2 > (l2 - h2) * h1);
}
long long solve(int l, int r) {
  long long sums = 0, ret = 0;
  for (int i = l; i <= r; i++)
    if (s[i] == 's')
      sums++;
    else
      ret += sums;
  return ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n, cmp);
  for (int i = 0; i < n; i++) s += a[i];
  cout << solve(0, s.size() - 1);
  return 0;
}
