#include <bits/stdc++.h>
using namespace std;
bool is(int h, int m) {
  int hh = h, mm = m, cnt = 0;
  while (hh) {
    hh /= 10;
    cnt++;
  }
  string s;
  if (cnt == 1) {
    s += "0";
    s += ('0' + h);
  } else if (!cnt)
    s += "00";
  else {
    string ss;
    hh = h;
    while (hh) {
      int c = hh % 10;
      ss += ('0' + c);
      hh /= 10;
    }
    reverse(ss.begin(), ss.end());
    s += ss;
  }
  s += ":";
  cnt = 0;
  while (mm) {
    mm /= 10;
    cnt++;
  }
  if (cnt == 1) {
    s += "0";
    s += ('0' + m);
  } else if (!cnt)
    s += "00";
  else {
    mm = m;
    string ss;
    while (mm) {
      int c = mm % 10;
      ss += ('0' + c);
      mm /= 10;
    }
    reverse(ss.begin(), ss.end());
    s += ss;
  }
  string s1 = s;
  reverse(s1.begin(), s1.end());
  return s1 == s;
}
int main() {
  string s;
  cin >> s;
  int hh = s[1] - '0';
  hh += 10 * (s[0] - '0');
  int mm = s[4] - '0';
  mm += 10 * (s[3] - '0');
  int ans = 0;
  while (!is(hh, mm)) {
    ans++, mm++;
    if (mm == 60) mm = 0, hh++;
    if (hh == 24) hh = 0;
  }
  cout << ans << endl;
  return 0;
}
