#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back

using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
        string s;
        cin >> s;
        int n=s.size();
        reverse(s.begin(), s.end());
        int x=1;
        int tot=0;
        int m=4;
        vector<int> dp(m);
        ll ans=0;
        for (int i = 0; i < n; ++i)
        {
            dp[tot]++;
            tot+=(s[i]-'0')*x;
            x=(x*10)%m;
            tot%=m;
            ans+=dp[tot];
        }
        cout << ans << endl;
    return 0;
}
