#include <bits/stdc++.h>
using namespace std;
bool isPal(int t) {
  int h = t / 60, m = t % 60;
  string sh, sm;
  sh.push_back('0' + h / 10);
  sh.push_back('0' + h % 10);
  sm.push_back('0' + m / 10);
  sm.push_back('0' + m % 10);
  string s = sh + sm;
  string rs = s;
  reverse(rs.begin(), rs.end());
  return s == rs;
}
int main() {
  int h, m;
  scanf("%d:%d", &h, &m);
  int t = h * 60 + m;
  for (int i = 0; i < 24 * 60; i++) {
    int tt = (t + i) % (24 * 60);
    if (isPal(tt)) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}
