#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
pair<long long, long long> a[N];
long long ans;
void Convert(pair<long long, long long> &x, const string &s) {
  int a = 0, b = 0;
  for (char ch : s)
    if (ch == 's') {
      a++;
    } else {
      b++;
      ans += a;
    }
  x = make_pair(a, b);
}
bool cmp(const pair<long long, long long> &a,
         const pair<long long, long long> &b) {
  return (a.first * b.second > a.second * b.first);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    Convert(a[i], s);
  }
  sort(a + 1, a + 1 + n, cmp);
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    ans += cnt * a[i].second;
    cnt += a[i].first;
  }
  cout << ans;
}
