#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long INF = 1e18;
int n;
struct word {
  string s;
  long long cnts, cnth;
} a[N];
long long ans;
string conc;
long long get_noise(string t) {
  int i;
  long long res, cnts;
  res = cnts = 0;
  for (i = 0; i < t.size(); i++) {
    if (t[i] == 's')
      cnts++;
    else
      res += cnts;
  }
  return res;
}
bool good(int i, int j) {
  long long resi, resj;
  resi = a[i].cnts * a[j].cnth;
  resj = a[j].cnts * a[i].cnth;
  if (resi > resj)
    return true;
  else
    return false;
}
vector<int> conquer(int low, int high) {
  vector<int> res;
  if (low == high) {
    res.push_back(low);
    return res;
  }
  int mid = (low + high) / 2;
  vector<int> x, y;
  x = conquer(low, mid);
  y = conquer(mid + 1, high);
  int xi, yi;
  xi = yi = 0;
  while (xi < x.size() && yi < y.size()) {
    if (good(x[xi], y[yi])) {
      res.push_back(x[xi]);
      xi++;
    } else {
      res.push_back(y[yi]);
      yi++;
    }
  }
  while (xi < x.size()) {
    res.push_back(x[xi]);
    xi++;
  }
  while (yi < y.size()) {
    res.push_back(y[yi]);
    yi++;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i].s;
    a[i].cnts = a[i].cnth = 0;
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < a[i].s.size(); j++) {
      if (a[i].s[j] == 's')
        a[i].cnts++;
      else
        a[i].cnth++;
    }
  }
  vector<int> perm = conquer(1, n);
  for (i = 0; i < n; i++) conc += a[perm[i]].s;
  ans = get_noise(conc);
  cout << ans << endl;
  return 0;
}
