#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
const long long N = 1e5 + 5;
const long long MOD = 1e9 + 7;
struct data {
  string str;
  long long s;
  long long h;
} a[N];
bool cmp(data& a, data& b) {
  long long cnt1 = a.s * b.h;
  long long cnt2 = b.s * a.h;
  if (cnt1 != cnt2) return cnt1 > cnt2;
  return a.s > b.s;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i].str;
    for (auto c : a[i].str) {
      if (c == 's')
        a[i].s++;
      else
        a[i].h++;
    }
  }
  sort(a, a + n, cmp);
  long long scnt = 0, ans = 0;
  for (long long i = 0; i < n; i++) {
    for (auto c : a[i].str) {
      if (c == 's')
        scnt++;
      else
        ans += scnt;
    }
  }
  cout << ans;
}
