#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const unsigned gen_seed =
    std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
bool comp(const std::pair<long long, long long>& x,
          const std::pair<long long, long long>& y) {
  return x.first * y.second < x.second * y.first;
}
int main() {
  int n;
  scanf("%d\n", &n);
  long long ans = 0;
  std::vector<std::pair<long long, long long> > y;
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    long long a = 0;
    long long b = 0;
    for (auto x : s) {
      if (x == 's')
        a++;
      else if (x == 'h') {
        ans += a;
        b++;
      }
    }
    y.push_back(make_pair(a, b));
  }
  sort((y).begin(), (y).end(), comp);
  reverse((y).begin(), (y).end());
  long long a = 0;
  for (auto x : y) {
    ans += x.second * a;
    a += x.first;
  }
  cout << ans;
}
