#include <bits/stdc++.h>
using namespace std;
string ar[100009];
bool cmpf(string a, string b) {
  long long int s = 0, p = 0, res = 0, sum = 0;
  for (long long int i = 0; a[i] != '\0'; i++) {
    if (a[i] == 's')
      s++;
    else
      sum += s;
  }
  for (long long int i = 0; b[i] != '\0'; i++) {
    if (b[i] == 's') {
      p++;
      s++;
    } else {
      sum += s;
      res += p;
    }
  }
  for (long long int i = 0; a[i] != '\0'; i++) {
    if (a[i] == 's')
      p++;
    else
      res += p;
  }
  return (sum > res);
}
int main() {
  long long int n, i, j;
  cin >> n;
  for (i = 0; i < n; i++) cin >> ar[i];
  sort(ar, ar + n, cmpf);
  long long int s = 0, ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; ar[i][j] != '\0'; j++) {
      if (ar[i][j] == 's')
        s++;
      else
        ans += s;
    }
  }
  cout << ans << endl;
  return 0;
}
