#include <bits/stdc++.h>
using namespace std;
int n, m, l, r, a;
long long sum;
vector<int> vr;
int main() {
  for (int i = 0; i < 24; ++i) {
    int a = i;
    string s;
    while (a) {
      s.push_back('0' + (a % 10));
      a /= 10;
    }
    string s1 = s;
    a = i * 60;
    int b = 1;
    if (s1.size() == 1) s1 += '0';
    if (s1 >= "60") continue;
    for (int j = s1.length() - 1; j >= 0; --j) {
      a += b * (s1[j] - '0');
      b *= 10;
    }
    vr.push_back(a);
  }
  vr.push_back(1440);
  int a, b;
  scanf("%d:%d", &a, &b);
  b += a * 60;
  int id = lower_bound(vr.begin(), vr.end(), b) - vr.begin();
  if (id == vr.size()) {
    id = 0;
  }
  cout << vr[id] - b << endl;
  return 0;
}
