#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<string, pair<long long, long long>>& a,
         pair<string, pair<long long, long long>>& b) {
  return (-a.second.first * b.second.second + b.second.first * a.second.second <
          0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n;
  cin >> n;
  vector<pair<string, pair<long long, long long>>> v(n);
  long long h_all = 0;
  for (int i = 0; i < n; ++i) {
    cin >> v[i].first;
    long long h = 0, s = 0;
    for (auto elem : v[i].first) {
      if (elem == 'h')
        ++h;
      else
        ++s;
    }
    v[i].second.first = s;
    v[i].second.second = h;
    h_all += h;
  }
  sort(v.begin(), v.end(), cmp);
  long long res = 0;
  for (auto elem : v)
    for (auto ch : elem.first) {
      if (ch == 'h')
        --h_all;
      else
        res += h_all;
    }
  cout << res << endl;
  return 0;
}
