#include <bits/stdc++.h>
using namespace std;
struct t {
  long long in, s = 0;
  long long h = 0;
};
bool f(t x, t y) {
  long long s1, s2, h1, h2;
  s1 = x.s;
  h2 = y.h;
  s2 = y.s;
  h1 = x.h;
  if (s1 * h2 > s2 * h1)
    return 1;
  else
    return 0;
}
int main() {
  long long n;
  cin >> n;
  vector<t> v;
  vector<string> v1;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    v1.push_back(s);
    t x;
    for (long long j = 0; j < s.size(); j++) {
      if (s[j] == 's')
        x.s++;
      else
        x.h++;
    }
    x.in = i;
    v.push_back(x);
  }
  string s;
  sort(v.begin(), v.end(), f);
  for (long long i = 0; i < v.size(); i++) {
    s.append(v1[v[i].in]);
  }
  long long a[s.size() + 1];
  a[s.size()] = 0;
  long long ans = 0;
  for (long long i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'h')
      a[i] = a[i + 1] + 1;
    else {
      a[i] = a[i + 1];
      ans = ans + a[i + 1];
    }
  }
  cout << ans << endl;
}
