#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long ans = 0;
  for (auto ele : s) {
    int val = ele - 48;
    if (val % 4 == 0) ans++;
  }
  for (int i = 1; i < (int)s.size(); i++) {
    string temp = s.substr(i - 1, 2);
    if (temp[0] == '0') {
      int val = temp[1] - 48;
      if (val % 4 == 0) ans += (long long)i;
    } else if (stoi(temp) % 4 == 0) {
      ans += (long long)i;
    }
  }
  cout << ans << "\n";
  return 0;
}
