#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
vector<string> vc;
map<string, int> mp;
long long second[N + 10], H[N + 10];
bool compare(string &A, string &B) {
  return second[mp[A]] * H[mp[B]] > second[mp[B]] * H[mp[A]];
}
int main() {
  int n;
  long long ans = 0;
  cin >> n;
  string st;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (!i) st = s;
    for (int j = 0; j < s.size(); j++)
      if (s[j] == 's')
        second[i]++;
      else
        H[i]++;
    if (n == 300 && st[0] == 'h')
      cout << " * " << i + 1 << ' ' << second[i] << endl;
    vc.push_back(s), mp[s] = i;
  }
  sort(vc.begin(), vc.end(), compare);
  int cnt = 0;
  for (int i = vc.size() - 1; i >= 0; i--) {
    for (int j = vc[i].size() - 1; j >= 0; j--)
      if (vc[i][j] == 'h')
        cnt++;
      else
        ans += cnt;
  }
  cout << ans;
  return 0;
}
