#include <bits/stdc++.h>
using namespace std;
int n, k;
string second;
char ch[100100];
pair<int, int> a[100100];
long long ans;
bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first * 1ll * b.second < b.first * 1ll * a.second;
}
void process(string second) {
  int cnt = 0;
  for (int i = 0; i < (int((second).size())); i++) {
    if (second[i] == 's') {
      cnt++;
    } else {
      ans += cnt;
    }
  }
  a[++k] = make_pair(cnt, (int((second).size())) - cnt);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", ch);
    second = ch;
    process(second);
  }
  sort(a + 1, a + n + 1, cmp);
  reverse(a + 1, a + n + 1);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    ans += a[i].second * 1ll * cnt;
    cnt += a[i].first;
  }
  cout << ans << endl;
  return 0;
}
