#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x, hr, mn, hrp, fhr, fmn, ans;
  string s;
  cin >> s;
  hr = (s[1] - '0') + (s[0] - '0') * 10;
  hrp = (s[1] - '0') * 10 + (s[0] - '0');
  mn = (s[3] - '0') * 10 + (s[4] - '0');
  fhr = hr;
  if (hrp < mn) fhr++;
  fhr %= 24;
  if (fhr % 10 > 5) {
    if (fhr / 10 == 0)
      fhr = 10;
    else if (fhr / 10 == 1)
      fhr = 20;
  }
  fmn = fhr / 10 + (fhr % 10) * 10;
  x = fhr * 60 + fmn;
  if (x == 0 && hr != 0) x = 24 * 60;
  ans = x - (hr * 60 + mn);
  cout << ans;
}
