#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
string str[maxn];
long long cal(string a) {
  int len = a.length();
  long long ans = 0, num = 0;
  for (int i = 0; i < len; i++) {
    if (a[i] == 's') {
      num++;
    } else if (a[i] == 'h') {
      ans += num;
    }
  }
  return ans;
}
bool cmp(string a, string b) {
  string temp1 = "", temp2 = "";
  temp1 += a, temp1 += b;
  temp2 += b, temp2 += a;
  return cal(temp1) > cal(temp2);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str[i];
  }
  sort(str, str + n, cmp);
  string endStr = "";
  for (int i = 0; i < n; i++) {
    endStr += str[i];
  }
  cout << cal(endStr) << endl;
  return 0;
}
